python求整数n阶乘 python语音写函数计算1到100的阶乘之和?

python语音写函数计算1到100的阶乘之和?def factorial(n):if nreturn 1else:return n*factorial(n-1)therange=range(110

python语音写函数计算1到100的阶乘之和?

def factorial(n):

if n

return 1

else:

return n*factorial(n-1)

therange=range(1100)

thelist=[factorial(a)for a in therange

]sum=reduce(lambda x,y:x y,[list

]print sum

factorial函数:improve numpprintnumpy.数学.阶乘(3) Python自己的标准库还具有阶乘函数import mathprint数学.阶乘(3)

python没有自己算阶乘的函数吗?

阶乘函数:Improtnumpyprintnumpy.math.factorial函数(3) Python自己的标准库也有阶乘函数importmathprintmath.阶乘(3)