Skip to content

Instantly share code, notes, and snippets.

@mlhaufe
Last active December 15, 2015 01:59
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 mlhaufe/5183570 to your computer and use it in GitHub Desktop.
Save mlhaufe/5183570 to your computer and use it in GitHub Desktop.
function trampoline(f) {
while (typeof f === "function") f = f();
return f;
}
function fib(n){
function f(n0,n1,step){
return step == n ? n1 : function() { return f(n1, n0 + n1, step +1) }
}
return trampoline(f(0,1,1))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment