Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # b_pi.py
- def pi(places=20000):
- "Computes pi to given number of decimal places"
- extra = 8
- one = 10 ** (places+extra)
- t, c, n, na, d, da, i = 3*one, 3*one, 1, 0, 0, 24, 0
- while 1:
- n, na, d, da = n+na, na+8, d+da, da+32
- t = t * n // d
- c += t
- s = str(c // (10 ** extra))
- try:
- print s[i],
- except:
- break
- i += 1
- pi()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement