def Factorial(n):
result = 1
for i in range(1,n):
result = result * (result+1)
print(result)
Factorial(5)
前5个数字的结果是:
1 - > 1
2 - > 2
3 - > 6
4 - > 42
5 - > 1806
我的功能有什么不正确?
答案 0 :(得分:1)
def Factorial(n):
result = 1
for i in range(1,n):
result = result * (i+1)
print(result)
替换
result = result * (result+1)
与
result = result * (i + 1)