Last active
August 26, 2019 12:42
-
-
Save agutoli/76533c974cd2b4e633ce2cedde7e1b98 to your computer and use it in GitHub Desktop.
Max sequence of Fibonacci numbers.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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