#大问题-->刚好的子问题-->寻求出口--->保存数据用return #用Long作为返回值,int溢出了 #include <iostream> #include<cstdio> using namespace std; long fun(int n ){ if(n==1) return 1; else return fun(n-1)*n; } int main() { int n; while(scanf("%d",&n)!=EOF){ printf("%ld",fun(n));} } // 64 位输出请用 printf("%lld")