C#.求 1+2!+3!+...+20!的和
时间: 2023-11-17 12:00:26 浏览: 115
iTextSharp.NetCore 添加浮水印 NuGet + 简单示例
C#代码如下所示:
```csharp
using System;
namespace FactorialSum
{
class Program
{
static void Main(string[] args)
{
int n = 20;
long sum = 0;
long factorial = 1;
for (int i = 1; i <= n; i++)
{
factorial *= i;
sum += factorial;
}
Console.WriteLine(sum);
}
}
}
```
阅读全文