A301572 a(n) = distance from n to nearest Fibbinary number (A003714).
0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 1, 2, 3, 2, 1, 0, 0, 0, 1, 0, 0, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 1, 2, 3, 2, 1, 0, 0, 0, 1, 0, 0
Offset: 0
Examples
a(12) = a(14) = 2 because 10 is the nearest Fibbinary number to 12 and 16 is the nearest Fibbinary number to 14.
Links
Crossrefs
Cf. A003714.
Programs
-
PARI
a(n) = for (k=0, oo, if (bitand(n-k, 2*(n-k))==0 || bitand(n+k, 2*(n+k))==0, return (k)))
Formula
a(n) = 0 iff n belongs to A003714.
0 <= 2 * a(n) - a(2 * n) <= 1.
Comments