Skip to content

Instantly share code, notes, and snippets.

@pmalek
Created July 15, 2016 19:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pmalek/05a9ed4985b017f9cce8b778662c705a to your computer and use it in GitHub Desktop.
Save pmalek/05a9ed4985b017f9cce8b778662c705a to your computer and use it in GitHub Desktop.
fibonacci tail recursion
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