#include <stdio.h>
int main()
{
int n, i, j, tmp, sum;
char num[3000] = { 1 };
scanf( "%d", &n );
for ( i=2; i<=n; i++ )
for ( j=0,tmp=0; j<3000; j++ )
{
sum = num[j]*i+tmp;
num[j] = sum%10;
tmp = sum/10;
}
i = 2999;
while ( !num[i] )
i--;
for ( j=i; j>=0; j-- )
printf( "%d",num[j] );
putchar( '\n' );
return 0;
}
把结果存放在字符数组里,所以能表示最低位到最高位的所有数字。
转载于:https://www.cnblogs.com/jlbs/p/6390369.html
相关资源:算10000以内数阶乘的C语言程序