阶乘计算程序
具体数(如6)的阶乘
fact = 1
for f in [6,5,4,3,2,1]:
fact = fact * f
一般情形
n = input(" Enter a number: ")
fact = 1
for f in range(n,1,-1):
fact = fact * f
print "The factorial of ",n, "is",fact
答案: 你可以使用下面的Python代码来计算10的阶乘:def factorial(n): if n == 0: return 1 else: return n * factorial(n-1) print(factorial(10))