#include<stdio.h>
#include <string.h>
int main ()
{
int n, ans[80005], tmp=0, index;
memset(ans, 0, sizeof(ans));
ans[0] = 1;
scanf ("%d", &n);
for (int j=1; j<=n; j++)
{
tmp = 0;
for (int i=0; i<80004; i++) {
ans[i] = ans[i]*j + tmp;
tmp = ans[i] /10;
ans[i] = ans[i] % 10;
}
}
for (int i=80004; i>=0; i--)
{
if (ans[i])
{
index = i;
break;
}
}
for (int i=index; i>=0; i--) {
printf ("%d", ans[i]);
}
return 0;
}
求一万以内的阶乘(高精度算法)
最新推荐文章于 2024-11-08 15:24:41 发布