Last active
January 28, 2017 19:16
-
-
Save rinchik/ac6a946b5dff339089f8047383f1f442 to your computer and use it in GitHub Desktop.
FibonacciHashLookup.js
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 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