Techniques for Adding the Numbers 1 to 100

@nada: If you want to add 47 to 100, for example, you can do this: Add 1 to 100 (all the numbers: (100 * 101)/2) and the subtract the sum of 1 to 46 (all the numbers you don’t want (46 * 47)/2).

My question is how to add/count every “1” found between 0 and any end point. End Point could be 10,000. Thanks.

I stumbled across your page while looking for an answer to the same question posed in #30, but was intrigued by all the methods described here. I was trying to figure out a way to map a series of numbers (say 1 through 15) to a smaller result set of numbers (say 1 through 5) such that:
1 => 1
2,3 => 2
4,5,6 => 3
7,8,9,10 => 4
11,12,13,14,15 => 5
as I was pondering how to write a mathematical function to get a result (instead of doing brute iteration) I realized that this smacked of Gauss. Not being able to memorize formulas, I sat down with a piece of paper and tried summing 1 through 100. I cut the set in half, yielding 1 through 50 and 51 through 100. The two ‘half’ sets match such that you can make a pair using one number from each half-set that adds up to 101 (1 + 100, 2 + 99, 3 + 98, etc). There are exactly 50 such pairs (100/2), so the sum must be 10150. Making a formula, this makes (X+1)(X/2) which is the same as ((X+1)*X)/2, which brings us back into familiar territory.
Thanks for an interesting article, and for reassurance that the math actually works.
now … how to invert a parabolic function … heads back to google

this is amazing now i feel like einstien

Hi- love this page, very helpful, but I’m stuck trying to figure out how to work out a formula that works out the sum of all the numbers up to that one (can’t explain it properly)…
1…1 (sum=1)
2…3 (sum=3+1=4)
3…5 (sum=5+3+1=10)
4…10 (sum=10+5+3+1=20)
5…15 (sum=35)
6…21 (sum=56)

so when n=6 the answer is 56, how do you work out a formula for when n=12 or 112?
Help please, I’m going stir-crazy!

Just cheated and worked it out with spreadsheet:
(n^3)/6+(n^2)/2+n/3
Would still like to know how to get to this equation without cheating though…

Thank you very much! I will be using this story in an introductory class to programming, and the 4 listed techniques will really help in explaining the solution.

Cheers

Thank you thank you thank you! I’ve heard the story you opened with before, but never knew the answer… I’m soooo glad I stumbled upon your explanation. My life is forever improved!

@Mel: Awesome, glad it helped!

That did not help at allllll. =(

Here’s a formula I came up with to sum a series of evenly spaced values. You do not need to know the number of values in the set.

a = the first digit in the set
b = the last digit in the set
x = difference between two consecutive numbers

sum = [a^2 + ax + b^2 + bx] / 2x

If counting by ones…

sum = n(n + 1)/2

If counting by twos…

sum = n(n/2 + 1)/2

If counting by threes…

sum = n(n/3 + 1)/2

oops, I meant to write above:
sum = [a^2 + ax - b^2 + bx] / 2x

I don’t know if this is the same thing, but…

I just found half of x, added .5 to it, and multiplied x with (one half of x + .5)

Haha. Oh, well.

[…] price of it’s day of the year. I wasn’t to excited about that until I calculated (using Gauss’s method) how much money he’d be earning for the year: […]

is there a formula to add numbers like 1-100 but starting from lets say 40-100?

@sascha: Great question! Actually one way to do this is to add 1 to 100, and then subtract 1 to 39 :). You’ll be left with 40-100. Another way is to start writing the numbers like this:

40 41 42 43…
100 99 98 …

And use the techniques above. Note that 40 to 100 is actually 61 numbers, just like 40 to 41 is 2 numbers. So it’d be 61 * (40 + 100) / 2.

I revising for my Grade 5 maths paper and i really didi not understand the concept and your explanation really helped. Thank you sooo much!!!

@Shash: Awesome, glad it helped!

[…] So I set up some golf balls hoping it would shed some light on a time efficient way to figure out the area without wasting much time. For example, there are 37 golf balls in the last row and it is an equilateral triangle, so there are 37 rows. It would be so annoying to count 1+2+3+4 etc… But By taking 37rows(37number of balls in the last row +1)/2 gives you your answer. It does not matter what the last number is it will always work. It is explained in better detail here. […]