Last active
March 11, 2022 19:09
-
-
Save iamricks/675005d2fec8c8544f1553c821d9389c to your computer and use it in GitHub Desktop.
Fast Fib
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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