# how to confirm that for $n<1000$, each number $0,…,9$ appears exactly $300$ times

How can we know that among all numbers with $3$ or fewer digits (i.e. a number $n<1000$), each digit (from $0$ to $9$) appears exactly $300$ times? I'm trying to convince myself, but I can't seem to find the right way to do so.

(If you're wondering about the context, here's the problem to which the statement above was a pretty integral part of solution:

Find the sum of the digits of all numbers in the sequence $1,2,3,4,\ldots,100$.)

## 2 Answers

I don't think that's the case for $0$ because you don't usually write a number less than $100$ by adding zero(s) to the front. However, as Mjiig pointed out, you can allow $0$ if you want to, though $0$ doesn't contribute towards the sum of digits.

Hint: prove that $1$ to $9$ each appears $100$ times in hundreds, tens, and units digit respectively, so that's $300$ times in total for each.

Something more fun: Use induction and you prove that for $n<10^k,k\in \mathbb{N^*}$, $0$ to $9$ appears exactly $k\cdot 10^{k-1}$ times

• You can make it correct by including 0 and writing every number with leading zeros out to three digits if you want to. – Mjiig May 29 '18 at 11:44
• Yes you are right. – Macrophage May 29 '18 at 11:44

Including leading zeros you can see this as follows.

Let $d$ be a digit from $0,\ldots , 9$

• there is exactly 1 3-digit number $ddd$ $\Rightarrow 3$ occurrences
• there are $\binom{3}{2}\cdot 9$ 3-digit numbers, where $d$ occurs exactly twice $\Rightarrow 3\cdot 9 \cdot 2 = 54$ occurrences
• there are $\binom{3}{1}\cdot 9^2$ 3-digit numbers, where $d$ occurs exactly once $\Rightarrow 3\cdot 9^2 = 243$ occurrences

All together $300$ occurrences.

Here is another shorter argument:

If you write down all 3-digit codes with digits $0,\ldots , 9$, you write all together $3000$ digits. Each digit occurs equally often. So, each digit occurs $$\frac{3000}{10}= 300 \mbox{ times}$$