Skip to content

Instantly share code, notes, and snippets.

@nariaki3551
Last active December 8, 2016 08:04
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 nariaki3551/a22471f965c6d93b1c3f9c20e92b4d9a to your computer and use it in GitHub Desktop.
Save nariaki3551/a22471f965c6d93b1c3f9c20e92b4d9a to your computer and use it in GitHub Desktop.
from functools import lru_cache
@lru_cache(maxsize=None)
def fib(num):
if num == 1 or num == 2:
return 1
else:
return fib(num-1) + fib(num-2)
print(fib(int(input())))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment