Created
May 6, 2015 16:59
-
-
Save cem2ran/e82099d700baa1e86044 to your computer and use it in GitHub Desktop.
Fibonacci generator
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() { | |
let a = 0, b = 1; | |
while(a < Infinity) { | |
yield a; | |
[a, b] = [b, a + b]; | |
} | |
} | |
for(let value of fibonacci()) { | |
console.log(value); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment