0
$\begingroup$

If you had to write out all the numbers between 1 and 1,000,000. How many zeros would you have to write in total.

I was given that the answer is 488,895. Can any one show the clearest way possible of getting this figure. The couple ways I have tried have given me an answer that is about half of that figure.

  • 0
    And what exactly have you tried?2017-02-21
  • 0
    Hint: Count the number of zeros in al 1-digit numbers; then all 2-digit numbers; then ...2017-02-21

3 Answers 3

0

Here's a fresh way to solve this problem:

How many $1$-digits are there? largest - smallest + 1: or 9 - 1 + 1 = 9.

What is the total number of digits contributed by $1$-digit numbers? $1 \cdot 9 = 9$

How many $2$-digit numbers are there? $99 - 10 + 1 = 82$

What is the total number of digits contributed by $2$-digit numbers? $2 \cdot 82 = 164$

How many $i$-digit numbers are there? $10^{i-1} - 10^i$.

So how many digits are contributed in the $i$-digit numbers?

$i (10^{i-1} - 10^i)$.

How many total digits are contributed by all $6$-digit numbers (i.e., up to 999,999)?

$\sum\limits_{i=1}^6 i (10^i - 10^{i-1}) = 5,888,889$.

How many digits are contributed up to $1,000,000$? We merely add the seven digits of $1,000,000$, thus: $5,888,896$.

Each of the nine digits $1, \ldots, 9$ appear 600,000 times in that list, except $1$ which appears one more (from its appearance in $1,000,000$).

The remaining digits must be $0$s:

$\left(\sum\limits_{i=1}^6 i \left(10^i-10^{i-1}\right)+7\right)-9 \cdot 600000-1 = 488,895$.

Verified by Mathematica:

Counts[Flatten[IntegerDigits /@ Range[{1, 1000000}]]]

(* <|1 -> 600002, 2 -> 600000, 3 -> 600000, 4 -> 600000, 5 -> 600000, 6 -> 600000, 7 -> 600000, 8 -> 600000, 9 -> 600000, 0 -> 488895|> *)

1

Claim: For $k \geq 2$, the number of zero digits among $k$-digit numbers is $(k-1)(10^{k-1}-10^{k-2})$.

Proof: There are exactly $10^k$ sequences of $k$ digits, and in this collection there are $k\cdot 10^k$ digits in total, and each digit occurs the same number of times, i.e., $k \cdot 10^{k-1}$ times.

From these, we exclude those that have a $0$ at the start. There are exactly $10^{k-1}$ sequences of $k$ digits that start with $0$. Ignoring the starting zero, each digit occurs the same number of times, i.e., $(k-1) \cdot 10^{k-2}$ times.

This gives $k \cdot 10^{k-1}-10^{k-1}-(k-1) \cdot 10^{k-2}$ zeroes.

So, the answer is $$6+\sum_{k=2}^6 (k-1)(10^{k-1}-10^{k-2})=488895.$$

This can be verified computationally using the GAP code:

count:=0;
for i in [1..1000000] do
  for d in DigitsNumber(i,10) do
    if(IntChar(d)=48) then count:=count+1; fi;
  od;
od;
count;

which returns 488895.

1

There are 6 positions where the zeros can occur. They will occur in that position 1 out of 10 times. Or at total of $\frac {1,000,000}{10} = 100,000$ times. So there should be a total of $6*100,000 = 600,000$ zeros.

Except zeros do not appear in tens position if the number only has one digit. So that removes $9$ of the potential zeros. That is, we would have counted $1,2,3,4,5,6,7,8,9$ as $01,02,03,04,05,06,07,08,09$ but we don't write those zeros so there are only $600,000 - 9$.

Likewise if the number is less then $100$ we don't count the first zeros in the $100$ position. We count $27$ and $27$ not $027$. So none of the zeros from $1$ to $99$ aren't counted. Sothere are only $600,000 - 9-99$.

We do that for the zeros in 4,5, and position. So there are $600,000 - 9 -99-999- 9,999 - 99,999$ zeros.

$9+99+999+9,999 + 99,999 = 10 -1 + 100 - 1 + 1000 - 1 + 10,000 - 1 + 100,000 -1 = 111,110 - 5$ so there are $600,000 - 9 -99-999- 9,999 - 99,999= 600,000 - 111,110 + 5 = 4,888,895$ zeros.