Python/maths/factorial_recursive.py
Vysor df04d94543 Some directories had a capital in their name [fixed]. Added a recursive factorial algorithm. (#763)
* Renaming directories
* Adding a recursive factorial algorithm
2019-04-22 22:53:56 +08:00

14 lines
243 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)
"""
Shown factorial for i,
where i ranges from 1 to 20.
"""
for i in range(1,21):
print(i, ": ", fact(i), sep='')