Consider all the positive integers up to $10000000000 $ in which every digit is $0$ or $2$.What is the total number of $0$s among their digits?

111 Views Asked by At

Consider all the positive integers up to $10000000000 $ in which every digit is $0$ or $2$. What is the total number of $0$s among their digits?

I tried using the stars and bars method where The $0$S were stars and digits were bars but it didn’t work because the possible number of digits is different

Taken from 2014 imc.

2

There are 2 best solutions below

0
On BEST ANSWER

The interval $[10^r,10^{r+1}-1]$ contains all $(r+1)$-digit numbers. If a number in that interval consists of just $0$'s and $2$'s, then it must start with a $2$, followed by $r$ trailing digits. The number of such numbers is $2^r$, so the total number of trailing digits is $r2^r$; and by symmetry exactly half of the trailing digits are $0$, giving a total of $r2^{r-1}$ $0$'s.

Now just add up $r2^{r-1}$ for $0\le r\le 9$. (If you don't want to do this by hand, you will find tips for summing the series here, but doing it by hand is probably just as fast.)

0
On

In the interval $[10^j,10^{j+1}-1]$, for $1\leq k\leq j$, there are $\binom{j}{k}$ numbers with exactly $k$ digits $0$ and $2$ the remaining ones. Hence the number of such zeros is $$\sum_{j=0}^9\sum_{k=1}^j k\binom{j}{k}=\sum_{j=0}^9j\sum_{k=1}^j \binom{j-1}{k-1}=\sum_{j=0}^9j2^{j-1}=2^{9}\cdot 8+1=4097.$$