题目要求,尝试不使用循环语句,且 n 的取值范围较小,所以采用递归求解 AC代码: #include<iostream> using namespace std; int f(int n){ if(n==1) return 1; return (f(n-1)*n); } int main(){ int n ; cin >> n ; cout << f(n) << endl; return 0; }