Created
February 4, 2020 20:16
-
-
Save adi518/c14898409f9a554d0819bf9d8dda2fea 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
function* fibonacci(limit = Infinity) { | |
let [prev, current] = [0, 1] | |
while (current < limit) { | |
;[prev, current] = [current, prev + current] | |
yield current | |
} | |
} | |
for (let i of fibonacci(30)) console.log(i) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment