Little Gauss formula for the HP-15C

Description

The sum of integers up to n are calculated.

I adapted a 9 step subroutine by Torsten Manz to produce a new 7 step program. The 9 step subroutine used the original formula found by Carl Friedrich Gauss:

n n(n + 1)
k = ——————————
k=1 2

This version uses the rearranged sum (n2 + n)/2.

g LSTx recovers n after g .

1. Enter the number n to compute the sum of integers from 1 to n.
2. Press GSB A to run.

Example:
n = 100, (n2 + n)/2 = 5050.
n= 1000, (n2 + n)/2 = 500500.

Note that the sum is the mid-point (average) x n.
For the even number sum 1 to 10, the mid-point (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 mid-point (average) is between the little fingers, i.e at 5.5.
For the odd number sum 1 to 9, the mid-point (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.

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
003 43 36 g LSTx
004 40 +
005 2 2
006 10 ÷
007 43 32 g RTN