Created
July 15, 2016 19:34
-
-
Save pmalek/05a9ed4985b017f9cce8b778662c705a to your computer and use it in GitHub Desktop.
fibonacci tail recursion
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
int fib(int term, int val = 1, int prev = 0) | |
{ | |
if(term == 0) return prev; | |
if(term == 1) return val; | |
return fib(term - 1, val+prev, val); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment