Created
May 20, 2023 10:30
-
-
Save yoniLavi/ee361e5e98c410ca299ad16351a78182 to your computer and use it in GitHub Desktop.
Fibonacci number generator in JS
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
| function* fib(upTo) { | |
| let a = b = 1; | |
| while (a < upTo) { | |
| yield a; | |
| [a, b] = [b, a + b]; | |
| } | |
| } | |
| console.log(...fib(1e10)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment