自己调用自己。

#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);
}

 

posted on 2015-03-10 13:48  箭已离弓  阅读(112)  评论(0编辑  收藏  举报