Skip to content

Instantly share code, notes, and snippets.

@seabre
Created April 17, 2016 04:13
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 seabre/39e55778cd6250c6633fba0ebaac3358 to your computer and use it in GitHub Desktop.
Save seabre/39e55778cd6250c6633fba0ebaac3358 to your computer and use it in GitHub Desktop.
var yourself = {
fibonacci_lookup : {0: 0, 1: 1},
fibonacci : function(n) {
if (this.fibonacci_lookup[n] !== undefined) {
return this.fibonacci_lookup[n];
}
else {
var result = this.fibonacci(n - 1) +
this.fibonacci(n - 2);
this.fibonacci_lookup[n] = result;
return result;
}
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment