-
-
Save jecsham/b0ef802e0c051def6e62a66ced17abd6 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
class Fibonacci { | |
/** | |
* @param {number} value | |
* @returns {number} | |
*/ | |
sequence (value) { | |
return (value < 2) ? value : this.sequence(value - 1) + this.sequence(value - 2) | |
} | |
/** | |
* @param {number} times | |
* @returns {Array<number>} | |
*/ | |
run (times) { | |
return [ ...Array(times).keys() ].map(key => this.sequence(key)) | |
} | |
} | |
console.log(new Fibonacci().run(50)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment