Skip to content

Instantly share code, notes, and snippets.

@alksndrglk
Created October 25, 2022 06:57
Show Gist options
  • Save alksndrglk/4dc6b10c9f360d1d9d5c3b2b9cc5e66e to your computer and use it in GitHub Desktop.
Save alksndrglk/4dc6b10c9f360d1d9d5c3b2b9cc5e66e to your computer and use it in GitHub Desktop.
def factorial(k):
def gen(n):
if n == 1:
yield 1
else:
for u in gen(n - 1):
continue
yield u * n
return next(gen(k))
if __name__ == "__main__":
print(factorial(10))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment