Created
July 28, 2020 15:22
-
-
Save CodeDrome/bd86b5acea52f3fda0f02e8035094e13 to your computer and use it in GitHub Desktop.
estimatingpi.py part 4
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
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