OFFSET
0
COMMENTS
Unlike the Thue-Morse sequence A010060, the nested index 2n+1-a(n) in the recurrence formula cannot be simplified to a linear function of n. This makes a(n) a "genuinely nested" automatic sequence. The sequence is balanced; i.e., a(2n) + a(2n+1) = 1 for all n >= 0. The sequence is 4-automatic with a 4-state DFAO reading base-4 digits most significant first. The auxiliary sequence b(n) = a(2n+1-a(n)) is A392743.
LINKS
Michael De Vlieger, Table of n, a(n) for n = 0..10000
John M. Campbell and Benoit Cloitre, Meta-automatic Sequences, arXiv:2602.23395 [math.NT], 2026. See p. 3.
FORMULA
a(0)=0, a(1)=1, and for n>=0: a(4n) = a(n), a(4n+1) = 1-a(n), a(4n+2) = a(2n+1-a(n)), a(4n+3) = 1-a(2n+1-a(n)).
EXAMPLE
For n=2: a(4*2+2) = a(10) = a(2*2+1-a(2)) = a(5-1) = a(4) = 1.
MATHEMATICA
a[0] = 0; a[1] = 1; a[n_] := a[n] = Which[Mod[n, 4] == 0, a[Quotient[n, 4]], Mod[n, 4] == 1, 1 - a[Quotient[n, 4]], Mod[n, 4] == 2, a[2*Quotient[n, 4] + 1 - a[Quotient[n, 4]]], True, 1 - a[2*Quotient[n, 4] + 1 - a[Quotient[n, 4]]]]; Table[a[n], {n, 0, 79}]
PROG
(PARI) a(n) = if(n<2, n, my(q=n\4, r=n%4); if(r==0, a(q), r==1, 1-a(q), r==2, a(2*q+1-a(q)), 1-a(2*q+1-a(q))));
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
John M. Campbell and Benoit Cloitre, Jan 21 2026
STATUS
approved
