Skip to content

Instantly share code, notes, and snippets.

@cem2ran
Created May 6, 2015 16:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cem2ran/e82099d700baa1e86044 to your computer and use it in GitHub Desktop.
Save cem2ran/e82099d700baa1e86044 to your computer and use it in GitHub Desktop.
Fibonacci generator
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