Skip to content

Instantly share code, notes, and snippets.

@kwyn
Last active August 29, 2015 13:58
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 kwyn/9959862 to your computer and use it in GitHub Desktop.
Save kwyn/9959862 to your computer and use it in GitHub Desktop.
var fibonacci = function(n, output) {
var a = 1, b = 1, sum;
for (var i = 0; i < n; i++) {
output.push(a);
sum = a + b;
a = b;
b = sum;
}
};
var result = [];
fibonacci(4,result);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment