n次循环
以 n = 4 为例
利用 n!+(n-1)! = (n + 1) x ( n - 1)!
4! + 3! + 2! + 1! + 0!
= (4+1) x 3! + 2! + 1! + 0!
= ( (4+1) x 3 + 1) x 2! + 1! + 0!
= ( ( (4+1) x 3 + 1) x 2 + 1) x 1 + 0!
= ( ( ( (4+1) x 3 + 1) x 2 + 1) x 1 + 1) x 0!
#include <iostream>
#include <stdio.h>
#include <string>
#include <typeinfo>
#include <stack>
#include <vector>
#include <sstream>
#include <string.h>
#include <map>
#include <math.h>
#include <stdlib.h>
#include <limits.h>
using namespace std;
typedef long long LL;
int main()
{
int n = 5;
long long s = 1;
for (;n >= 1; n--)
{
s = (1 + n * s) ;
}
cout<< s <<endl;
return 0;
}