Pagini recente » Cod sursa (job #861740) | Cod sursa (job #1905129) | Cod sursa (job #192235) | Cod sursa (job #431590) | Cod sursa (job #188888)
Cod sursa(job #188888)
var f:text;
p,r,fac,facc:int64;
begin
assign(f ,'fact.in');
reset(f);
read(f,p);
close(f);
r:=1;
fac:=5;
while r<p do
begin
r:=r+fac;
fac:=fac*5;
end;
assign(f ,'fact.out');
rewrite(f);
if r=p then
write(f,fac)
else
begin
while (p<>r) and (p<r) do
begin
facc:=fac;
while facc mod 25=0 do
begin
facc:=facc div 5;
r:=r-2;
end;
fac:=fac-5;
end;
if r=p then
write(f,fac)
else
write(f,'-1');
end;
close(f);
end.