Finding Pi

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

However: Although this is the simplist formula this takes a large number of loops to find pi to many decimal places.

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.

The Fibonacci Sequence (1,1,2,3,4,8,13,21...) in which:
t(n) = t(n-1) + t(n-2)
can be used to find the golden ratio (1.618033989...):
Golden ratio = t(n)/t(n-1)

Find the golden ratio to as many decimal places as you can using this result.