#include<iostream>
using namespace std;
int main()
{
int n;
int sum = 1;
int total = 0;
cin >> n;
for (int i = 1; i <= n; i++)
{
sum = sum*i;
total += sum;
}
cout << total << endl;
system("pause");
}
计算阶乘相加1!+2!+3!
#include<iostream>
using namespace std;
int main()
{
int n;
int sum = 1;
int total = 0;
cin >> n;
for (int i = 1; i <= n; i++)
{
sum = sum*i;
total += sum;
}
cout << total << endl;
system("pause");
}