Using this following formula write a program which calculates pi:
pi = 2(2/1 * 2/3 * 4/3 * 4/5 * 6/5 * 6/7 * 8/7 * 8/9...)
For this program it will be best to use a type of variable called 'double'. This is like a 'real' but can store more decimal places. It may also be useful to make the loop counter of type 'longInt'.
Here is our answer: Finding Pi
Other formulas are:
pi = 4(1 - 1/3 + 1/5 - 1/7 + 1/9 - 1/11...)
Note this formula is nearly as bad as the first one at taking a large number of loops.
pi = 16(1/5 - 1/3(1/5)^3 + 1/5(1/5)^5 - 1/7(1/5)^7 + ...) - 4(1/239 - 1/3(1/239)^3 + 1/5(1/239)^5 - 1/7(1/239)^7 + ...)
This formula (although more complex) gives pi much faster.
Try using these formulas to find pi.
Find the golden ratio to as many decimal places as you can using this result.