Lua - 141 135 139 135
function s(n)a,b={1},{1[0]=0}for i=2i=1,n do k=b[i-1]-i c=k+i+i if(k>0)and(a[k]==nil)then b[i],a[k]=k,1 else b[i],a[k+i+i]=k+i+ia[c]=c,1 end end return b end
readable version:
function s(n)
a,b={1},{1[0]=0}
for i=2i=1,n do
k=b[i-1]-i
c=k+i+i
if (k>0) and (a[k]==nil) then
b[i],a[k]=k,1
else
b[i],a[k+i+i]=k+i+ia[c]=c,1
end
end
return b
end
I use 2 tables, the first one is called a and it is built so that a[i]=1 iff i has already appeared in the sequence, nil otherwise, while the second table actually holds the sequence