XIII OM - I - Problem 2

How many digits do all natural numbers with at most $ m $ digits have in total?
The number of one-digit natural numbers is $ c_1 = 9 $; the number of two-digit numbers is $ c_2= 10^2 -10= 10 \cdot 9 $, they have $ 2 \cdot 10 \cdot 9 $ digits; the number of three-digit numbers is $ c_3=10^3-10^2= 10^2 \cdot 9 $, the number of their digits is $ 3 \cdot 10^2 \cdot 9 $, etc. Finally, the number of $ m $-digit numbers is $ c_m = 10^m -10^{m-1} = 10^{m-1} \cdot 9 $; they have $ c_m =m \cdot 10^{m-1} \cdot 9 $ digits. 
All numbers with at most $ m $ digits have in total



digits. To calculate the value of the expression in parentheses in formula (1), we will first solve a more general problem, namely find the formula for the sum



where $ a \ne 1 $, depending on $ a $. From equality (2) we get



Subtracting equality (3) from (2) we have



from which



After arranging the terms, we get the formula



Taking $ a = 10 $ in (2) and (4) and substituting the obtained value of the sum (2) into equality (1), we get the desired number of



Note. We derived formula (4) under the assumption that $ a \ne 1 $. When $ a = 1 $, formula (4) makes no sense; in this case, the value of $ S $ can be obtained by substituting $ a = 1 $ in formula (2):



thus, according to the known formula for an arithmetic progression,



We can, however, arrive at formula (5) based on formula (4) by the following reasoning. 
Let $ a -1= x $; substituting $ a = 1 + x $ in formula (4) we get



Expanding $ (1 + x)^{m+1} $ and $ (1 + x)^m $ according to the binomial theorem of Newton. We will only calculate the terms containing $ x^0 $, $ x $, and $ x^2 $; the remaining terms form a polynomial in $ x $, in which all terms are of at least the third degree and we can write



where $ f(x) $ denotes some polynomial in $ x $.
Hence,






or



Substituting $ a = 1 $ in formula (6) we get formula (5). It turns out, therefore, that formula (6) gives the value of the sum (2) for any value of $ a $. However, it is useful for calculating this sum only when $ a = 1 $; when $ a \ne 1 $, it must be restored to the form (4).