Skip to content

Instantly share code, notes, and snippets.

@pbondoer
Created November 28, 2014 09:55
Show Gist options
  • Save pbondoer/e450e602733f29baa44b to your computer and use it in GitHub Desktop.
Save pbondoer/e450e602733f29baa44b to your computer and use it in GitHub Desktop.
import time
from math import sqrt
#START
n = int(input("Nombre d'itérations?"))
m = input("Méthode (l/e)?")
start_time = time.time()
if(m.lower() == "l"):
x = -3
pi = 1
for i in range(0, n):
pi += 1/x
x *= -1
if(x < 0):
x -= 2
else:
x += 2
print(pi * 4)
else:
x = 1
pi = 1
for i in range(0, n):
x += 1
pi += 1/(x**2)
print(sqrt(pi * 6))
print("--- %s seconds ---" % (time.time() - start_time))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment