%I #41 Jul 03 2024 10:05:11
%S 0,1,1,1,1,1,1,2,1,1,1,2,1,2,2,1,1,1,1,2,1,2,2,1,1,2,2,1,2,1,1,2,1,1,
%T 1,2,1,2,2,1,1,2,2,1,2,1,1,2,1,2,2,1,2,1,1,2,2,1,1,2,1,2,2,2,1,1,1,2,
%U 1,2,2,1,1,2,2,1,2,1,1,2,1,2,2,1,2,1,1,2,2,1,1,2,1,2,2,2,1,2,2
%N Sum of bits of sum of bits of n: a(n) = wt(wt(n)).
%H Reinhard Zumkeller, <a href="/A054868/b054868.txt">Table of n, a(n) for n = 0..10000</a>
%H Richard Bellman and Harold N. Shapiro, <a href="http://www.jstor.org/stable/1969281">On a problem in additive number theory</a>, Annals Math., 49 (1948), 333-340.
%H Michael Gilleland, <a href="/selfsimilar.html">Some Self-Similar Integer Sequences</a>.
%H <a href="/index/Bi#binary">Index entries for sequences related to binary expansion of n</a>.
%F a(n) = A000120(A000120(n)).
%F a(2^(2^n-1)-1) = a(A077585(n)) = n (first occurrence). - _Alois P. Heinz_, Jul 04 2022
%e a(127) = 3 since 127 in base 2 is 1111111, whose sum of bits is 7 and 7 in base 2 is 111, whose sum of bits is 3.
%p a:= n-> (w-> w(w(n)))(k-> add(i, i=Bits[Split](k))):
%p seq(a(n), n=0..100); # _Alois P. Heinz_, Jul 04 2022
%t a[n_] := DigitCount[DigitCount[n, 2, 1], 2, 1]; Array[a, 100, 0] (* _Amiram Eldar_, Jul 24 2023 *)
%o (PARI) a(n) = norml2(binary(norml2(binary(n)))) \\ _Michel Marcus_, May 25 2013
%o (PARI) a(n) = hammingweight(hammingweight(n)); \\ _Ruud H.G. van Tol_, Jul 03 2024
%o (Haskell)
%o a054868 = a000120 . a000120 -- _Reinhard Zumkeller_, Mar 31 2015
%o (Python)
%o def a(n): return n.bit_count().bit_count()
%o print([a(n) for n in range(99)]) # _Michael S. Branicky_, Jul 04 2022
%Y Cf. A000120, A077585 (where records occur), A089224.
%K nonn,base,easy
%O 0,8
%A _Jeffrey Shallit_, May 15 2000