Skip to content

Instantly share code, notes, and snippets.

@htsign
Created March 15, 2016 01:11
Show Gist options
  • Save htsign/cc6c732872bf3ac75018 to your computer and use it in GitHub Desktop.
Save htsign/cc6c732872bf3ac75018 to your computer and use it in GitHub Desktop.
"use strict";
for (let i of fib(10)) {
console.log(i);
}
function* fib(num) {
let [prev, curr] = [0, 1];
for (let i = 0; i < num; ++i) {
[prev, curr] = [curr, prev + curr];
yield curr;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment