-1
$\begingroup$

Okay i need to see if there is a formula to calculate how many 0's are between two given number for example the number of 0's between 100 and 200 is 20 and the number of 0's between 1234567890 and 2345678901 is 987654304, is there a reliable equation that can calculate this number? (note: 100 counts as two 0's 1000 is three and 101 is one)

  • 0
    Also some recent techniques here: [Writing Out The Number of Zeros From 1 - 1,000,000](http://math.stackexchange.com/questions/2153915/writing-out-the-number-of-zeros-from-1-1-000-000)2017-02-22
  • 0
    You might want to mention how you know the answer for 1234567890 and 2345678901.2017-02-22
  • 0
    **Between** 100 and 200 there are 18 zeros, not 20: 101 through 109 plus 110 through 190, that is 9+9. Unless you include **exactly one** of those two bounding numbers (but you didn't specify that).2017-02-22

1 Answers 1

1

The number of zero digits in a positive integer $k$ is:

$$\sum\limits_{i=0}^{\log_{10}{k}}1-\left\lceil\frac{\left\lfloor\frac{k}{10^{i}}\right\rfloor-10\left\lfloor\frac{k}{10^{i+1}}\right\rfloor}{10}\right\rceil$$


The number of zero digits in the range $[1,n]$ is therefore:

$$\sum\limits_{k=1}^{n}\sum\limits_{i=0}^{\log_{10}{k}}1-\left\lceil\frac{\left\lfloor\frac{k}{10^{i}}\right\rfloor-10\left\lfloor\frac{k}{10^{i+1}}\right\rfloor}{10}\right\rceil$$


The number of zero digits in the range $[m,n]$ is therefore:

$$\left(\sum\limits_{k=1}^{n}\sum\limits_{i=0}^{\log_{10}{k}}1-\left\lceil\frac{\left\lfloor\frac{k}{10^{i}}\right\rfloor-10\left\lfloor\frac{k}{10^{i+1}}\right\rfloor}{10}\right\rceil\right)-\left(\sum\limits_{k=1}^{m-1}\sum\limits_{i=0}^{\log_{10}{k}}1-\left\lceil\frac{\left\lfloor\frac{k}{10^{i}}\right\rfloor-10\left\lfloor\frac{k}{10^{i+1}}\right\rfloor}{10}\right\rceil\right)$$

  • 0
    for the number of zero digits in the range [m,n] what is k, n, and i? sorry my understanding of it is pretty basic. if i were to write this as a program what am i plugging into k n and i in the equation?2017-02-22
  • 0
    @JacobBowman: In the last formula, `k` and `i` are intermediate variables. `k` is your counter in the outer loop, and `i` is your counter in the inner loop.2017-02-22