%I #36 Jan 11 2023 06:39:43
%S 0,1,0,2,0,1,0,0,0,1,0,2,0,1,0,1,0,1,0,2,0,1,0,0,0,1,0,2,0,1,0,2,0,1,
%T 0,2,0,1,0,0,0,1,0,2,0,1,0,1,0,1,0,2,0,1,0,0,0,1,0,2,0,1,0,0,0,1,0,2,
%U 0,1,0,0,0,1,0,2,0,1,0,1,0,1,0,2,0,1,0,0,0,1,0,2,0,1,0,2,0,1,0,2,0,1,0,0,0
%N Ternary sequence that is a fixed point of the morphism 0 -> 01, 1 -> 02, 2 -> 00.
%H Antti Karttunen, <a href="/A096271/b096271.txt">Table of n, a(n) for n = 0..65537</a>
%H <a href="/index/Fi#FIXEDPOINTS">Index entries for sequences that are fixed points of mappings</a>.
%F Recurrence: a(2n) = 0, a(2n+1) = (a(n)+1) mod 3. - _Ralf Stephan_, Dec 11 2004
%F a(n) = A007814(n+1) mod 3. - _Gabriele Fici_, Mar 28 2019
%F Asymptotic mean: Limit_{m->oo} (1/m) * Sum_{k=1..m} a(k) = 4/7. - _Amiram Eldar_, Jan 11 2023
%t Nest[ Function[ l, {Flatten[(l /. {0 -> {0, 1}, 1 -> {0, 2}, 2 -> {0, 0}})]}], {0}, 7] (* _Robert G. Wilson v_, Feb 26 2005 *)
%o (PARI) map(d)=if(d==2,[0,0],if(d==1,[0,2],[0,1]))
%o {m=53;v=[];w=[0];while(v!=w,v=w;w=[];for(n=1,min(m,length(v)),w=concat(w,map(v[n]))));for(n=1,2*m,print1(v[n],","))} \\ _Klaus Brockhaus_, Jun 23 2004
%o (PARI) A096271(n) = if(!(n%2),0,(1+A096271((n-1)/2))%3); \\ _Antti Karttunen_, Nov 01 2018
%o (Python)
%o def A096271(n): return (~(n+1) & n).bit_length()%3 # _Chai Wah Wu_, Jan 09 2023
%Y Cf. A007814, A071858.
%K nonn,easy
%O 0,4
%A _N. J. A. Sloane_, Jun 23 2004
%E More terms from _Klaus Brockhaus_, Jun 23 2004