Created
August 14, 2013 22:40
-
-
Save ericrius1/6236399 to your computer and use it in GitHub Desktop.
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
var fib = (function(){ | |
var cache = [0, 1, 1]; | |
return function(n){ | |
if(cache[n] === undefined){ | |
cache[n] = fib(n-1) + fib(n-2); | |
} | |
return cache[n]; | |
} | |
})() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment