Pagini recente » Cod sursa (job #2540305) | Cod sursa (job #528297) | Cod sursa (job #3210393) | Cod sursa (job #3145782) | Cod sursa (job #139127)
Cod sursa(job #139127)
program factorial;
var f,g:text;
i,p,gasit,nr,i1:longint;
begin
assign(f,'fact.in');
assign(g,'fact.out');
reset(f);
rewrite(g);
read(f,p);
gasit:=0;
i:=0;
if p>99999999 then
begin
i:=400000010;
gasit:=99999999;
end else
if p>49999999 then
begin
i:=200000005;
gasit:=49999999;
end else
if p>9999999 then
begin
i:=40000005;
gasit:=9999999;
end else
if p>4999999 then
begin
i:=20000000;
gasit:=4999999;
end else
if p>999999 then
begin
i:=4000000;
gasit:=999999;
end else
if p>499999 then
begin
i:=2000000;
gasit:=499999;
end else
if p>99999 then
begin
i:=400000;
gasit:=99999;
end else
if p>49999 then
begin
i:=200005;
gasit:=49999;
end else
if p>9999 then
begin
i:=40005;
gasit:=9999;
end else
if p>999 then
begin
i:=4000;
gasit:=999;
end else
if p>99 then
begin
i:=400;
gasit:=99;
end;
while(gasit<p) do
begin
i:=i+5;
i1:=i;
while (i1 mod 3125=0) do
begin
i1:=i1 div 3125;
gasit:=gasit+5;
end;
while(i1 mod 125=0) do
begin
i1:=i1 div 125;
gasit:=gasit+3;
end;
while( i1 mod 5 =0) do
begin
i1:=i1 div 5;
gasit:=gasit+1;
end;
end;
if p=0 then nr:=1
else nr:=1;
write(g,nr);
close(f);
close(g);
end.