Skip to content

Instantly share code, notes, and snippets.

@josephjunker
Created November 5, 2015 23:39
Show Gist options
  • Save josephjunker/1d5117f197e2bdd90ca2 to your computer and use it in GitHub Desktop.
Save josephjunker/1d5117f197e2bdd90ca2 to your computer and use it in GitHub Desktop.
an even worse fibbonacci sequence generator
function fib(count) {
function f(list) { if(!count) return list; x(); count--; return f(list); }
function x() {
var list = f.arguments[0];
list.push((list[list.length - 1] || 1) + (list[list.length - 2] || 0));
}
if (count < 0) count = 0;
return f([]);
}
fib(5); // returns [ 1, 1, 2, 3, 5 ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment