Calculate the sum

$$
1+11+111+1111+\cdots+\underbrace{1111 \ldots 11}_{n \text { ones }}
$$
Solution

A solution can be made using the sum of geometric progressions. But we will give another solution that does not require this! Observe. Let's call $S$ the sum we want to calculate, that is,

$$
S=1+11+111+1111+\cdots+\underbrace{1111 \ldots 11}_{n \text { ones }} .
$$

What is the value of $9 \times S$? It's enough to replace each digit one with a digit nine!

$$
9 S=9+99+999+9999+\cdots+\underbrace{9999 \ldots 99}_{n \text { nines }}
$$

Now let's write $9=10-1$. And we do the same with $99=100-1$, $999=1000-1$ and so on. That is,

$$
\begin{array}{ccccc}
9 & = & 10-1 & = & 10^{1}-1 \\
99 & = & 100-1 & = & 10^{2}-1 \\
999 & = & 1000-1 & = & 10^{3}-1 \\
9999 & = & 10000-1 & = & 10^{4}-1 \\
\vdots & & \vdots & & \vdots \\
\underbrace{9999 \cdots 9}_{n \text { nines }} & = & 1 \underbrace{000 \cdots 0}_{n \text { zeros }}-1 & & 10^{n}-1
\end{array}
$$

Making these substitutions in $9 S$, we get

$$
9 S=(10-1)+\left(10^{2}-1\right)+\left(10^{3}-1\right)+\left(10^{4}-1\right)+\cdots+\left(10^{n}-1\right)
$$

Grouping all the "minus ones", we get

$$
\begin{aligned}
9 S & =\left(10+10^{2}+10^{3}+10^{4}+\cdots+10^{n}\right)-(\underbrace{1+1+1+\cdots+1}_{n \text { ones }}) \\
& =10 \cdot \underbrace{111111 \cdots 1}_{n \text { ones }}-n
\end{aligned}
$$

To write the number above better, let's multiply and divide by nine the term with many "ones". Observe:

$$
\begin{aligned}
9 S & =10 \times \frac{9}{9} \underbrace{111111 \cdots 1}_{n \text { ones }}-n \\
& =\frac{10}{9} \underbrace{99999 \cdots 9}_{n \text { nines }}-n \\
& =\frac{10}{9}\left(10^{n}-1\right)-n
\end{aligned}
$$

Therefore,

$$
9 S=\frac{10}{9}\left(10^{n}-1\right)-n
$$

Moving the factor nine to the other side of the equation, we have

$$
S=\frac{10}{81}\left(10^{n}-1\right)-\frac{n}{9}
$$

thus obtaining the desired value!