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(); } } }
求函数f(n)=1/1!+1/2!+1/3!+..1/n!,n=30的值