Last active
December 26, 2015 05:09
-
-
Save camilleriluke/7098433 to your computer and use it in GitHub Desktop.
Fibonacci Sequence using JavaScript Arrays
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(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