提问:求1+2!+3!+...+20!的和
方法一:
sumValue = 0
t = 1
for n in range(1,11):
t *= n
sumValue += t
print ('1! + 2! + 3! + ... + 10! = %d' % sumValue)
方法二:
s = 0
myarray = range(1,11)
def myfunction(x):
r = 1
for i in range(1,x + 1):
r *= i
return r
sumValue = sum(map(myfunction,myarray))
print ('1! + 2! + 3! + ... + 10! = %d' % sumValue)
1! + 2! + 3! + ... + 10! = 4037913