3
$\begingroup$

The integers from 1 to 222,222 are written. How many times is the digit zero written?

From $1$ to $10^n$, any digit appears $n \cdot 10^{n-1}$ times in all orders, zero starts to appear $n \cdot 10^{n-1}$ times, in the first, second,.... n-th order, in all units, tens, hundreds from 10 onwards and so on. So we have:

$$222222=2\cdot10^5+2\cdot 10^4+2 \cdot 10^3+2\cdot 10^2+2 \cdot 10^1+2$$

$2\cdot 5 \cdot 10^4=100000$ digits, $2\cdot 4 \cdot 10^3=8000$ digits, $2\cdot 3 \cdot 10^2=600$ digits, $2\cdot 2 \cdot 10=40$ digits, $2\cdot 1 \cdot 10^0=2$ digits. Adding up we have $108642$ digits, which is the answer to the question.

I have the following doubts: how to deduce the "formula" $n \cdot 10^{n-1}$? The other doubt is, why by transforming the 22...2 into base 10 and applying the formula for each parcel, can we find out the number of zeros that appear?"

$\endgroup$
5
  • $\begingroup$ What are you familiar with? What have you tried? EG With the statement, induction seems like a reasonable approach, though it doesn't quite have the satisfying crux. $\endgroup$
    – Calvin Lin
    Commented Sep 27, 2023 at 2:21
  • 3
    $\begingroup$ FWIW I don't think your claim is true for the general case. EG 1/ The number of 0's that it takes to write from 1 to 100, is 1 less than the number of 0's it takes to write from 1 to 101. Yet, in both cases, your formula yields $ 1 \times 10^1 + 0 \times 10^0 = 10$. 2/ The number of 0's that it takes to write from 1 to 110 is 20, but your formula gives us $1 \times 10^ 1 + 1 \times 10^0 = 11$. $\endgroup$
    – Calvin Lin
    Commented Sep 27, 2023 at 2:23
  • $\begingroup$ Didn't like that the answers didn't directly address my question and instead offered other solutions $\endgroup$ Commented Sep 27, 2023 at 13:19
  • $\begingroup$ Aschepler's solution does address your question. I suggest you review it and interact with them. $\endgroup$
    – Calvin Lin
    Commented Sep 27, 2023 at 13:31
  • $\begingroup$ @CalvinLin sure, but I was wanting to explore a closed formula for the number of times a number appears from 1 to 10^n. $\endgroup$ Commented Sep 27, 2023 at 13:51

1 Answer 1

1
$\begingroup$

I find this approach the easiest. Its results can be converted to the form of your other solution, for what that's worth.

How many times does zero appear in the units position? The digits left of a final zero can be a number from $1$ to $22222$, so there are $22222$ zeros in the unit position.

How many times does zero appear in the tens position? The digits left of it can be from $1$ to $2222$, and the digit right of it can be from $0$ to $9$, independently. So there are $2222 \cdot 10 = 22220$ zeros in the tens position.

How many times does zero appear in the hundreds position? $222 \times 100 = 22200$

How many times does zero appear in the thousands position? $22 \times 1000 = 22000$

How many times does zero appear in the ten-thousands position? $2 \times 10000 = 20000$

Zero can't appear in the hundred-thousands position.

So the total number of zeros is $22222 + 22220 + 22200 + 22000 + 20000 = 108642$.

$\endgroup$
4
  • $\begingroup$ Is there any way to generalize this? For example, how can we guarantee that a certain quantity of digits appears that number of times? For instance, from 1 to 1111, the digit zero appears in the units place 111 times, and so on... and why did you add the results? $\endgroup$ Commented Sep 27, 2023 at 13:46
  • $\begingroup$ The results are added because we can think of this method as the shortcut to writing all the numbers in a vertical list, finding the number of zeros in each column, then adding those subtotals together. It generalizes in the obvious way as long as the maximum number doesn't itself contain any zero digits. If the maximum number does contain zeros, I think a tweak to the method could account for that too. $\endgroup$
    – aschepler
    Commented Sep 27, 2023 at 13:54
  • $\begingroup$ Is there any way to ensure that we will have these patterns in the counts of 0's in each order of the digits? $\endgroup$ Commented Sep 27, 2023 at 14:21
  • $\begingroup$ I don't understand what you mean. $\endgroup$
    – aschepler
    Commented Sep 27, 2023 at 14:26

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .