Created
May 14, 2019 10:41
-
-
Save 73nko/fa2c7c4fe896ef7deb97308979b4f5d2 to your computer and use it in GitHub Desktop.
Create a infinite fibbonachi list.
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() { | |
let a = 1, b = 0; | |
for (; ;) { | |
[a, b] = [b, a + b]; | |
yield b; | |
} | |
} | |
const f = fib(); | |
for (let i = 0; i < 6; i++) | |
console.info(f.next().value) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment