long fac1(int n)
{
long f;
if (n == 1) f = 1;
else f = n * fac1(n - 1);
return (f);
}
int main()
{
int n;
long y;
printf(" 请输入n(n < 13):");
scanf("%d", &n);
if (n > 12)
{
printf(" 输入的n超出上限12,请重新输入n。\n");
return 0;
}
y = fac1(n);
printf(" %d! = %ld\n", n, y);
return 0;
}
结果: