Skip to content

Instantly share code, notes, and snippets.

@agutoli
Last active August 26, 2019 12:42
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 agutoli/76533c974cd2b4e633ce2cedde7e1b98 to your computer and use it in GitHub Desktop.
Save agutoli/76533c974cd2b4e633ce2cedde7e1b98 to your computer and use it in GitHub Desktop.
Max sequence of Fibonacci numbers.
/**
* Bruno Agutoli
*/
function fib(curr=0, prev) {
this.seq = this.seq || [];
let n = curr + prev;
if (n) {
n = curr + prev;
} else {
n = 1;
}
if (n === Infinity) {
return this.seq;
}
this.seq.push(n);
return fib.call(this, n, curr);
}
//
// should return a list of 1476 fibonacci numbers ex. [1,1,2,3...1.3069892237633987e+308];
console.log(JSON.stringify(fib(), null));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment