Problem :
How many zeros are in all natural numbers from $1$ to $2019$ ?
My attempt :
From $1$ to $100$ we have $11$ zeros
Now from $101$ to $110$ we have $10$ zeros
So from $20$ zeros
Moreover from $101$ to $1000$ we have $201$ zeros
But its very tried I need simple method to calculated this zeros
$\endgroup$ 42 Answers
$\begingroup$First look at $1$ to $99$, than $100$ to $1000$, than $1000$ to $2000$ and than the last from $2000$ to $2019$. We look at the different choices for a fixed digit to be zero. Counting the choices is easier than counting all possibilities.
Start by looking at the numbers $1$ to $99$. There are $9$ numbers that end with a $0$, namely $10,20,30,\dots,90$. Because there are $9$ choices for the first digit.
Next look at all numbers from $100$ to $999$. Here there are $90$ numbers that end with a $0$, namely $100, 110, 120,\dots,990$. Because there are $9$ choices for the first digit and $10$ choices for the second digit. Next there are $90$ numbers that have a $0$ in the middle, these are $100, 101, 102,\dots,908,909$. Because $9$ choices for the first digit and $10$ choices for the last digit.
Next, look at the numbers from $1000$ to $2000$, there are $100$ numbers ending with a $0$, namely $1000,1010,\dots,1990$. Furthermore, there are $100$ numbers where the third digit is a $0$, namely $1000, 1001,\dots, 1909$. Lastly there are also $100$ numbers where the second digit is a $0$, these are $1000,1001,\dots,1099$.
Lastly we want to look at the numbers from $2000$ to $2019$. there are $20$ numbers where the second digit is a $0$, namely $2000,2001,\dots,2019$. Furthermore there are $10$ numbers where the third digit is a zero, these are $2000, 2001,\dots,2009$, and lastly there are $2$ numbers where the last digit is a $0$, namely $2000, 2010$.
This results in $9+90+90+100+100+100+20+10+2 = 521$. Counting the choices is easier than counting all possibilities.
$\endgroup$ $\begingroup$Taking advantage of Wolfram Mathematica, by brute force, we have:
Count[ToExpression@StringCases[ToString@Table[n, {n, 1, 2019}], DigitCharacter], 0]521
while, reasoning a moment, we have:
$$ \begin{aligned} n_{1,2019} & = n_{1,99} + 9 \cdot n_{100,199} + n_{1000,1099} +9 \cdot n_{1100,1199} + n_{2000,2019} \\ & = 9 + 9 \cdot 20 + 120 + 9 \cdot 20 + 32 \\ & = 521\,. \end{aligned} $$
$\endgroup$