Given two integers A and B , how to efficiently compute the sum of all the digits of every number int the set $\{N | A \le N \le B \} $.

For example: **A = 100** and **B = 777**, then the required answer is **8655**.

I am interested in deriving an formula/efficient algorithm for the same.