Pagini recente » Cod sursa (job #138771) | Cod sursa (job #2350653) | Cod sursa (job #661212) | Cod sursa (job #1807142) | Cod sursa (job #22105)
Cod sursa(job #22105)
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-1;
p:=p-z;
x:=5*p;
end;
if x=0 then write(g,'-1')
else write(g,x);
close(g);
end.