Pagini recente » Cod sursa (job #1096163) | Cod sursa (job #8817) | Cod sursa (job #374883) | Cod sursa (job #1983199) | Cod sursa (job #1447609)
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);
if p=2 then Write(o,10) else;
if p=10 then write(o,45) else;
if (p<>2) and (p<>10) then write(o,-1) else;Write('P:=');Readln(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.