Skip to content

Instantly share code, notes, and snippets.

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