Created
October 25, 2015 16:31
-
-
Save jimbojetset/c13c973e9e8108f2bcfd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def make_pi(l): | |
q, r, t, k, m, x, j = 1, 0, 1, 1, 3, 3, 0 | |
while j < l + 2: | |
if 4 * q + r - t < m * t: | |
yield m | |
j += 1 | |
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 | |
my_array = [] | |
places = 100 | |
for i in make_pi(places): | |
my_array.append(str(i)) | |
print "".join(my_array[:1] + ['.'] + my_array |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment