Skip to content

Instantly share code, notes, and snippets.

@rinchik
Last active January 28, 2017 19:16
Show Gist options
  • Save rinchik/ac6a946b5dff339089f8047383f1f442 to your computer and use it in GitHub Desktop.
Save rinchik/ac6a946b5dff339089f8047383f1f442 to your computer and use it in GitHub Desktop.
FibonacciHashLookup.js
function fibonacci(number) {
var sequence = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89];
var numberZeroBased = number - 1;
if (numberZeroBased > sequence.length)
throw new Error('The number you provided is outside of the range');
return sequence[numberZeroBased];
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment