login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

A054868
Sum of bits of sum of bits of n: a(n) = wt(wt(n)).
4
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, 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, 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
OFFSET
0,8
LINKS
Richard Bellman and Harold N. Shapiro, On a problem in additive number theory, Annals Math., 49 (1948), 333-340.
FORMULA
a(n) = A000120(A000120(n)).
a(2^(2^n-1)-1) = a(A077585(n)) = n (first occurrence). - Alois P. Heinz, Jul 04 2022
EXAMPLE
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.
MAPLE
a:= n-> (w-> w(w(n)))(k-> add(i, i=Bits[Split](k))):
seq(a(n), n=0..100); # Alois P. Heinz, Jul 04 2022
MATHEMATICA
a[n_] := DigitCount[DigitCount[n, 2, 1], 2, 1]; Array[a, 100, 0] (* Amiram Eldar, Jul 24 2023 *)
PROG
(PARI) a(n) = norml2(binary(norml2(binary(n)))) \\ Michel Marcus, May 25 2013
(PARI) a(n) = hammingweight(hammingweight(n)); \\ Ruud H.G. van Tol, Jul 03 2024
(Haskell)
a054868 = a000120 . a000120 -- Reinhard Zumkeller, Mar 31 2015
(Python)
def a(n): return n.bit_count().bit_count()
print([a(n) for n in range(99)]) # Michael S. Branicky, Jul 04 2022
CROSSREFS
Cf. A000120, A077585 (where records occur), A089224.
Sequence in context: A319608 A230850 A072085 * A352517 A347981 A065081
KEYWORD
nonn,base,easy
AUTHOR
Jeffrey Shallit, May 15 2000
STATUS
approved