Last active
February 2, 2023 23:25
-
-
Save juliusgeo/1da759d07af0b447a78d0ccb14162c57 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
from functools import reduce as red; from math import \ | |
(factorial as fact, comb);import sys;from decimal import \ | |
(getcontext as c,Decimal as dc);(a:=range, | |
b:=int(sys. argv[1]));c\ | |
().prec=b; ber=lambda\ | |
e,f=[dc(1)]: [f.append( | |
1-sum(comb(h ,g)*f[g]/(h | |
- g + 1) for g in a(h)))for | |
h in a(1, e + 1)] and abs( | |
f[-1]);print ((2 * fact(b) / | |
(ber(b)* 2** b * red(dc.__mul__ | |
, [1 - (1/dc (i) ** b) for i in | |
[2, 3, 5, 7] ]))) ** (1 / dc(b))) | |
#juliusgeo pi arb. precis. |
https://gist.github.com/juliusgeo/f4642c3a6835a2ea0676ef82a6fea1ac This is what I did before, it's basically the same implementation, but without all of the stuff to work with the whitespace changes.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Output:
It accepts one argument which is the number of digits of precision you want.