Skip to content

Instantly share code, notes, and snippets.

@CodeDrome
Created July 28, 2020 15:22
Show Gist options
  • Save CodeDrome/bd86b5acea52f3fda0f02e8035094e13 to your computer and use it in GitHub Desktop.
Save CodeDrome/bd86b5acea52f3fda0f02e8035094e13 to your computer and use it in GitHub Desktop.
estimatingpi.py part 4
def john_wallis():
"""
Infinite product created by English mathematician John Wallis in 1655
"""
print("John Wallis\n===========")
iterations = 1000000
numerator = 2.0
denominator = 1.0
pi = 1.0
for i in range(1, iterations + 1):
pi*= (numerator / denominator)
if (i%2) == 1:
denominator+= 2.0
else:
numerator+= 2.0
pi*= 2.0
print_as_text(pi)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment