1000的阶乘等于多少?
答案:3 悬赏:10 手机版
解决时间 2021-02-19 14:37
- 提问者网友:斑駁影
- 2021-02-19 04:23
1000的阶乘等于多少?
最佳答案
- 五星知识达人网友:duile
- 2021-02-19 05:51
4.02387260077093773543702433923e+2567
用这个计算吧。。。。
#include
#include
int main( )
{
int n=1000, i;
double sum=0;
for(i=1; i<=n; i++)
sum += log10((double)(i));
printf("%d\n", (int)sum+1);
}
用这个计算吧。。。。
#include
#include
int main( )
{
int n=1000, i;
double sum=0;
for(i=1; i<=n; i++)
sum += log10((double)(i));
printf("%d\n", (int)sum+1);
}
全部回答
- 1楼网友:三千妖杀
- 2021-02-19 07:41
#include //任意键入1-1000的数,输出他的阶乘
#include
int a[10000];
int cheng(int p)
{
int i=9999;
while(a[i]==0)
i--;
for(;i>=0;i--)
a[i]=p*a[i];
for(i=0;i<10000;i++)
{
a[i+1]=a[i+1]+a[i]/10;
a[i]=a[i]%10;
}
}
int display()
{
int i=9999;
while(a[i]==0)
i--;
for(;i>=0;i--)
printf("%d",a[i]);
}
int main()
{
a[0]=1;
int d,i;
scanf("%d",&d);
for(i=2;i<=d;i++)
cheng(i);
if(d==1)
printf("1");
else
display();
return 0;
}
#include
int a[10000];
int cheng(int p)
{
int i=9999;
while(a[i]==0)
i--;
for(;i>=0;i--)
a[i]=p*a[i];
for(i=0;i<10000;i++)
{
a[i+1]=a[i+1]+a[i]/10;
a[i]=a[i]%10;
}
}
int display()
{
int i=9999;
while(a[i]==0)
i--;
for(;i>=0;i--)
printf("%d",a[i]);
}
int main()
{
a[0]=1;
int d,i;
scanf("%d",&d);
for(i=2;i<=d;i++)
cheng(i);
if(d==1)
printf("1");
else
display();
return 0;
}
- 2楼网友:荒野風
- 2021-02-19 07:21
1000!=4023872600770937735437024339230039857193748642107146325437999104299385123986290205920442084869694048004799886101971960586316668729948085589013238296699445909974245040870737599188236277271887325197795059509952761208749754624970436014182780946464962910563938874378864873371191810458257836478499770124766328898359557354325131853239584630755574091142624174743493475534286465766116677973966688202912073791438537195882498081268678383745597317461360853795345242215865932019280908782973084313928444032812315586110369768013573042161687476096758713483120254785893207671691324484262361314125087802080002616831510273418279777047846358681701643650241536913982812648102130927612448963599287051149649754199093422215668325720808213331861168115536158365469840467089756029009505376164758477284218896796462449451607653534081989013854424879849599533191017233555566021394503997362807501378376153071277619268490343526252000158885351473316117021039681759215109077880193931781141945452572238655414610628921879602238389714760885062768629671466746975629112340824392081601537808898939645182632436716167621791689097799119037540312746222899880051954444142820121873617459926429565817466283029555702990243241531816172104658320367869061172601587835207515162842255402651704833042261439742869330616908979684825901254583271682264580665267699586526822728070757813918581788896522081643483448259932660433676601769996128318607883861502794659551311565520360939881806121385586003014356945272242063446317974605946825731037900840244324384656572450144028218852524709351906209290231364932734975655139587205596542287497740114133469627154228458623773875382304838656889764619273838149001407673104466402598994902222217659043399018860185665264850617997023561938970178600408118897299183110211712298459016419210688843871218556461249607987229085192968193723886426148396573822911231250241866493531439701374285319266498753372189406942814341185201580141233448280150513996942901534830776445690990731524332782882698646027898643211390835062170950025973898635542771967428222487575867657523442202075736305694988250879689281627538488633969099598262809561214509948717012445164612603790293091208890869420285106401821543994571568059418727489980942547421735824010636774045957417851608292301353580818400969963725242305608559037006242712434169090041536901059339838357779394109700277534720000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
我是用FREE PASCAL编的
var
SD:text;
a:array [1..1000000] of Qword;
m,b,c,i,j,x,y:longint;
begin
assign(SD,'SD.txt');
fillchar(a,sizeof(a),0);
j:=1;
a[1]:=1;
m:=1;
readln(c);
for i:=2 to c do
begin
x:=0;
for b:=m to j do
begin
a[b]:=a[b]*i+x;
x:=a[b] div 1000000000000;
a[b]:=a[b] mod 1000000000000;
end;
while x<>0 do
begin
j:=j+1;
a[j]:=x mod 1000000000000;
x:=x div 1000000000000;
end;
while a[m]=0 do inc(m);
end;
rewrite(SD);
write(SD,c,'!=');
write(SD,a[j]);
for i:=j-1 downto 1 do
if a[i]<10 then write(SD,'00000000000',a[i])
else if a[i]<100 then write(SD,'0000000000',a[i])
else if a[i]<1000 then write(SD,'000000000',a[i])
else if a[i]<10000 then write(SD,'00000000',a[i])
else if a[i]<100000 then write(SD,'0000000',a[i])
else if a[i]<1000000 then write(SD,'000000',a[i])
else if a[i]<10000000 then write(SD,'00000',a[i])
else if a[i]<100000000 then write(SD,'0000',a[i])
else if a[i]<1000000000 then write(SD,'000',a[i])
else if a[i]<10000000000 then write(SD,'00',a[i])
else if a[i]<100000000000 then write(SD,'0',a[i])
else write(SD,a[i]);
writeln;
readln;
close(SD);
end.
算50000!都只须40S
我是用FREE PASCAL编的
var
SD:text;
a:array [1..1000000] of Qword;
m,b,c,i,j,x,y:longint;
begin
assign(SD,'SD.txt');
fillchar(a,sizeof(a),0);
j:=1;
a[1]:=1;
m:=1;
readln(c);
for i:=2 to c do
begin
x:=0;
for b:=m to j do
begin
a[b]:=a[b]*i+x;
x:=a[b] div 1000000000000;
a[b]:=a[b] mod 1000000000000;
end;
while x<>0 do
begin
j:=j+1;
a[j]:=x mod 1000000000000;
x:=x div 1000000000000;
end;
while a[m]=0 do inc(m);
end;
rewrite(SD);
write(SD,c,'!=');
write(SD,a[j]);
for i:=j-1 downto 1 do
if a[i]<10 then write(SD,'00000000000',a[i])
else if a[i]<100 then write(SD,'0000000000',a[i])
else if a[i]<1000 then write(SD,'000000000',a[i])
else if a[i]<10000 then write(SD,'00000000',a[i])
else if a[i]<100000 then write(SD,'0000000',a[i])
else if a[i]<1000000 then write(SD,'000000',a[i])
else if a[i]<10000000 then write(SD,'00000',a[i])
else if a[i]<100000000 then write(SD,'0000',a[i])
else if a[i]<1000000000 then write(SD,'000',a[i])
else if a[i]<10000000000 then write(SD,'00',a[i])
else if a[i]<100000000000 then write(SD,'0',a[i])
else write(SD,a[i]);
writeln;
readln;
close(SD);
end.
算50000!都只须40S
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯