Skip to content

Instantly share code, notes, and snippets.

@dhigginbotham
Last active August 29, 2015 14:20
Show Gist options
  • Save dhigginbotham/d8f7b87a1cd67612b203 to your computer and use it in GitHub Desktop.
Save dhigginbotham/d8f7b87a1cd67612b203 to your computer and use it in GitHub Desktop.
var fib = function(n,arr) {
if (!arr) { arr = [1,1]; n=n-2; };
if (n==-1) return [arr[0]];
if (n==0) return arr;
arr.push(arr[arr.length-1] + arr[arr.length-2]);
return fib(n-1,arr);
};
fib(10);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment