Last active
December 22, 2015 00:48
-
-
Save rubik/6391350 to your computer and use it in GitHub Desktop.
Computing PI digit by digit. The input to the function is the number of decimal digits.
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
f=lambda w=4:(lambda j,o,i:(lambda s,g:list(i.takewhile(lambda _:len(o)<w+1, | |
(((4*g(0)+g(1)-g(2)<g(4)*g(2)and(o.append(int(g(4))),s(6,10*(g(1)-g(4)*g(2))), | |
s(4,((10*(3*g(0)+g(1)))//g(2))-10*g(4)),s(0,g(0)*10),s(1,g(6))))or(s(6,(2*g(0) | |
+g(1))*g(5)),s(7,(g(0)*(7*g(3))+2+(g(1)*g(5)))//(g(2)*g(5))),s(0,g(0)*g(3)), | |
s(2,g(2)*g(5)),s(5,g(5)+2),s(3,g(3)+1),s(4,g(7)),s(1,g(6))))for _ in iter(int,1) | |
)))and o)(lambda v,y:j.__setitem__(v,y),lambda v:j[v]))([1,0,1,1,3,3,-1,-1],[], | |
__import__('itertools')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Original code: