Find the sum of all the digits in the numbers $1$, $2$, $3$, ... $9999999$

61 Views Asked by At

I tried to solve the problem with two different methods.

First, I paired $1$ and $9999999$, $2$ and $9999998$... $4999999$ and $5000001$, and summed the digits up. Each pair's digits sum up to $64$, and I have $4999999$ such pairs. $64\cdot4999999=319999936$. Add the $5$ on the $5000000$ gives $319999941$.

Second, I left $9999999$ as its own group and paired $1$ and $9999998$ ... $4999999$ and $5000000$. Each pair had a digit sum of $63$, and I have $5000000$ such pairs, giving me $315000000$.

Which method, if any, is correct?

2

There are 2 best solutions below

1
On BEST ANSWER

Hint: Take both methods, and write down the first 10 pairs explicitly. You will see your mistake appear plain as day in one of the approaches.

0
On

Your first attempt is wrong.

For example $10$ and $9999990$ have a combined digit sum of $55$ not $64$ and there are other examples.

Your second attempt is $7 \times \frac1{10}\sum\limits_{n=0}^9 n \times 10^7$ and is correct.