Skip to content

Instantly share code, notes, and snippets.

@areski
Last active December 12, 2015 05:28
Show Gist options
  • Save areski/4722239 to your computer and use it in GitHub Desktop.
Save areski/4722239 to your computer and use it in GitHub Desktop.
make_pi
#
# Display PI Number
#
def make_pi():
q, r, t, k, m, x = 1, 0, 1, 1, 3, 3
for j in range(10000):
if 4 * q + r - t < m * t:
yield m
q, r, t, k, m, x = 10*q, 10*(r-m*t), t, k, (10*(3*q+r))//t - 10*m, x
else:
q, r, t, k, m, x = q*k, (2*q+r)*x, t*x, k+1, (q*(7*k+2)+r*x)//(t*x), x+2
digits = make_pi()
pi_list = []
my_array = []
for i in make_pi():
my_array.append(str(i))
my_array = my_array[:1] + ['.'] + my_array[1:]
big_string = "".join(my_array)
print big_string
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment