Cod sursa(job #1447715)
Utilizator | Data | 5 iunie 2015 02:13:45 | |
---|---|---|---|
Problema | Factorial | Scor | 5 |
Compilator | fpc | Status | done |
Runda | Arhiva de probleme | Marime | 1.29 kb |
Program Factorial;
var p,n,x,k,r,m: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;k:=0;
While (k<=100000000) and z do begin
f:=f*n;
inc(n);
if (n mod 5=0) and (n div 5<>0) then begin
x:=n;m:=1;
While m<>x do begin
m:=m*5;
inc(r);
end;
k:=k+r;
end;
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.