N的阶乘就是n.(n-1)! 5的阶乘是什么?5*4*3*2*1
#include <iostream> using namespace std; int jiecheng(int num){ int f; if(num==1) f=1; else f=jiecheng(num-1)*num; return f; } int main(){ int n=5; cout<<jiecheng(n)<<endl; return 0; }
N的阶乘就是n.(n-1)! 5的阶乘是什么?5*4*3*2*1
#include <iostream> using namespace std; int jiecheng(int num){ int f; if(num==1) f=1; else f=jiecheng(num-1)*num; return f; } int main(){ int n=5; cout<<jiecheng(n)<<endl; return 0; }