Created
April 6, 2015 20:16
-
-
Save daniel-williams/6b679350ab7abaef78a4 to your computer and use it in GitHub Desktop.
Fibonacci using recursive JavaScript
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
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