login
Lexicographically earliest sequence of nonnegative integers in which, for all k >= 0, there are exactly k pairs of consecutive terms whose sum is k.
3

%I #45 Nov 17 2024 10:14:10

%S 0,1,1,1,2,1,2,2,2,2,2,3,2,3,2,3,3,3,3,3,3,3,4,3,4,3,4,3,4,4,4,4,4,4,

%T 4,4,4,5,4,5,4,5,4,5,4,5,5,5,5,5,5,5,5,5,5,5,6,5,6,5,6,5,6,5,6,5,6,6,

%U 6,6,6,6,6,6,6,6,6,6,6,7,6,7,6,7,6,7,6,7,6,7,6,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,8

%N Lexicographically earliest sequence of nonnegative integers in which, for all k >= 0, there are exactly k pairs of consecutive terms whose sum is k.

%C The old definition was "Lexicographically earliest sequence starting with a(1) = 0 such that a(n) is the number of pairs of contiguous terms whose sum is a(n)".

%C From _Paul Curtz_, Apr 27 2019: This can be written as a triangle:

%C 0

%C 1 1

%C 1 2 1

%C 2 2 2 2

%C 2 3 2 3 2

%C 3 3 3 3 3 3

%C 3 4 3 4 3 4 3

%C ...

%H Jean-Marc Falcoz, <a href="/A307707/b307707.txt">Table of n, a(n) for n = 1..11326</a>

%F a(n) + a(n+1) = A002024(n). - _Rémy Sigrist_, Apr 24 2019

%F Let t_m = m*(m+1)/2. Write n = t_m - i with m >= 1 and 0 <= i < m. Then a(n) = m/2 if m is even, or if m is odd, a(n) = (m-1)/2 + (i-1 mod 2). - _N. J. A. Sloane_, Nov 16 2024

%t m = 107; a[1]=0;

%t a24[n_] := Ceiling[(Sqrt[8n+1]-1)/2];

%t Array[a, m] /. Solve[Table[a[n] + a[n+1] == a24[n], {n, 1, m-1}]][[1]] (* _Jean-François Alcover_, Jun 02 2019, after _Rémy Sigrist_'s formula *)

%o (PARI) v=0; rem=wanted=1; for (n=1, 107, print1 (v", "); v=wanted-v; if (rem--==0, rem=wanted++)) \\ _Rémy Sigrist_, Apr 23 2019

%Y Cf. A002024.

%Y Cf. also A007590, A057353, A106466 and A238410.

%Y For other versions see A307720 and A378117.

%K nonn,look,changed

%O 1,5

%A _Eric Angelini_ and _Jean-Marc Falcoz_, Apr 23 2019

%E Definition clarified by _Rémy Sigrist_ and _N. J. A. Sloane_, Nov 17 2024