You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
tongxun/递归算法计算 n!.cpp

20 lines
238 B

#include <stdio.h>
int N(int n)
{
if(n<=1)
return 1;
else
return N(n-1)*n;//关键思想
}
int main()
{
int n=0;
int ret=0;
printf("请输入你想要求阶乘的数:");
scanf("%d",&n);
ret=N(n);
printf("%d的阶乘是%d\n",n,ret);
return 0;
}