Skip to content

Commit 8f3fc63

Browse files
authored
Merge pull request #90 from abhitrueprogrammer/patch-2
Update pi.py
2 parents 9eba623 + a0298d3 commit 8f3fc63

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

‎code/pi.py‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,14 @@ def estimate_pi():
3636
while True:
3737
num = factorial(4*k) * (1103 + 26390*k)
3838
den = factorial(k)**4 * 396**(4*k)
39-
term = factor * num / den
40-
total += term
39+
40+
total += num / den
41+
term = factor * num/den
4142

4243
if abs(term) < 1e-15:
4344
break
4445
k += 1
45-
46-
return 1 / total
46+
47+
return 1 / (factor * total)
4748

4849
print(estimate_pi())

0 commit comments

Comments
 (0)