Skip to content

Instantly share code, notes, and snippets.

@FerdinaKusumah
Last active December 16, 2019 01:38
Show Gist options
  • Save FerdinaKusumah/aa88bd4ff7e50d64d3ef268e0ebc666c to your computer and use it in GitHub Desktop.
Save FerdinaKusumah/aa88bd4ff7e50d64d3ef268e0ebc666c to your computer and use it in GitHub Desktop.
Fibonacci
def fibonacci(n: int):
""" Define function fibonacci with recursion"""
if n == 0:
return 0
elif n == 1:
return 1
return fibonacci(n-1) + fibonacci(n-2)
N = 35
fib = fibonacci(N)
print(timeit.timeit("fibonacci(N)", globals=globals(), number=1))
# Running for 7.011678666000001 seconds
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment