python 实现函数的递归
kk=5
def factorial(n):
result = 1
for i in range(2, n+1):
result *= i
return result
print(factorial(kk))
def factorial(n):
if n == 1:
return 1
else:
return n * factorial(n - 1)
print(factorial(kk))
120
120