Created
April 12, 2020 21:00
-
-
Save lucianmarin/78e6df72638cda10a8f999b06553928a to your computer and use it in GitHub Desktop.
Calculate pi
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
# pip install progressbar2 | |
from progressbar import progressbar | |
def wallis(n): | |
pi = 2. | |
for i in progressbar(range(1, n)): | |
left = (2. * i) / (2. * i - 1.) | |
right = (2. * i) / (2. * i + 1.) | |
pi = pi * left * right | |
return pi | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment