Last active
December 9, 2016 00:13
-
-
Save dboyliao/e73c3dae092d109d3f996e2348d3a6fe to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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