# Misc: Sum of Digit-Sums between one and a million

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:

1 | n |

2 | n-1 |

3 | n-2 |

... | ... |

n-1 | 2 |

n | 1 |

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.

0 | 999999 |

1 | 999998 |

2 | 999997 |

... | ... |

999999 | 0 |

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.