📄 求n个数的阶乘.txt
字号:
using System;public class Factorial{
public long factorial(long x){
return ((x<=1) ? 1 : x*(factorial(x-1)));
}
}
public class FactorialSum
{
public static void Main()
{
long temp=0;
long sum=0;
Console.WriteLine ("输入一个数:");
int x=int.Parse (Console.ReadLine ());
for(int i=1;i<=x;i++)
{
Factorial f1=new Factorial ();
temp+=f1.factorial (i);
}
sum+=temp;
Console.WriteLine ("1!+2!+3!+...+a!="+sum);
}}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -