Project 6 Extension (sum of finite arithmetic series): Carl Gauss was a famous mathematician born in the late 1700s. The story is told that when he was a young child (around third grade), his teacher posed the problem to find the sum of the first 100 integers (as some sort of punishment) but Gauss noticed a pattern and was able to solve this problem much easier than intended. There is still debate on whether the story is true, but let’s take a look at one of our examples and investigate the pattern.
arithmeticSeries(5.0, 2.0, 6) returns 60.0
The corresponding series would be calculated as follows:
5.0 + 7.0 + 9.0 + 11.0 + 13.0 + 15.0
The pattern:
When we add the first term in the sequence with the last term, we get 20 (5.0 + 15.0).
When we add the second term in the sequence with the second to last term, we get 20 (7.0 + 13.0)
When we add the third term in the sequence with the third to last term, we get 20 (9.0 + 11.0)
There are three pairs of numbers all with the same sum of 20. Therefore, the series would be equal to 60.
Gauss Example
1 + 2 + 3 + 4 + ….. 96 + 97 + 98 + 99 + 100
There would be 50 pairs each with a sum of 101. Therefore, the sum of the first 100 integers is 5,050.