Skip to content

Instantly share code, notes, and snippets.

@saxbophone
Created November 26, 2015 14:56
Show Gist options
  • Save saxbophone/1dccc0f8b6deaedbebbb to your computer and use it in GitHub Desktop.
Save saxbophone/1dccc0f8b6deaedbebbb to your computer and use it in GitHub Desktop.
Fibonacci sequence generator in ES6
function* fibonacci(a=0, b=1) {
`This is a fibonacci sequence generator.`
yield a;
yield b;
let current = b;
let previous = a;
while (true) {
let next = previous + current;
previous = current;
current = next;
yield next;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment