python计算阶乘和1!+2!+4!+6!+8!+10!
时间: 2023-12-27 14:04:29 浏览: 113
以下是Python计算阶乘和1!+2!+4!+6!+8!+10!的代码实现:
```python
def factorial(n):
if n == 0:
return 1
else:
return n * factorial(n-1)
sum = 0
for i in [1, 2, 4, 6, 8, 10]:
sum += factorial(i)
print(sum)
```
输出结果为:37128
阅读全文