Pagini recente » Cod sursa (job #1254726) | Cod sursa (job #78097) | Cod sursa (job #105901) | Cod sursa (job #2767343) | Cod sursa (job #22107)
Cod sursa(job #22107)
var f,g:text;
p,x,nr,y,z,i,m:longint;
begin
assign(f,'fact.in'); reset(f);
assign(g,'fact.out'); rewrite(g);
read(f,p); x:=0;
if p<0 then x:=0;
if p=0 then x:=1;
if p>0 then
begin
m:=0; y:=1;
repeat
begin
y:=y*5;
inc(m);
end
until y>p*5; dec(m); z:=0;
for i:=1 to m do z:=z+i; z:=z-m;
p:=p-z;
x:=5*p;
end;
if x=0 then write(g,'-1')
else write(g,x);
close(g);
end.