# On Gauss' Shoulders

This is problem 34 from R. Honsberger's More Mathematical Morsels (MAA, New Math Library, 1991):

The solution is based on an idea of young Gauss.

What is the sum of all the digits used in writing down the numbers from one to a billion?

### Solution

Prepend zeros to short numbers to make all the billion of them the same length. This will not change the sum of their digits. Pair the numbers the same distance from the two ends of the sequence (omitting for a moment the billion itself and counting $0$ as the first term in the series):

\begin{align}&(000,000,000;999,999,999),\\ &(000,000,001;999,999,998),\\ &(000,000,002;999,999,997),\\ &(000,000,003;999,999,996),\\ &\qquad\qquad\ldots\ldots\\ &(128,956,347;871,043,652),\\ &\qquad\qquad\ldots\ldots\\ &(234,565,432;765,434,567),\\ &\qquad\qquad\ldots\ldots\\ &(499,999,998,500,000,001),\\ &(499,999,999,500,000,000). \end{align}

The sum of the digits of the numbers in any pair is $9\times 9=81$ and there are half a billion of such pairs. So adding $1$ from the omitted billion we get

$81\times 500,000,000+1=40,500,000,001.$

Here's another count, by Jacob Janssen and, independently, by Amit Itagi, who chose to stand on their own feet:

Write each number between $1$ and a billion except $1,000,000,000$ as a $9-digit$ number possibly starting with zeros. Then the last digit appears $10^8$ times as a $1,$ $10^8$ times as a $2,$ etc. Same for all digits. Since $1+\ldots +9 = 45,$ we have for each digit $45\times 10^8.$ So $9\times 45\times 10^8 + 1 = 40,500,000,001.$