def fact(z):
if z == 1:
return 1
return z*fact(z-1)
while True:`
z = int(input("Enter a number"))
if z == 0:
break
print(fact(z))
Enter a number3
6
Enter a number4
24
Enter a number5
120
Enter a number
另一种方法
result = 1
for i in range(1,3):
result *= i
print(result)