OFFSET
0,3
COMMENTS
A "lexicographically earliest" variant of A098951.
LINKS
Paolo Xausa, Table of n, a(n) for n = 0..1000
Index entries for linear recurrences with constant coefficients, signature (1,-1,1,100,-100,100,-100).
FORMULA
a(0) - a(6) are 0, 1, 2, 10, 101, 21, 210. Thereafter, for k >= 2,
a(4*k-1) = a(4*k-5) || 10,
a(4*k) = a(4*k-4) || 01,
a(4*k+1) = a(4*k-3) || 01,
a(4*k+2) = a(4*k-2) || 10,
where || denotes concatenation.
EXAMPLE
We begin by arranging the nonnegative integers whose digits alternate in parity in lexicographic order. First, 0; then the numbers with first digit 1: 1, 10, 101, 1010, 10101, 101010, ...; then the numbers with first digit 2: 2, 20, 201, 2010, 20101, 201010, ...; then the numbers with first digit 3, and so on.
The sequence begins with 0 and from then on we choose the first unused number from the above list which preserves alternating parity of the digits in the sequence.
(The above list does not have an OEIS entry, since there are uncountably many terms before the number 2 appears. In fact there are uncountably many terms before 12 appears. The beginning of the list coincides with A056830.)
MATHEMATICA
LinearRecurrence[{1, -1, 1, 100, -100, 100, -100}, {0, 1, 2, 10, 101, 21, 210, 1010, 10101}, 50] (* Paolo Xausa, Dec 09 2024 *)
PROG
(PARI) a(n)=if(n>1, ([0, 1, 0, 0, 0, 0, 0; 0, 0, 1, 0, 0, 0, 0; 0, 0, 0, 1, 0, 0, 0; 0, 0, 0, 0, 1, 0, 0; 0, 0, 0, 0, 0, 1, 0; 0, 0, 0, 0, 0, 0, 1; -100, 100, -100, 100, 1, -1, 1]^(n-2)*[2; 10; 101; 21; 210; 1010; 10101])[1, 1], n) \\ Charles R Greathouse IV, May 31 2026
CROSSREFS
KEYWORD
nonn,base,easy
AUTHOR
N. J. A. Sloane, Dec 08 2024
STATUS
approved
