login
A303548
For any n > 0 and h > 0, let d_h(n) be the distance from n to the nearest number with Hamming weight at most h; a(n) = Sum_{i > 0} d_i(n).
3
0, 0, 1, 0, 1, 2, 2, 0, 1, 2, 4, 4, 4, 4, 3, 0, 1, 2, 4, 4, 6, 8, 9, 8, 8, 8, 9, 8, 7, 6, 4, 0, 1, 2, 4, 4, 6, 8, 9, 8, 10, 12, 15, 16, 17, 18, 18, 16, 16, 16, 17, 16, 17, 18, 18, 16, 15, 14, 14, 12, 10, 8, 5, 0, 1, 2, 4, 4, 6, 8, 9, 8, 10, 12, 15, 16, 17, 18
OFFSET
1,6
COMMENTS
For any n > 0 and h >= A000120(n), d_h(n) = 0, hence the series in the name contains only finitely many nonzero terms and is well defined.
See also A303545 for a similar sequence.
LINKS
FORMULA
a(n) = 0 iff n is a power of 2.
Apparently, a(2 * n) = 2 * a(n).
a(n) >= A053646(n) (as d_1 = A053646).
EXAMPLE
For n = 42:
- d_1(n) = |42 - 32| = 10,
- d_2(n) = |42 - 40| = 2,
- d_h(n) = 0 for any h >= 3,
- hence a(42) = 10 + 2 = 12.
PROG
(PARI) a(n) = my (v=0, h=hamming weight(n)); for (d=0, oo, my (o=min(hamming weight(n-d), hamming weight(n+d))); if (o<h, v += d*(h-o); h=o); if (o<=1, return (v)))
CROSSREFS
KEYWORD
nonn,base,look
AUTHOR
Rémy Sigrist, Apr 26 2018
STATUS
approved