I have a small problem that goes like this: Find number $N$ in a series of consecutive numbers starting from $1$, $(1,2,\cdots,N)$ where $N$ is a multiple of $10$, and the number of appearances of the digit $1$ in the entire series equals $N$.
EX:
$f(1) = 1 \ $ (1)
$f(2) = 1 \ $ (1,2)
$f(12) = 5 \ $ (1,2,3,4,5,6,7,8,9,10,11,12)
I have written a Java program that does this for me, and I came up with $N=199990$, but how would I go about explaining this result in a mathematical way ?
Thanks
You can consider the number of $1$'s in each place. Aside from the first one, if you counted up to $200000$ each place would be $1/10\ 1$'s, so would contribute $20000\ 1$'s. The missing numbers don't take any away except for the $1$'s place, where you lose $199991$. The first place contributes $99991$ from $100000$ through $199990$. As $5 \cdot 20000-1 + 99991=199990$ you are there. Others (not all multiples of $10$) are shown in A014778