Skip to content

Instantly share code, notes, and snippets.

@vidul-nikolaev-petrov
Last active August 29, 2015 14:15
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 vidul-nikolaev-petrov/476cb032a114616db0a7 to your computer and use it in GitHub Desktop.
Save vidul-nikolaev-petrov/476cb032a114616db0a7 to your computer and use it in GitHub Desktop.
Fibonacci up to
function fibonacci(prev, next, stop) {
if (next >= stop) return prev;
try {
fibonacci.cache.push(prev);
}
catch (e) {
if (e.name === 'TypeError') {
fibonacci.cache = [];
}
}
return fibonacci(next, next + prev, stop);
}
function wrap_fibonacci(stop) {
wrap_fibonacci.result = fibonacci(0, 1, stop);
wrap_fibonacci.cache = fibonacci.cache;
}
//wrap_fibonacci(1000);
//console.log(wrap_fibonacci.result);
//console.log(wrap_fibonacci.cache);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment