while (true) { Console.WriteLine("请输入一个数n:"); int n = int.Parse(Console.ReadLine()); int sum = 0; for (int i = 1; i <= n; i++) { int s = 1; for (int a = 1; a <= i; a++) { s = s * a; } sum = sum + s; } Console.WriteLine("1-"+n+"的阶乘的和为:"+sum); Console.ReadLine(); }