Pagini recente » Cod sursa (job #2059100) | Cod sursa (job #1579375) | Cod sursa (job #620384) | Cod sursa (job #1323144) | Cod sursa (job #51766)
Cod sursa(job #51766)
var n:longint;
x5:longint;
i:integer;
function power(x:integer):integer;
var rez:integer;
begin
rez:=0;
while x mod 5 = 0 do
begin
inc(rez);
x:=x div 5;
end;
power:=rez;
end;
begin
assign(input,'fact.in');
reset(input);
assign(output,'fact.out');
rewrite(output);
write('n> ');readln(n);
x5:=0;
i:=1;
while x5<n do
begin
inc(x5,power(i));
inc(i);
end;
if n<0 then writeln('-1') else if i=1 then writeln('1') else if (i-1) mod 5 = 0 then writeln(i-1) else writeln('-1');
close(output);
end.