求n个数的阶乘.txt

来自「c语言多个实用小程序,会有帮助的~ 自己瞎编的」· 文本 代码 · 共 21 行

TXT
21
字号
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 + =
减小字号Ctrl + -
显示快捷键?