Skip to content

Instantly share code, notes, and snippets.

@wedburst
Last active October 23, 2020 18:14
Show Gist options
  • Select an option

  • Save wedburst/8cb3c7fee361120c4289c5fb6ef944b5 to your computer and use it in GitHub Desktop.

Select an option

Save wedburst/8cb3c7fee361120c4289c5fb6ef944b5 to your computer and use it in GitHub Desktop.
function fibonacciGenerator(n) {
var output = []
if (n === 1){
output = [0];
}
else if(n === 2){
output = [0, 1];
}
else{
output = [0, 1];
for (var i = 2; i < n; i++) {
output.push(output[output.length - 2] + output[output.length - 1]);
}
}
return output;
}
output = fibonacciGenerator(5);
console.log(output)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment