File tree Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Original file line number Diff line number Diff line change @@ -44,15 +44,16 @@ def pi(precision: int) -> str:
44
44
getcontext ().prec = precision
45
45
num_iterations = ceil (precision / 14 )
46
46
constant_term = 426880 * Decimal (10005 ).sqrt ()
47
- multinomial_term = 1
48
47
exponential_term = 1
49
48
linear_term = 13591409
50
49
partial_sum = Decimal (linear_term )
51
50
for k in range (1 , num_iterations ):
52
- multinomial_term = factorial (6 * k ) // (factorial (3 * k ) * factorial (k ) ** 3 )
51
+ multinomial_term = factorial (
52
+ 6 * k ) // (factorial (3 * k ) * factorial (k ) ** 3 )
53
53
linear_term += 545140134
54
54
exponential_term *= - 262537412640768000
55
- partial_sum += Decimal (multinomial_term * linear_term ) / exponential_term
55
+ partial_sum += Decimal (multinomial_term *
56
+ linear_term ) / exponential_term
56
57
return str (constant_term / partial_sum )[:- 1 ]
57
58
58
59
You can’t perform that action at this time.
0 commit comments