Pagini recente » Cod sursa (job #2572552) | Cod sursa (job #2568436) | Cod sursa (job #1524393) | Diferente pentru problema/bile intre reviziile 6 si 5 | Cod sursa (job #157811)
Cod sursa(job #157811)
program factorial;
var n,i,j,k,p,s,f:longint;
begin
assign(input,'fact.in');
reset(input);
readln(p);
close(input);
n:=5*p;
repeat
s:=0;f:=5;
while n div f <> 0 do
begin
s:=s+n div f;
f:=f*5;
end;
n:=n+5;
until (s=p)or(n>maxlongint-10);
assign(output,'fact.out');
rewrite(output);
if p=0 then writeln('1')
else
if n>maxlongint-10 then writeln('-1')
else
writeln(n-5);
close(output);
end.