Using an infinite series shown by Euler, π can be approximated.

The series goes as follows:

By rearranging the equation, you get the following:

```
# Python 2.7.7 Code
# Jonathan Frech 14th of December, 2015
```

```
# using Euler's formular: (pi**2)/6 = 1/1**2 + 1/2**2 + 1/3**2 + ... to calculate pi
sum = 0
s = 1
while True:
sum += 1. / (s**2)
pi = (sum * 6)**.5
s += 1
print "pi approx. " + str(pi)
```

Advertisements