Created
September 6, 2022 09:18
-
-
Save EvilFreelancer/46efb31f6913fe075556e3b358f49595 to your computer and use it in GitHub Desktop.
Fibonacci Sequence In JavaScript
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
| const max = process.argv.slice(2); | |
| const fibonacci = n => { | |
| let a = 0, b = 1, c = n; | |
| console.log(a); | |
| console.log(b); | |
| for(let i = 2; i <= n; i++) { | |
| c = a + b; | |
| console.log(c); | |
| a = b; | |
| b = c; | |
| } | |
| return c; | |
| }; | |
| fibonacci(max); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment