### The Sum of 1 + 22 + 333 + 4444 + ... to $n$ terms

This is an extension of the NRICH problem called

Clickety Click and All the Sixes , where the solution involves
summing the series

$$1 + 11 + 111 + 1111 +\cdots$$ to $n$ terms.

Each term of the series $1 + 22 + 333 + 4444 +\cdots$ can be
written as $k (1 + 10 + 100 + \cdots + 10^{k -1} )$ for some value
of $k$. Using geometric series theory each term can be written as
$k (10^ {k} -1)/9$. So the sum $S_n$ can be written as $$\eqalign{
S_n &=& 1\left(\frac{10^1-1}{9}\right) +
2\left(\frac{10^2-1}{9}\right) + 3\left(\frac{10^3-1}{9}\right) +
4\left(\frac{10^4-1}{9}\right) + \cdots \\ \; &=&
{1\over9}(1.10^1 + 2.10^2 + 3.10^3 +4.10^4 + \cdots + n.10^n -
(1+2+3+4+ \cdots +n)) \\ \; &=& {1\over9}(1.10^1 + 2.10^2 +
3.10^3 +4.10^4 + \cdots + n.10^n - {1\over2}n(n+1))}$$

To find the formula for $1.10^1 + 2.10^2 + 3.10^3 + 4.10^4 + \cdots
+ nx^n$ consider the series $$y = 1+ x + x^2 + x^3 + \cdots + x^n =
\frac{x^{n+1}-1}{x-1}$$

Differentiating this expression and multiplying the derivative by x
we get $$\eqalign{ x\frac{dy}{dx} &=& x + 2x^2 + 3x^3 +
\cdots + nx^n \\ \; &=& \frac{nx^{n+2} - (n+1)x^{n+1} +
x}{(x-1)^2}}$$.

Hence $$10 + 2.10^2 + 3.10^3 + \cdots + n.10^n = \frac{n.10^{n+2} -
(n+1).10^{n+1} + 10}{81}$$

So the sum of $n$ terms of the original series is $$S_n = 1 + 22 +
333 + 4444 + \cdots = {1\over9}\left(\frac{n.10^{n+2} -
(n+1).10^{n+1} + 10}{81} - {1\over2}n(n+1)\right)$$

Note that when $n$ is greater than 9, terms cannot be written with
a repeated single digit and the $k^{th}$ term should be treated as
$k (10^0 + 10^1 + 10^2 + \cdots + 10^{k-1})$.