Skip to content

Instantly share code, notes, and snippets.

@lidio601
Created May 13, 2019 00:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lidio601/575741048222fddf08fbdaeaf5910811 to your computer and use it in GitHub Desktop.
Save lidio601/575741048222fddf08fbdaeaf5910811 to your computer and use it in GitHub Desktop.
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