Skip to content

Instantly share code, notes, and snippets.

@ibrahim-kardi
Created August 10, 2017 18:21
Show Gist options
  • Save ibrahim-kardi/fad0110c479c08d77a67f7d62244b36e to your computer and use it in GitHub Desktop.
Save ibrahim-kardi/fad0110c479c08d77a67f7d62244b36e to your computer and use it in GitHub Desktop.
null created by ikardi420 - https://repl.it/KFM2/1
def fafib(n,memo={}):
"""Assumes n is an int>=0,memo used only by recursive calls Return Fibonacci of n"""
if n == 0 or n == 1:
return 1
try:
return memo[n]
except KeyError:
result= fafib(n-1,memo)+fafib(n-2,memo)
memo[n]=result
return result
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment