OFFSET
0,3
COMMENTS
'Recamán transform' (see A005132) of the odd numbers.
LINKS
EXAMPLE
Consider n=7. We have a(6)=22 and try to subtract 13, the 7th odd number. The result, 9, is certainly positive, but we cannot use it because 9 is already in the sequence. So we must add 13 instead, getting a(7) = 22 + 13 = 35.
PROG
(PARI) A128204(N, s/*=1 to print all terms*/)={my(a=0, u=0); for( n=1, N, s&print1(a", "); u=bitor(u, 2^a+=if(a<2*n || bittest(u, a+1-2*n), 2*n-1, 1-2*n))); a} \\ M. F. Hasler, Mar 07 2012
CROSSREFS
KEYWORD
easy,nonn
AUTHOR
Nick Hobson, Feb 19 2007
STATUS
approved