递归求n的阶乘

namespace 递归求n的阶乘
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine(factory(4)); 
        }
        static int factory(int n)
        {
            if (n == 0 || n == 1)
            {
                return 1;
            }
            else
            {
                return n*factory(n - 1);
            }
        }
    }
}
posted @ 2012-08-01 20:33  ``炯``  阅读(332)  评论(0编辑  收藏  举报