题目:求1+2!+3!+…+20!的和?
有点类似九九乘法表,用俩层for循环搞定
int sum=0;
int n = 20;
for (int i = 1; i <= n; i++)
{
int temp = 1;
for (int j = 1; j <= i; j++)
{
temp *= j;
}
sum += temp;
}
Console.WriteLine(sum);
Console.ReadKey();