A377919 a(0) = 0; thereafter a(n) is the lexicographically earliest missing nonnegative integer such that the digits in the sequence (ignoring the commas) alternate in parity.
0, 1, 2, 10, 101, 21, 210, 1010, 10101, 2101, 21010, 101010, 1010101, 210101, 2101010, 10101010, 101010101, 21010101, 210101010, 1010101010, 10101010101, 2101010101, 21010101010, 101010101010, 1010101010101, 210101010101, 2101010101010, 10101010101010, 101010101010101, 21010101010101, 210101010101010, 1010101010101010, 10101010101010101, 2101010101010101, 21010101010101010, 101010101010101010
Offset: 0
Examples
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.)
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).
Programs
-
Mathematica
LinearRecurrence[{1, -1, 1, 100, -100, 100, -100}, {0, 1, 2, 10, 101, 21, 210, 1010, 10101}, 50] (* Paolo Xausa, Dec 09 2024 *)
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.
Comments