Факторная рекурсия Python
def fact_rec(n):
if n < 0:
return
elif n <= 1:
return 1
else:
return n*fact_rec(n-1)
answer = fact_rec(4)
if answer == None:
print("Cannot calculate factorial of a negative value")
else:
print(answer) # 24 = 4x3x2x1 = 4!
Wissam