Created
May 14, 2015 01:58
-
-
Save jshcrowthe/cda7b0c7628d42786645 to your computer and use it in GitHub Desktop.
Fibonacci Sequence (The cool way)
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
var fibonacci = function(n) { | |
return Array.apply(null, Array(n)) | |
.reduce(function(sequence, value, index) { | |
return sequence.concat((index < 2) ? index : sequence[index - 1] + sequence[index - 2]); | |
}, []); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment