# Number of “1”s in a certain number

How many ones are in the decimal representation of $S = \displaystyle \frac{10^{n+1} - 10 - 9n}{81}$, and the specific case $n=2002$? What I have tried doing is adding up the digits individually, but there doesn't seem to be a clear pattern.

Let $$A := \frac{10^{n+1}-10}{9}=10(1+10+10^2+ \cdots + 10^{n-1})$$ Therefore $S=\frac{A-n}{9}$ $$A=11111.......110$$ where number of 1's are 2002 as $n=2002$ now $A-2002$=$1111.......09108$ where number of 1's are $4$ less that is $1998$ now this is nothing but $1111.....100000$+$9108$ now notice there is a pattern when you divide a number with consecutive 1's and try to use that property $$property:$$ when u divide a number containing 5 1's by 9 you get a number of form $1234.555555\cdots$ similarly for 6 1's you get $12345.666666\cdots$ except for when you have 9 1's you get $123456789$ and then for 10 1's you have $1234567890.111\cdots$ and then it is cyclic now see when number of 1's are 2002 the last digits of the number when divided by 9 is same as when number have 5 1's are divided by 9 so then you can calculate the number of 1's present after adding $\frac{9108}{9}$ which is $1012$