下面的代码是用vs2010创建的一个C#的控制台应用程序:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace CSharp_Test
{
class Program
{
static void Main(string[] args)
{
double result = 0;
double sum = 0;
for (int i = 1; i <= 15; ++i)
{
double factorialSum = 1;
for (int j = 1; j <= i; ++j)
{
factorialSum *= j;
}
sum += factorialSum;
}
result = 1 / sum;
Console.WriteLine(result.ToString());
Console.ReadKey(true);
}
}
}