mirror of
https://github.com/TheAlgorithms/Python.git
synced 2024-11-28 07:21:07 +00:00
15 lines
264 B
Python
15 lines
264 B
Python
def fact(n):
|
|
"""
|
|
Return 1, if n is 1 or below,
|
|
otherwise, return n * fact(n-1).
|
|
"""
|
|
return 1 if n <= 1 else n * fact(n - 1)
|
|
|
|
|
|
"""
|
|
Show factorial for i,
|
|
where i ranges from 1 to 20.
|
|
"""
|
|
for i in range(1, 21):
|
|
print(i, ": ", fact(i), sep="")
|