Skip to content

Instantly share code, notes, and snippets.

@zorbash
Created November 9, 2015 14:11
Show Gist options
  • Select an option

  • Save zorbash/774928e671f5bee31d56 to your computer and use it in GitHub Desktop.

Select an option

Save zorbash/774928e671f5bee31d56 to your computer and use it in GitHub Desktop.
Fibonacci using JavaScript Generators
function* fib() {
var current = a = b = 1;
yield 1;
while (true) {
current = b;
yield current;
b = a + b;
a = current;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment