.
|
.
|
/*** Adding Up Sequences **********************************
Moe's math class is investigating adding up number sequences.
For example: 1/2 + 1/4 + 1/8 + ... = 1
They tried to find a formula for: 1/2 + 1/3 + 1/4 + ...
The teacher claimed that this sequence can grow infinitely big.
The following program will add up the sequence, stopping at 2.0
***********************************************************/
Mathematicians study sequences of numbers. A sequence is a list
of numbers that follows a pattern.
Common examples are Arithmetic Sequences (adding the
same number over and over)
1 , 3 , 5 , 7 , 9 (always adding 2)
Total = 5/2(1+9) = 25
and Geometric Sequences (multiplying by the same
number over and over).
1 , 2 , 4 , 8 , 16 , 32 (always
multiplying by 2)
Total = 2^6 - 1
Arithmetic and Geometric sequences are well understood by
mathematicians.
They have simple formulas for adding up a lot of terms of the sequence.
This program adds up a sequence that is neither arithmetic nor geometric. It adds up these fractions:
1/2 + 1/3 + 1/4 + 1/5 + 1/6 + 1/7 + 1/8 + 1/9
+ 1/10 + 1/11
Total = approximately 2.02, but there is no
exact formula