c++ 递归求一个数的阶乘
#include <iostream> using namespace std; long factorial(int value); int main() { int value; cout << "input number: "; cin >> value; cout << "factorial: " << factorial(value) << endl; return 0; } long factorial(int value) { if (value == 0) { return 1; } return value * factorial(value - 1); }