[求助]求阶乘出现的问题
#include <stdio.h>long factorial(int a)
{
long fac;
if(a<0)
printf("error!!!!!");
else if(a==0||a==1)
fac=1;
else
fac=factorial(a-1)*a;
return(fac);
}
main()
{
int n;
long mul;
printf("input a number:");
scanf("%d",&n);
mul=factorial(n);
printf("the factorial of %d is:%1d",n,mul);
getch();
return 0;
}
这个程序从0到7的阶乘计算是对的到8以上就错了
输出:
input a number:7
the factorial of 7 is:5040
input a number:8
the factorial of 8 is:-25216
这是怎么一回事???