Commit 906df5c5 authored by Michael Krause's avatar Michael Krause 🎉
Browse files

Add pi approximation

parent 0a2898ef
......@@ -2,3 +2,12 @@ def fibonacci(n):
if n==0 or n==1:
return n
return fibonacci(n-1) + fibonacci(n-2)
def pi(n):
"""return approximation of pi by Leibniz' series with n elements"""
j = 1
pi = 0
for i in range(1,n+1):
pi -= (-1)**(i) * 4/j
j += 2
return pii
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment