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.

Showing 1-1 of 1 results.

A214561 Number of 1's in binary expansion of n^n.

Original entry on oeis.org

1, 1, 1, 4, 1, 6, 6, 11, 1, 14, 11, 20, 10, 28, 23, 33, 1, 31, 27, 41, 26, 49, 36, 59, 16, 58, 41, 68, 37, 62, 51, 83, 1, 79, 61, 88, 58, 97, 85, 98, 53, 115, 96, 116, 63, 123, 96, 128, 41, 138, 105, 144, 90, 163, 128, 164, 81, 172, 148, 181, 124, 167, 134, 201, 1
Offset: 0

Views

Author

Alex Ratushnyak, Jul 21 2012

Keywords

Comments

a(n) + A214562(n) = 1+floor(log_2(n^n)) = 1, 1, 3, 5, 9, 12, 16, 20, 25, 29, 34, 39, 44, 49... is the number of binary digits in n^n. - R. J. Mathar, Jul 22 2012

Crossrefs

Programs

  • Maple
    a:= proc(n) option remember; local m, r;
          m, r:= n^n, 0;
          while m>0 do r:= r +irem(m, 2, 'm') od; r
        end:
    seq(a(n), n=0..100);  # Alois P. Heinz, Jul 21 2012
  • Mathematica
    Table[Count[IntegerDigits[n^n,2],1],{n,1,64}] (* Geoffrey Critzer, Sep 30 2013 *)
    Join[{1},Table[DigitCount[n^n,2,1],{n,100}]] (* Harvey P. Dale, Oct 13 2022 *)
  • PARI
    vector(66, n, b=binary((n-1)^(n-1)); sum(j=1, #b, b[j])) /* Joerg Arndt, Jul 21 2012 */
  • Python
    for n in range(300):
        c = 0
        b = n**n
        while b>0:
            c += b&1
            b//=2
        print(c, end=',')
    
  • Python
    def a(n): return bin(n**n)[2:].count('1')
    print([a(n) for n in range(65)]) # Michael S. Branicky, May 22 2021
    

Formula

a(n) = A000120(A000312(n)).
a(2^k)=1.
Showing 1-1 of 1 results.