cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A054868 Sum of bits of sum of bits of n: a(n) = wt(wt(n)).

Original entry on oeis.org

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

Views

Author

Jeffrey Shallit, May 15 2000

Keywords

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.
		

Crossrefs

Cf. A000120, A077585 (where records occur), A089224.

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(n) = A000120(A000120(n)).
a(2^(2^n-1)-1) = a(A077585(n)) = n (first occurrence). - Alois P. Heinz, Jul 04 2022