任意输入n,求S=1!+2!+...+n!
时间: 2023-11-24 21:50:47 浏览: 168
1!+2!+..n!
以下是一个任意输入n,求S=1!+2!+...+n!的Python程序:
```python
n = int(input("请输入n的值:"))
sum = 0
factorial = 1
for i in range(1, n+1):
factorial *= i
sum += factorial
print("S的值为:", sum)
```
阅读全文