Created
December 16, 2013 04:29
-
-
Save christopherhill/7982344 to your computer and use it in GitHub Desktop.
Fibonacci Generator
This file contains hidden or 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 fibonacci = function(arrLength) { | |
| var offset = 1; | |
| var result = [0, 1]; | |
| for (var i = offset; i < arrLength + offset; i++) { | |
| result.push(result[i] + result[i-1]); | |
| } | |
| return result; | |
| } | |
| console.log(fibonacci(15)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment