OFFSET
0,8
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.
FORMULA
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
KEYWORD
nonn,base,easy
AUTHOR
Jeffrey Shallit, May 15 2000
STATUS
approved