%I #53 Oct 16 2019 12:14:28
%S 0,1,0,0,0,1,0,1,0,0,1,0,0,1,0,0,0,1,0,1,0,0,0,1,0,1,0,0,1,0,0,0,1,0,
%T 1,0,0,1,0,0,0,1,0,1,0,0,1,0,0,1,0,0,0,1,0,1,0,0,0,1,0,1,0,0,1,0,0,1,
%U 0,0,0,1,0,1,0,0,0,1,0,1,0,0,1,0,0,0,1,0,1,0,0,1,0,0,1,0,0,0,1,0,1,0,0,0,1,0,1,0,0,1,0,0,0,1,0,1,0,0,1,0,0,1
%N Fixed point of the morphism 0->010, 1->001.
%C a(n) is the parity of the number of ternary 1-digits below the lowest 0-digit in the ternary expansion of n-1. All fixed-width morphisms have a similar digital interpretation. - _Kevin Ryde_, Apr 26 2017
%H Joerg Arndt, <a href="/A189664/b189664.txt">Table of n, a(n) for n = 1..2187</a>
%H <a href="/index/Fi#FIXEDPOINTS">Index entries for sequences that are fixed points of mappings</a>
%F a(3k-2)=0, a(3k-1)=1-a(k), a(3k)=a(k) for k>=1, a(0)=0.
%F 2*a(n) = A284794(n) for n >= 1. - _Clark Kimberling_, Apr 14 2017
%F This formula cannot be correct, it belongs to A189665. - _Michel Dekking_, Oct 15 2019
%F a(n) = A284777(n) - 2n. - _Clark Kimberling_, Apr 15 2017
%e Iterating the morphism starting with 0:
%e 0: (#=1)
%e 0
%e 1: (#=3)
%e 010
%e 2: (#=9)
%e 010001010
%e 3: (#=27)
%e 010001010010010001010001010
%e 4: (#=81)
%e 010001010010010001010001010010001010010001010010010001010001010010010001010001010
%e etc.
%t t = Nest[Flatten[# /. {0->{0,1,0}, 1->{0,0,1}}] &, {0}, 5] (* A189664 *)
%t f[n_] := t[[n]]
%t Flatten[Position[t, 0]] (* A189665 *)
%t Flatten[Position[t, 1]] (* A189666 *)
%t s[n_] := Sum[f[i], {i, 1, n}]; s[0] = 0;
%t Table[s[n], {n, 1, 120}] (* A189667 *)
%t Nest[Flatten[# /. a_Integer -> {0, Abs[a - 1], a}] &, {0}, 5] (* _Robert G. Wilson v_, Jul 16 2012 *)
%o (PARI) a(n) = n--; my(ret=0); while(n%3, if(n%3==1,ret=!ret); n\=3); ret; /* _Kevin Ryde_, Jul 23 2019 */
%Y Cf. A189628, A189665, A189666, A189667.
%K nonn
%O 1
%A _Clark Kimberling_, Apr 25 2011