

















C#:
class Class1
{
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main(string[] args)
{
Console.WriteLine(factorial(6));
}
private static long factorial(int n)//记得一定要用long返回类型,不然数值大了就成负数了哦
{
if (n == 1) return 1;
else return n * factorial(n - 1);
}
}
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。