阶乘的精确值(白皮书)
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
const int maxn = 3000;
int f[maxn];
int main()
{
//freopen("output.txt","w",stdout);
int i, j, n;
scanf("%d",&n);
memset(f, 0, sizeof(f));
f[0] = 1;
for(i = 2; i <= n; i ++)
{//乘以i
int c = 0;//进位量
for(j = 0; j < maxn; j ++)
{
int s = f[j] * i + c;
f[j] = s % 10;//个位留下
c = s / 10; //十位进上 两个个位数之积至多为两位数
}
}
for(j = maxn - 1; j >= 0; j --)
if(f[j]) break;//得出数字串长度
for(i = j; i >= 0; i --) printf("%d",f[i]);
printf("\n%d",j);
system("pause");
return 0;
}