%I #46 Jan 09 2024 08:19:16
%S 0,1,2,1,2,1,0,1,2,1,0,1,0,1,2,1,2,1,0,1,0,1,2,1,0,1,2,1,2,1,0,1,2,1,
%T 0,1,0,1,2,1,0,1,2,1,2,1,0,1,0,1,2,1,2,1,0,1,2,1,0,1,0,1,2,1,2,1,0,1,
%U 0,1,2,1,0,1,2,1,2,1,0,1,0,1,2,1,2,1,0,1,2,1,0,1,0,1,2,1,0,1,2,1,2,1,0,1,2,1
%N a(n) = 2*(Sum_{k=0..n} A010060(k)) - n, where A010060 is a Thue-Morse sequence.
%C Is there any interesting sequence b(n) such that b(n) mod 3 = a(n)?
%C Fixed point of the morphism 0->012; 1->1; 2->210 starting with a(0) = 0. - _Philippe Deléham_, Mar 14 2004
%H Antti Karttunen, <a href="/A076826/b076826.txt">Table of n, a(n) for n = 0..8191</a>
%H Hsien-Kuei Hwang, Svante Janson, and Tsung-Hsi Tsai, <a href="https://arxiv.org/abs/2210.10968">Identities and periodic oscillations of divide-and-conquer recurrences splitting at half</a>, arXiv:2210.10968 [cs.DS], 2022, p. 52.
%H <a href="/index/Fi#FIXEDPOINTS">Index entries for sequences that are fixed points of mappings</a>
%F a(2k+1) = 1, a(4k) = a(2k), a(4k+2) = 2-a(2k). - _Michael Somos_, Dec 04 2002
%F a(2n) = 2*A010060(n); a(2n+1) = 1. - _Benoit Cloitre_, Mar 08 2004
%F a(n) = 2*(A026430(n+1) - 1) mod 3. - _Philippe Deléham_, Mar 28 2004
%F a(n) = (number of odious numbers <= n) - (number of evil numbers <= n) for n>0. - _T. D. Noe_, Jun 14 2007
%F a(n) = 2*A115384(n) - n. - _Vladimir Shevelev_, May 31 2009
%F a(n) = 0 if n and A000120(n) are even; a(n) = 2 if n is even but A000120(n) is odd; a(n) = 1 if n is odd. - _Vladimir Shevelev_, May 31 2009
%t Nest[ Function[ l, {Flatten[(l /. {0 -> {0, 1, 2}, 1 -> {1}, 2 -> {2, 1, 0}}) ]}], {0}, 6] (* _Robert G. Wilson v_, Mar 03 2005 *)
%t cnt=0; Join[{0}, Table[If[EvenQ[Count[IntegerDigits[n,2],1]], cnt--, cnt++ ]; cnt, {n,150}]] (* _T. D. Noe_, Jun 14 2007 *)
%o (PARI) a(n)=if(n<0,0,2*sum(k=1,n,subst(Pol(binary(k)),x,1)%2)-n)
%o (PARI) a(n)=if(n<1,0,if(n%2,1,if(n/2%2,2-a(n\4*2),a(n/2))))
%o (Python)
%o def A076826(n): return 1 if n&1 else (n.bit_count()&1)<<1 # _Chai Wah Wu_, Mar 01 2023
%Y Cf. A000069 (odious numbers), A001969 (evil numbers).
%Y Cf. A000120, A007413, A010060, A026430, A115384, A159481.
%K nonn
%O 0,3
%A _Benoit Cloitre_, Nov 24 2002