Created
July 28, 2020 15:41
-
-
Save CodeDrome/e919e6632fe43c7010f5d6a1e76af2c1 to your computer and use it in GitHub Desktop.
estimatingpi.py part 6
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 gregory_leibniz(): | |
""" | |
Co-discovered by James Gregory and Gottfried Wilhelm Leibniz | |
""" | |
print("Gregory-Leibniz\n===============") | |
iterations = 400000 | |
denominator = 1.0 | |
multiplier = 1.0 | |
pi = (4.0 / denominator) | |
for i in range(2, iterations + 1): | |
denominator += 2.0 | |
multiplier *= -1.0 | |
pi += ( (4.0 / denominator) * multiplier ) | |
print_as_text(pi) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment