A054868 Sum of bits of sum of bits of n: a(n) = wt(wt(n)).
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
Examples
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.
Links
- Reinhard Zumkeller, Table of n, a(n) for n = 0..10000
- Richard Bellman and Harold N. Shapiro, On a problem in additive number theory, Annals Math., 49 (1948), 333-340.
- Michael Gilleland, Some Self-Similar Integer Sequences.
- Index entries for sequences related to binary expansion of n.
Programs
-
Haskell
a054868 = a000120 . a000120 -- Reinhard Zumkeller, Mar 31 2015
-
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 *)
-
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
-
Python
def a(n): return n.bit_count().bit_count() print([a(n) for n in range(99)]) # Michael S. Branicky, Jul 04 2022
Formula
a(2^(2^n-1)-1) = a(A077585(n)) = n (first occurrence). - Alois P. Heinz, Jul 04 2022