Skip to content

Instantly share code, notes, and snippets.

@rishi93
Created March 17, 2016 05:03
Show Gist options
  • Save rishi93/bcfe1c964a0e6bfb50c8 to your computer and use it in GitHub Desktop.
Save rishi93/bcfe1c964a0e6bfb50c8 to your computer and use it in GitHub Desktop.
Digits of Pi
# Calculating Pi, William Shank's method using Machin's formula
def arctan(x):
result = 0
for i in range(1,11):
t = 2*i - 1
if (i % 2 == 0):
result = result - (x**t)/t
else:
result = result + (x**t)/t
return result
pie = 16*arctan(1/5) - 4*arctan(1/239)
print(pie)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment