Created
December 15, 2015 17:15
-
-
Save bendc/b91fd1e31c171c9626c1 to your computer and use it in GitHub Desktop.
Fibonacci Series
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
const fib = (n, seq = [0, 1]) => | |
n - 2 ? fib(n - 1, [...seq, seq.slice(-2).reduce((a, b) => a + b)]) : seq; | |
fib(10); // 0, 1, 1, 2, 3, 5, 8, 13, 21, 34 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment