Skip to content

Instantly share code, notes, and snippets.

@iamricks
Last active March 11, 2022 19:09
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 iamricks/675005d2fec8c8544f1553c821d9389c to your computer and use it in GitHub Desktop.
Save iamricks/675005d2fec8c8544f1553c821d9389c to your computer and use it in GitHub Desktop.
Fast Fib
seen = {}
def fib(n) -> int:
if n <= 2:
return 1
if n not in seen:
seen[n] = fib(n - 1) + fib(n - 2)
return seen[n]
num = int(input("Enter your fib number: "))
print(fib(num))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment