Created
May 13, 2019 00:32
-
-
Save lidio601/575741048222fddf08fbdaeaf5910811 to your computer and use it in GitHub Desktop.
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) { | |
if (n < 1) return 0; | |
var a = [1, 1]; | |
var sum = 1; | |
while (n-- > 2) { | |
sum += a[0]; | |
a = a.slice(1).concat(sum); | |
} | |
return sum; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment