webvm/examples/python3/pi.py
2022-01-31 22:00:49 +01:00

12 lines
254 B
Python

from decimal import Decimal, getcontext
getcontext().prec=60
summation = 0
for k in range(50):
summation = summation + 1/Decimal(16)**k * (
Decimal(4)/(8*k+1)
- Decimal(2)/(8*k+4)
- Decimal(1)/(8*k+5)
- Decimal(1)/(8*k+6)
)
print(summation)