# coding=utf-8
"""求1+2!+3!+...+20!的和."""
def getNumStep(num):
if num == 1:
return 1
else:
return num * getNumStep(num - 1)
if __name__ == '__main__':
sum = 0
for i in range(1, 21):
sum += getNumStep(i)
print(sum)
# 初学Python 如有不足 请多多指教
# coding=utf-8
"""求1+2!+3!+...+20!的和."""
def getNumStep(num):
if num == 1:
return 1
else:
return num * getNumStep(num - 1)
if __name__ == '__main__':
sum = 0
for i in range(1, 21):
sum += getNumStep(i)
print(sum)
# 初学Python 如有不足 请多多指教