计算1!+2!+3!+。。。+10!。的Python代码
时间: 2023-11-13 19:54:53 浏览: 48
以下是计算1!+2!+3!+。。。+10!的Python代码:
```python
def factorial(n):
if n == 0:
return 1
else:
return n * factorial(n-1)
sum = 0
for i in range(1, 11):
sum += factorial(i)
print(sum)
```
输出结果为:4037913
阅读全文