Skip to content

Instantly share code, notes, and snippets.

@daniel-williams
Created April 6, 2015 20:16
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 daniel-williams/6b679350ab7abaef78a4 to your computer and use it in GitHub Desktop.
Save daniel-williams/6b679350ab7abaef78a4 to your computer and use it in GitHub Desktop.
Fibonacci using recursive JavaScript
function fib(n,undefined){
if(fib.cache[n] === undefined)
fib.cache[n] = fib(n-1) + fib(n-2);
return fib.cache[n];
}
fib.cache = [0,1,1];
fib(10);
console.log(fib.cache);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment