Skip to content

Instantly share code, notes, and snippets.

@naush
Created July 14, 2010 15:20
Show Gist options
  • Save naush/475542 to your computer and use it in GitHub Desktop.
Save naush/475542 to your computer and use it in GitHub Desktop.
var fib = function(n) {
if (n <= 1) {
return n;
} else {
return fib_tail_recursive(n, 0, 1);
}
}
var fib_tail_recursive = function(n, a, b) {
if (n === 0) {
return a;
} else {
return fib_tail_recursive(n-1, b, a+b);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment