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
E. Angelini, Minimizing Q, SeqFan list, Nov 11 2014.
PROG
(PARI) A250090(n=100, a=1, Q=0, u=[])={for(n=1, n, print1(a", "); u=setunion(u, Set(a)); Q-=(-1)^a*a; forstep(k=2-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))); a} \\ returns a(n) and prints out a(k) for 0<=k<n.
CROSSREFS
KEYWORD
nonn
AUTHOR
Eric Angelini and M. F. Hasler, Nov 11 2014
STATUS
approved