/*
求n的阶乘
*/
#include <stdio.h>
int main()
{
int n,i,r,res;
scanf("%d",&n);
r=1;
res=1;
while(n>1)
{
res=n*(n-1);
r=r*res;
n=n-2;
}
printf("the result is %d.\n",r);
return 0;
}
输入:
5
输出结果:
the result is 120.