编辑代码

#include <stdio.h>

int fun(int num)
{
 if(num < 0)
  return 0;
 if(num == 0 || num == 1)
  return 1;

 return num * fun(num-1);
}
int main()
{
 int num;
 scanf("%d",&num);

 printf("num的阶乘:%d\n",fun(num));
}