int total = 0;
for(int i = 1; i< 11; i++){
int temp = 1;
for (int j = 1; j < i + 1; j ++){
temp =temp * j;
}
//i!
total = total + temp;
}
Console.WriteLine(total);
递归的写法:
static int F1(int n )
{
if(n ==1)
return 1;
int result = n *F1(n-1);
return result;
}
static int F2(int n )
{
if(n ==1)
return 1;
int result =F2(n-1)+F1(n);// 相加 ,加上累乘
return result;
}