the-honk/languages/python/calculators/pi.py

13 lines
184 B
Python
Raw Normal View History

2024-10-09 17:02:45 +00:00
import math
pi = 0
for k in range(20):
numerator = (2 ** k) * (math.factorial(k) ** 2)
denominator = math.factorial((2 * k) + 1)
pi += numerator / denominator
pi *= 2
print(pi)