Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from decimal import Decimal, getcontext
- precision = int(input('Enter the precision: ')) + 1
- if not (precision - 1):
- pi = 3
- else:
- getcontext().prec = precision
- pi = sum([(1/Decimal(16)**k * (Decimal(4)/(8*k+1) - Decimal(2)/(8*k+4) - Decimal(1)/(8*k+5) - Decimal(1)/(8*k+6))) for k in range(precision)])
- print(pi)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement