50分 求指导
查看原帖
50分 求指导
1512905
renli0426楼主2024/11/22 20:00

#include<bits/stdc++.h> using namespace std; int main () { int n , sum = 0 ,fact = 1; cin >> n; for ( int i = 1; i <= n ; ++ i) { fact *= i; sum += fact;

}
cout << sum << endl;
return 0;

}

#include<bits/stdc++.h>
using namespace std;
int main ()
{
	int n , sum = 0 ,fact = 1;
	cin >> n;
	for ( int i = 1; i <= n ; ++ i)
	{
		fact *= i;
		sum += fact;
		
	}
	cout << sum << endl;
	return 0;
}
2024/11/22 20:00
加载中...