A343029 Number of 1-bits in the binary expansion of n which have an even number of 0-bits at less significant bit positions.
0, 1, 0, 2, 1, 1, 0, 3, 0, 2, 1, 2, 2, 1, 0, 4, 1, 1, 0, 3, 1, 2, 1, 3, 0, 3, 2, 2, 3, 1, 0, 5, 0, 2, 1, 2, 2, 1, 0, 4, 1, 2, 1, 3, 2, 2, 1, 4, 2, 1, 0, 4, 1, 3, 2, 3, 0, 4, 3, 2, 4, 1, 0, 6, 1, 1, 0, 3, 1, 2, 1, 3, 0, 3, 2, 2, 3, 1, 0, 5, 1, 2, 1, 3, 2, 2, 1
Offset: 0
Examples
n = 860 = binary 1101011100 ^^ ^^^ a(n) = 5
Links
- Kevin Ryde, Table of n, a(n) for n = 0..8192
Programs
-
PARI
a(n) = my(t=1,ret=0); for(i=0,if(n,logint(n,2)), if(bittest(n,i), ret+=t, t=!t)); ret;
-
Python
def a(n): b = bin(n)[2:] return sum(bi=='1' and b[i:].count('0')%2==0 for i, bi in enumerate(b)) print([a(n) for n in range(87)]) # Michael S. Branicky, Apr 03 2021
Formula
a(2*n) = A000120(n) - a(n).
a(2*n+1) = a(n) + 1.
G.f. satisfies g(x) = (x-1)*g(x^2) + A000120(x^2) + x/(1-x^2).
G.f.: (1/2) * Sum_{k>=0} x^(2^k)*( (1-x^(2^k))/(1-x) + Prod_{j=0..k-1} x^(2^j)-1 )/( 1-x^(2*2^k) ).
a(2^n - 1) = n. - Michael S. Branicky, Apr 03 2021
Comments