python学习记录-习题25

求1+2!+3!+...+20!的和。

def multiplys(n):
    mul = 1
    for i in range(1, n + 1):
        mul *= i
    return mul


def adds(n):
    total = 0
    for i in range(1, n + 1):
        total += multiplys(i)
    return total


print(adds(20))

2561327494111820313

 

posted @ 2021-07-20 14:34  一笔一划82  阅读(21)  评论(0)    收藏  举报