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.
18 lines
421 B
18 lines
421 B
#include <bits/stdc++.h>
|
|
|
|
using namespace std;
|
|
|
|
int main() {
|
|
int n;
|
|
cin >> n; // n!+(n-1)!+(n-2)!+...+1!
|
|
|
|
int sum = 0; //结果,累加和
|
|
for (int i = n; i >= 1; i--) { //枚举 n,n-1,n-2,....,1
|
|
//计算n这个数字的阶乘
|
|
int res = 1;
|
|
for (int j = i; j >= 1; j--) res *= j;
|
|
sum += res;
|
|
}
|
|
cout << sum << endl;
|
|
return 0;
|
|
} |