Created
December 4, 2018 14:08
-
-
Save wiesson/a2bdd3e3861e8eb841b558da82a5e778 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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