A303534 Amount by which n exceeds the largest binary palindrome less than or equal to n.
0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 2, 3, 4, 5, 0, 1, 0, 1, 2, 3, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 0, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 0, 1, 0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3
Offset: 0
Examples
The largest binary palindrome that doesn't exceed 30 is 27 (11011 r2). 30 - 27 = 3, so a(30) = 3.
Links
Crossrefs
Programs
-
PARI
isA006995(n) = Vecrev(n=binary(n))==n; a(n) = {my(k=0); while(!isA006995(n-k), k++); k;} \\ Altug Alkan, Apr 25 2018
Formula
a(n) = n - A206913(n).
Extensions
More terms from Altug Alkan, Apr 25 2018