1.
#include <iostream>
using namespace std;
int main()
{
int n;
cin >> n;
int tmp = 1, ans = 0;
for (int i = 1; i <= n; i ++)
{
for (int j = 1; j <= i; j ++)
{
tmp *= j;
}
ans += tmp;
tmp = 1;
}
cout << ans << endl;
return 0;
}
2.
#include <iostream>
using namespace std;
int main()
{
int n;
cin >> n;
long long tmp = 1, ans = 0;
for (int i = 1; i <= n; i ++)
{
tmp *= i;
ans += tmp;
}
cout << ans << endl;
return 0;
}
标签:std,tmp,int,namespace,cin,计算,main
From: https://www.cnblogs.com/fghjktgbijn/p/17426189.html