MCPcopy Create free account
hub / github.com/leaningtech/webvm / factorial

Function factorial

examples/python3/factorial.py:1–5  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1def factorial():
2 f, n = 1, 1
3 while True: # First iteration:
4 yield f # yield 1 to start with and then
5 f, n = f * n, n+1 # f will now be 1, and n will be 2, ...
6
7for index, factorial_number in zip(range(51), factorial()):
8 print('{i:3}!= {f:65}'.format(i=index, f=factorial_number))

Callers 1

factorial.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected