#include
int jieCheng(int n)
{
if (1 == n || 0 == n)
{
return 1;
}
return n*jieCheng(n -1);
}
int main()
{
printf("请输入n的值:\n");
int n = 0;
scanf("%d", &n);
printf("%d! = %d \n", n, jieCheng(n));
return 0;
}
运行结果:
#include
int jieCheng(int n)
{
if (1 == n || 0 == n)
{
return 1;
}
return n*jieCheng(n -1);
}
int main()
{
printf("请输入n的值:\n");
int n = 0;
scanf("%d", &n);
printf("%d! = %d \n", n, jieCheng(n));
return 0;
}
运行结果: