|
|
|
|
0, 2, 1, 6, 3, 9, 5, 12, 4, 16, 7, 18, 8, 23, 10, 27, 13, 29, 11, 33, 14, 35, 15, 40, 17, 43, 19, 47, 20, 50, 21, 53, 22, 57, 24, 60, 26, 63, 25, 67, 28, 71, 31, 75, 34, 79, 32, 78, 30, 85, 36, 87, 37, 90, 38, 95, 41, 97, 39, 101, 42, 105, 45, 109, 48, 113, 46, 112, 44, 118, 49, 121, 51
(list;
graph;
refs;
listen;
history;
text;
internal format)
|
|
|
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
|
|
|
STATUS
|
approved
|
|
|
|