Ya, there's (Python) code for that: def pi():
N = 0
n, d = 0, 1
while True:
xn = (120*N**2 + 151*N + 47)
xd = (512*N**4) + 1024*N**3 +
712*N**2 + 194*N + 15)
n = ((16 * n * xd) + (xn * d)) % (d * xd)
d *= xd
yield 16 * n // d
N += 1
N = 0
n, d = 0, 1
while True:
xn = (120*N**2 + 151*N + 47)
xd = (512*N**4) + 1024*N**3 +
712*N**2 + 194*N + 15)
n = ((16 * n * xd) + (xn * d)) % (d * xd)
d *= xd
yield 16 * n // d
N += 1
No comments:
Post a Comment