You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
23 lines
361 B
23 lines
361 B
2 years ago
|
#include <bits/stdc++.h>
|
||
|
|
||
|
using namespace std;
|
||
|
|
||
|
int jiecheng(int n) {
|
||
|
int result = 1;
|
||
|
for (int i = 1; i <= n; ++i) {
|
||
|
result *= i;
|
||
|
}
|
||
|
return result;
|
||
|
}
|
||
|
|
||
|
int main() {
|
||
|
int n;
|
||
|
cin >> n;
|
||
|
int sum = 0;
|
||
|
for (int i = 1; i <= n; ++i) {
|
||
|
sum += jiecheng(i);
|
||
|
}
|
||
|
cout << sum << endl;
|
||
|
return 0;
|
||
|
}
|