OFFSET
1,6
COMMENTS
LINKS
Rémy Sigrist, Table of n, a(n) for n = 1..10000
Rémy Sigrist, Colored pin plot of the first 3 * 512 terms (where the color is function of the number h in the term d_h(n))
FORMULA
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
AUTHOR
Rémy Sigrist, Apr 26 2018
STATUS
approved