OFFSET
0,3
COMMENTS
Odd terms are added, even terms are subtracted. At each step, the next term is chosen among numbers which did not yet occur, as to minimize this sum.
LINKS
M. F. Hasler, in reply to E. Angelini, Minimizing Q, SeqFan list, Nov 11 2014.
FORMULA
a(2n) = 2n+1 for n > 0; a(2^n-1) = 3*2^(n-1)-2 are particularly large "early bird" values (records of a(n)-n), a(2^n-3) = 2^(n-1)-2 are particularly small values (records of n-a(n), and also the values such that all subsequent terms are larger).
PROG
(PARI) a(n, a=0, Q=0, u=[])={for(n=1, n, print1(a", "); u=setunion(u, Set(a)); Q-=(-1)^a*a; forstep(k=Q%2, Q, 2, setsearch(u, Q-k)&&next; a=Q-k; next(2)); forstep(k=1, 9e9, 2, setsearch(u, k)&&next; a=k; next(2)))}
CROSSREFS
KEYWORD
nonn
AUTHOR
M. F. Hasler and Eric Angelini, Nov 11 2014
STATUS
approved