Let's write the first few terms in a table to get a better sense for what's happening:
i | Equation | Approximation |
1 | + 4/1 | 4 |
2 | + 4/1 - 4/3 | ~2.666 |
3 | + 4/1 - 4/3 + 4/5 | ~3.466 |
4 | + 4/1 - 4/3 + 4/5 - 4/7 | ~2.895 |
5 | + 4/1 - 4/3 + 4/5 - 4/7 + 4/9 | ~3.339 |
6 | + 4/1 - 4/3 + 4/5 - 4/7 + 4/9 - 4/11 | ~2.976 |
Okay. Two things stand out:
1
or -1
... or maybe multiplying each term by -1 * (loop + 1)
?i
goes up by 1, the fraction's denominator increases by 2. How can we turn 1 --> 1
, 2 --> 3
, 3 --> 5
, etc.?