puzzle contents
Contents
raw puzzle

What is the sum of the digit sums between one and one-million?

Solution

The solution can be calculated quite quickly without the help of a computer. The trick is similar to the summation of natural numbers:

\[\sum\limits_{i=1}^n i = \frac{1}{2}n(n+1)\]

The way this works is by writing down all natural numbers from \(1\) to \(n\) and add a second column where the numbers are reversed:

1n
2n-1
3n-2
......
n-12
n1

Summing every row always gives \(n+1\). How often? Exactly \(n\) times. Dividing by two results in the given formula. Coming back to the original problem, we can do a similar thing. We start with 0 up to 999999 to include all 6 digits numbers. The number one-million will be treated separately.

0999999
1999998
2999997
......
9999990

What we see is that every row has a sum of \(999999\) and as such a digit sum of \(6\cdot 9=54\). We have exactly one million of such digit sums, and doubled the result as in the sum of natural numbers. We have to divide by two again, which gives \(\frac{1}{2} 1000000 \cdot 54\). Since we have to include the upper bound of one million, we add its digit sum, which is 1 of course. All in all, the sum of all digit sums between one and one-million is 27000001.