六、递归-阶乘

自己调用自己。

#include <iostream>

using namespace std;

int Factorial(int value);
int main()
{
    int number = Factorial(5);
    cout << "Factorial" << number << endl;

    system("pause");
    return 0;
}

int Factorial(int value)
{
    if(value == 0)
        return 1;
    else
        return value * Factorial(value -1);
}
原文地址:https://www.cnblogs.com/gongyan/p/4325847.html