OFFSET
0,2
COMMENTS
Explicitly, this is the sequence of distinct nonnegative integers such that the sequence of first differences d(n) = a(n+1) - a(n) has alternating signs, distinct nonnegative partial sums, and the absolute values are all distinct and the lexicographically earliest sequence formed that way.
The first differences are (2, -1, 5, -3, 6, -4, 7, -8, 12, -9, 11, -10, 15, ...). Taking absolute values yields sequence S = A345967 which is the lexico-earliest sequence of distinct positive integers such that the alternating partial sums (i.e., a(n) = Sum_{k=1..n} -(-1)^k S(k), n >= 0) give all nonnegative integers exactly once.
LINKS
FORMULA
a(n) = Sum_{k=1..n} -(-1)^n * A345967(k), n >= 0.
PROG
(PARI) A343611_vec(Nmax, P=0)={ my(US=[0], UP=[P], used(x, U)= setsearch(U, x) || x<=U[1], insert(x, U)= U=setunion(U, [x]); while(#U>1&&U[2]==U[1]+1, U=U[^1]); U); vector(Nmax, n, my(s=(-1)^n); for(S=US[1]+1, oo, (used(S, US) || used(P-s*S, UP))&&next; if(s<0, my(f=1); for(PP=UP[1]+1, P+S-1, used(PP, UP) || used(P+S-PP, US) || PP==P || [f=0; break]); f && next); UP=insert(P-=s*S, UP); US=insert(S, US); break); P)} \\ Gives the vector a(1..Nmax), i.e., without a(0)=0.
CROSSREFS
KEYWORD
nonn
AUTHOR
M. F. Hasler, Jul 11 2021
STATUS
approved