Radio Astronomy Systems Research Group

Log In
Home Sitemap Recent Changes Media Manager

Trace: digits

wiki:donuts:digits

Answer:

There are two ways of solving this. For a pretty thorough explanation of the first check out this video: http://www.youtube.com/watch?v=Dd81F6-Ar_0

Here is a brief explanation of both.

Method 1

Similar to the Gauss question, add up the digits in each pair of numbers.

0 1 2 3 ... 999996 999997 999998 999999 1000000
^                                   ^ 
0 1 2 3 ... 999996 999997 999998 999999 1000000
  ^                         ^ 
0 1 2 3 ... 999996 999997 999998 999999 1000000
    ^                ^ 
0 1 2 3 ... 999996 999997 999998 999999 1000000
      ^        ^ 
  etc.
0 + 999999 = 999999
1 + 999998 = 999999
2 + 999997 = 999999
....

Now you have 500000 pairs that sum up to 999999

500000 * (9 + 9 + 9 + 9 + 9 + 9) = 27000000

Don't forget 1 million!

27000000 + 1 + 0 + 0 + 0 + 0 + 0 + 0 = 27000001
Method 2

Write each number using 6 digits (i.e. zero extend)

000001
000002
000003
...
999999

Each digit shows up in each column 100000 times. The sum of the digits 1-9 is 45.

45*100000*6 = 27000000

Plus that last 1 in 1 million

27000000 + 1 = 27000001
wiki/donuts/digits.txt · Last modified: 2013/06/27 14:01 by ceb0590