用递归方法求 n!

 1 #include <iostream>
 2 
 3 using namespace std;
 4 #define LL long long
 5 
 6 LL fac(int n)
 7 {
 8     LL f;
 9     if(n == 0 || n == 1)
10         f = 1;
11     else f = n * fac(n - 1);
12     return f;
13 }
14 
15 int main()
16 {
17     LL n;
18     while(cin >> n)
19     {
20         cout << fac(n) << endl;
21     }
22     return 0;
23 }
原文地址:https://www.cnblogs.com/jxust-jiege666/p/6574138.html