Skip to content

Instantly share code, notes, and snippets.

@waaronking
Forked from jshcrowthe/fibonacci.js
Created October 15, 2015 17:43
Show Gist options
  • Save waaronking/30882993f61e6f1e52f5 to your computer and use it in GitHub Desktop.
Save waaronking/30882993f61e6f1e52f5 to your computer and use it in GitHub Desktop.
Fibonacci Sequence (The cool way)
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