Skip to content

Instantly share code, notes, and snippets.

@camilleriluke
Last active December 26, 2015 05:09
Show Gist options
  • Save camilleriluke/7098433 to your computer and use it in GitHub Desktop.
Save camilleriluke/7098433 to your computer and use it in GitHub Desktop.
Fibonacci Sequence using JavaScript Arrays
function fibonacci(n) {
return Array.apply(0, new Array(n)).reduce(function(seq, current, index) {
return seq.concat((index < 2) ? index : seq[index-1] + seq[index-2]);
}, []);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment