Skip to content

Instantly share code, notes, and snippets.

@christopherhill
Created December 16, 2013 04:29
Show Gist options
  • Select an option

  • Save christopherhill/7982344 to your computer and use it in GitHub Desktop.

Select an option

Save christopherhill/7982344 to your computer and use it in GitHub Desktop.
Fibonacci Generator
var fibonacci = function(arrLength) {
var offset = 1;
var result = [0, 1];
for (var i = offset; i < arrLength + offset; i++) {
result.push(result[i] + result[i-1]);
}
return result;
}
console.log(fibonacci(15));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment