A306754 The bottom entry in the difference table of the positions of the ones in the binary representation of n.
0, 0, 1, 1, 2, 2, 1, 0, 3, 3, 2, 1, 1, -1, 0, 0, 4, 4, 3, 2, 2, 0, 1, 1, 1, -2, -1, -2, 0, 1, 0, 0, 5, 5, 4, 3, 3, 1, 2, 2, 2, -1, 0, -1, 1, 2, 1, 1, 1, -3, -2, -4, -1, -1, -2, -3, 0, 2, 1, 3, 0, -1, 0, 0, 6, 6, 5, 4, 4, 2, 3, 3, 3, 0, 1, 0, 2, 3, 2, 2, 2, -2
Offset: 0
Examples
For n = 59: - the binary representation of 59 is "111011", - so h = 5 and b_1 = 0, b_2 = 1, b_3 = 3, b_4 = 4, b_5 = 5, - the corresponding difference table is: 0 1 3 4 5 1 2 1 1 1 -1 0 -2 1 3 - hence a(59) = 3.
Links
- Rémy Sigrist, Table of n, a(n) for n = 0..16384
Programs
-
PARI
a(n) = { my (h=hammingweight(n), o=0, v=0); forstep (k=h-1, 0, -1, my (w=valuation(n, 2)); o += w; v += (-1)^k * binomial(h-1, k) * o; o++; n\=2^(1+w)); v };
Comments