Skip to content

Instantly share code, notes, and snippets.

@dboyliao
Last active December 9, 2016 00:13
Show Gist options
  • Save dboyliao/e73c3dae092d109d3f996e2348d3a6fe to your computer and use it in GitHub Desktop.
Save dboyliao/e73c3dae092d109d3f996e2348d3a6fe to your computer and use it in GitHub Desktop.
def fib(n):
if n < 2:
return 1
return fib(n-1) + fib(n-2)
def tail_fib(n, a=1, b=1):
if n < 2:
return b
return tail_fib(n-1, b, a+b)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment