Skip to content

Instantly share code, notes, and snippets.

@Allwin12
Created June 20, 2020 16:57
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 Allwin12/d3a74e14243a4da858b405122b298a8a to your computer and use it in GitHub Desktop.
Save Allwin12/d3a74e14243a4da858b405122b298a8a to your computer and use it in GitHub Desktop.
from functools import lru_cache
@lru_cache(maxsize=1000)
def fibonacci(n):
if n == 1:
return 1
if n == 2:
return 1
elif n > 2:
return fibonacci(n - 1) + fibonacci(n - 2)
for i in range(1, 1001):
print(i, ':', fibonacci(i))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment