Skip to content

Instantly share code, notes, and snippets.

@lucianmarin
Created April 12, 2020 21:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lucianmarin/78e6df72638cda10a8f999b06553928a to your computer and use it in GitHub Desktop.
Save lucianmarin/78e6df72638cda10a8f999b06553928a to your computer and use it in GitHub Desktop.
Calculate pi
# 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