Saturday, January 9, 2010

A Quite Simple Math Problem

Anyone can add single digits integers ... 5 + 4 = 9, 2 + 4 = 6, etc. Anyone can do this (even Ragknot ... heh heh ... don't tell him I said that).

So this is a quite simple problem ... simply add all the digits in the numbers from 1 to 1,000,000,000.

This is not like the famous problem a school teacher gave to her class to add all the integers from 1 to 100. Her class included the eventually famous mathematician Karl Friedrich Gauss, who at the time was 9 years old. He fairly quickly provided the correct answer of 5,050.

Our problem is a little different. Here's the start:

1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 = 45.
In the next step, when we conssider 10, we do not add 10, but rather 1, making 46.
Next, we consider 11, which adds 2, making a total of 48.
Next, adding the digits in 12, we get 51.
And so so forth up to 1,000,000,000.

Should be easy ... anyone can add single digit integers.

Answer anyone?

10 Comments:

Anonymous Anonymous said...

The solution for a number represented as 10^n is
(45*10^(n-1)*n)+1

e.g for 1 to 10
S=(45*1*1)+1=46

e.g for 1 to 100
S=(45*10*2)+1=901

so for 1,000,000,000= 10^9
the sum is
S=(45*10^8*9)+1

S=40,500,000,001

Cam

January 9, 2010 6:32 AM  
Anonymous Anonymous said...

Why does (45*10^(n-1)*n)+1
work ?

We know digits 1 to 9 add to 45
consider every digit added on
that column will increment by 1 every 1/(10^n) digits e.g. 1s column up 1 every digit, 10s column increments every 10 digits, 100s column every 100 digits

Consider for 1 to 100
For 1 to 100 we should have. 10 0s, 10 1s, 10 2s, etc.
since we have 10 of each we can group them in 10 groups of 1to9, which has the sum 45 each. Total sum for the 10s column is then 10*45=450

Back to the 1s column, 1 to 9 must repeat 10 times. So the sum is 10*45=450

Every new digit added will have 10*more 1 to 9 groups and will require the lower columns to repeat 10x more. Thus the sum is:
45*10^(n-1) for each column
but we must use n columns
so
45*10^(n-1)*n
but we must add 1 for the last 10^n digit, being 1 with the string of trailing 0s

Thus:

S=(45*10^(n-1)*n)+1

Cam

January 9, 2010 6:47 AM  
Blogger Chris said...

1000000 = 1 + 9*111111
As each set of 9 integers adds 45 we get:

Sum = 45*111111 + 1 = 4999996

January 9, 2010 6:54 AM  
Blogger Chris said...

I meant to say that each (in fact any) set of 9 consecutive integers adds 45 to the sum.

I secretly used mod 9 arithmetic. To wit, in base 10, the remainder after dividing a number by 9 is the same as the remainder after adding the digits of the number and then dividing by 9, and that can be done recursively.

I have assumed that e.g. 997 => 9+9+7 = 25 => 7

January 9, 2010 7:20 AM  
Anonymous Zaux said...

Cam ... do you really think that 40,500,000,001 is the total?

Oh ... wait ... I think that too.
Good analysis, as usual.

January 9, 2010 7:30 AM  
Blogger Chris said...

Zaux. Your question confused me. I read 99 => 18 => 9 whereas you seem to have meant 18. But you ended by saying "anyone can add single digit integers". But 18 is a two digit integer.

But I accept that Cam has correctly answered the harder problem that you intended.

January 9, 2010 8:28 AM  
Anonymous Zaux said...

Chris ... in this case, you are always adding single digit integers. Treat each digit of the next number as an individual number.

January 9, 2010 9:50 AM  
Blogger Chris said...

Hi Zaux. Because you said that Cam got it right, I was able to deduce that e.g. 997 added 25 (=9+9+7) and not 7 (=2+5). I did the latter, Cam and you did the former.

No sweat, I simply jumped to the wrong conclusion.

January 9, 2010 10:32 AM  
Anonymous Anonymous said...

sfw

January 9, 2010 5:15 PM  
Blogger Chris said...

Hear, hear, some fine work indeed.

January 10, 2010 3:15 AM  

Post a Comment

Links to this post:

Create a Link

<< Home