login
(Number of 1's in the binary expansion of n) mod 4.
2

%I #26 Sep 17 2020 04:40:37

%S 0,1,1,2,1,2,2,3,1,2,2,3,2,3,3,0,1,2,2,3,2,3,3,0,2,3,3,0,3,0,0,1,1,2,

%T 2,3,2,3,3,0,2,3,3,0,3,0,0,1,2,3,3,0,3,0,0,1,3,0,0,1,0,1,1,2,1,2,2,3,

%U 2,3,3,0,2,3,3,0,3,0,0,1,2,3,3,0,3,0,0,1,3,0,0,1,0,1,1,2,2,3,3,0,3

%N (Number of 1's in the binary expansion of n) mod 4.

%C This is the generalized Thue-Morse sequence t_4 (Allouche and Shallit, p. 335).

%D J.-P. Allouche and J. Shallit, Automatic Sequences, Cambridge Univ. Press, 2003.

%F a(n) = A010873(A000120(n)).

%t Nest[ Flatten[ # /. {0 -> {0, 1}, 1 -> {1, 2}, 2 -> {2, 3}, 3 -> {3, 0}}] &, {0}, 7] (* _Robert G. Wilson v_, May 17 2014 *)

%t Table[Mod[DigitCount[n,2,1],4],{n,0,110}] (* _Harvey P. Dale_, Jul 24 2016 *)

%o (PARI) a(n)=hammingweight(n)%4 \\ _Charles R Greathouse IV_, May 09 2016

%Y Cf. A000120, A010873, A010060 (mod 2), A071858 (mod 3).

%K nonn,easy

%O 0,4

%A _N. J. A. Sloane_, Jan 11 2011