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”).

A214561
Number of 1's in binary expansion of n^n.
1
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,4
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
LINKS
FORMULA
a(n) = A000120(A000312(n)).
a(2^k)=1.
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 *)
PROG
(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
(PARI) vector(66, n, b=binary((n-1)^(n-1)); sum(j=1, #b, b[j])) /* Joerg Arndt, Jul 21 2012 */
CROSSREFS
KEYWORD
nonn
AUTHOR
Alex Ratushnyak, Jul 21 2012
STATUS
approved