Little Gauss formula for the HP15C
Description
The sum of integers up to n are calculated.
I adapted a 9 step program by Torsten Manz to produce a new 7 step program. The 9 step program used the original formula found by Carl Friedrich Gauss:
n n(n + 1)
∑ k = ——————————
k=1 2
This version uses the rearranged sum (n^{2} + n)/2.
g LSTx recovers n after g x².
1. Enter the number n to compute the sum of integers from 1 to n.
2. Press GSB A to run.
Example:
n = 100, (n^{2} + n)/2 = 5050.
n= 1000, (n^{2} + n)/2 = 500500.
Note that the sum is the midpoint (average) x n.
For the even number sum 1 to 10, the midpoint (average) is 5.5. The sum is 5.5 x 10 = 55.
Looking at your open hands there are usually 10 fingers  assume they represent the integers 1 to 10.
Starting to count at one thumb and ending with 10 at the other thumb, the midpoint (average) is between the little fingers, i.e at 5.5.
For the odd number sum 1 to 9, the midpoint (average) is 5. The sum is 5 x 9 = 45.
For 1 to 100 you can just average 1 and 100 or 50 and 51 = 50.5. The sum is 50.5 x 100 = 5050.
For 1 to 99 the average is 50. The sum is 50 x 99 = 4950.
Sum from m to n
The generalised formula for the sum of integers from m to n is ∑x = (n(n + 1)  m(m  1) / 2.
Setting m to zero leaves the original Little Gauss formula.
Summing from 10 to 20 includes the eleven integers from 10 to 20.
The sum is 165.
An alternative version of the formula is ∑x = (n(n + 1)  (m(m + 1))/2 + m.
Again setting m to zero gives the original Little Gauss formula.
To fully understand this look up "fencepost error" or "off by one error".
Run the Little Gauss program, for n = 20 and for m = 10.
Subtract the results to give a difference of 155.
Add m = 10, as in the alternative formula above, to give a correct result of 165.
Program Resources
Labels
Name 
Description 

A 
Little Gauss formula 

Program
Line 
Display 
Key Sequence 

000 



001 
42,21,11 
f LBL A 

002 
43 11 
g x² 

003 
43 36 
g LSTΧ 

004 
40 
+ 

005 
2 
2 

006 
10 
÷ 

007 
43 32 
g RTN 
