Pagini recente » Istoria paginii runda/emagcluj_9_2016_2/clasament | Cod sursa (job #343001) | Cod sursa (job #1476186) | Cod sursa (job #1000780) | Cod sursa (job #1447611)
Program Factorial;
var p,n:longint;
k:longint;
f:real;
z:boolean;
i,o:text;
begin
assign(i,'fact.in');
assign(o,'fact.out');
reset(i);
rewrite(o);
Read(i,p);
n:=1;f:=1; z:=true;
While (k<=100000000) and z do begin
f:=f*n;
inc(n);
if (n div 5<>0) and (n mod 5 =0) then inc(k) else;
if (k=p) then z:=false;
end;
if (k=p) and (k<=100000000) then Write(o,n)
else Write(o,-1);
close(i);
close(o);
end.