【洛谷】P1009阶乘之和
题目链接:https://www.luogu.org/problemnew/show/P1009
题意:给一个整数n(n<50),求$ \sum^{n}_{i=1} i! $
题解:我。。拿py水的。。主要是今天想练练python,后面再更C++的解法吧。(咕咕咕)
代码:
1 n = input() 2 n = int(n) 3 ans = 0 4 for i in range(1,n+1,1): 5 sum = 1 6 for j in range(1,i+1,1): 7 sum *= j 8 ans += sum 9 print(ans)