阶乘

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            float sum = 0;

            for (int i = 1; i <= 30; i++)
            {
                int temp = 1;
                for (int j = i; j > 0; j--)
                {
                    temp = j * temp;
                }
                sum += (1 / (temp * 1.0f));
            }
            Console.WriteLine(sum);
            Console.ReadKey();

        }
    }
}
View Code

求函数f(n)=1/1!+1/2!+1/3!+..1/n!,n=30的值

posted on 2016-09-14 11:49  愚公学编程  阅读(121)  评论(0编辑  收藏  举报