The number π can be approached by the series 4 × (1 − 1/3 + 1/5 − 1/7 + 1/9 − 1/11 + …): the more terms, the closer. Write SeriesPi, which prints exactly:
1 + 2 + ... + 9 = 45
With whole numbers: 4
4 terms: 2.8952380952380956
6 terms: 2.9760461760461765
8 terms: 3.017071817071818
The real value starts with 3.14159
Line 2 uses 1 / 3, 1 / 5, … with whole numbers; lines 3 to 5 use 1.0 / 3, 1.0 / 5, … Explain the 4 on line 2.