# include<iostream>
using namespace std;
int main(){
int n ;
long long sum = 1, total_sum = 0;
cin >> n;
for (int i = 1; i <= n; i++)
{
for (int k = 1; k <= i; k++)
{
sum *= k;
}
total_sum += sum;
sum = 1; // 这条语句是为了下次循环使用
// cout << total_sum << endl;
}
cout << total_sum << endl;
return 0;
}
【1014】阶乘求和
最新推荐文章于 2023-07-18 15:29:34 发布