Last active
December 28, 2023 06:44
-
-
Save SafaSafari/a43a5065d434335f029b9f501b15d4df to your computer and use it in GitHub Desktop.
pi using machin's formula
This file contains 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 S(a,b): | |
c=a*a+1;d=(a*b)//c;e=d;f=2 | |
while d:g=(f+1)*c;d*=f;d=d//g;e+=d;f+=2 | |
return e | |
def l(d):u=10**(d+10);p=4*(4*S(5,u)-S(239,u));return p//10**10 | |
a=lambda v:print(str(v).rjust(min(c,m),'0'),end='') | |
m,c=170000,4299 | |
p=l(m) | |
while m>c:m-=c;a(p//10**m);p%=10**m | |
a(p) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment