Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from decimal import localcontext, Decimal
- def pi(K, prec=100):
- """
- https://www.davidhbailey.com//
- """
- with localcontext() as ctx:
- ctx.prec = prec
- return sum(
- (Decimal(1) / Decimal(16 ** k)) * (
- +(Decimal(4) / (Decimal(8 * k) + Decimal(1)))
- -(Decimal(2) / (Decimal(8 * k) + Decimal(4)))
- -(Decimal(1) / (Decimal(8 * k) + Decimal(5)))
- -(Decimal(1) / (Decimal(8 * k) + Decimal(6)))
- )
- for k in range(K)
- )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement