阶乘

打印出100的阶乘(即1*2*3*…*100)的精确数值结果(不能是浮点数)。如5的阶乘是1*2*3*4*5=120

namespace shuzu

{

    class Program

    {

        static void Main(string[] args)

        {

            Console.WriteLine("请输入一个正数");

            int n = int.Parse(Console.ReadLine());

            Console.WriteLine("{0}的阶乘1*2*3*…*{1}={2}", n,n,Fn(n));

        }

        public static double Fn(int n)

        {

            if (n==1)

            {

                return 1;

            }

            else

            {

                return n * Fn(n - 1);

            }

        }

    }

}

原文地址:https://www.cnblogs.com/dongwenhua/p/9000987.html