Skip to content

Instantly share code, notes, and snippets.

@oliverbth05
Created August 22, 2018 13:19
Show Gist options
  • Save oliverbth05/3889afbf8c33e81c515534548a482bca to your computer and use it in GitHub Desktop.
Save oliverbth05/3889afbf8c33e81c515534548a482bca to your computer and use it in GitHub Desktop.
Javascript Fibonacci Sequence
function generateFibonacci(length){
let sequence = [1];
for(var i = 1; i <= length; i++){
if (sequence.length === 1) {
sequence[i] = 1
}
else{
sequence[i] = sequence[i-1] + sequence[i - 2]
}
}
return sequence
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment