用c++ 编程求1!+2!+3!+...+8!
时间: 2023-11-17 07:00:20 浏览: 165
c++ 1!+2!+3!+..
```c++
#include <iostream>
using namespace std;
int main() {
int n = 8;
int sum = 0;
int fac = 1;
for (int i = 1; i <= n; i++) {
fac *= i;
sum += fac;
}
cout << "1!+2!+3!+...+8! = " << sum << endl;
return 0;
}
```
--相关问题--:
1. 什么是阶乘?
2. C++中如何计算阶乘?
3.
阅读全文