How many zeroes are in the numerals from $m$ to $n$? Counting Zeroes
If I write down the decimal representations of all natural numbers between and including $m$ and $n$, ($m \leq n$), how many zeroes will I write down? How to calculate it? $m$ and $n$ will be 32-bit integers.
For example if $m = 10$ and $n = 11$ the answer is $1$. But if $m = 13423$ and $n = 2352352454$ then what will be the answer?
 A: It is easiest to do it for $1$ to $n$.  Then if you want $m$ to $n$ subtract from $1$ to $m-1$.  If you want the number of zeros up to $13423$, it is the number up to $10000$ plus the number up to $3423$.  Going up to $10000$ note that each place except the $1000$'s contributes the same number of zeros (how many?)  The $1000$'s are none because it would be a leading zero, so going up to $10000$ is $3$ places times $1000$=$3000$.  This should suggest a recursive algorithm.
A: There is 1 zero (for the last digit) for every 10 numbers,
there is 10 additionnal zero every 100 numbers,
there is 100 additionnal zero every 1000 numbers...
This would imply that the numbers of zeros is approximatly
$$\sum_{k \geq 1} 10^{k-1}\left\lfloor \frac{n}{10^k} \right\rfloor$$
But this formula is not exact, as there is a problem when you count $10^k$ zeros in one group. The formula become :
$$\sum_{k \geq 1} 
\left\lbrace \begin{array} 
.10^{k-1}\left\lfloor \frac{n}{10^k}\right\rfloor & \text{if} & \text{k=1 or the k-th digit is not 0} \\
10^{k-1}\left(\left\lfloor \frac{n}{10^k}\right\rfloor -1\right) +n+1- 10^k\left\lfloor \frac{n}{10^k}\right\rfloor & \text{if} & \text{the k-th digit is 0 and k is not 1}\\
\end{array}\right.$$
Edit : this formula seems to work. I tested it on some numbers with the computer
