Skip to content

Instantly share code, notes, and snippets.

@wiesson
Created December 4, 2018 14:08
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 wiesson/a2bdd3e3861e8eb841b558da82a5e778 to your computer and use it in GitHub Desktop.
Save wiesson/a2bdd3e3861e8eb841b558da82a5e778 to your computer and use it in GitHub Desktop.
function *fibonacci(n: number, current: number = 0, next: number = 1) {
if (n === 0) {
return current;
}
yield current;
yield *fibonacci(n-1, next, current + next);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment