A370427 a(n) is the least k >= 0 such that n OR k is a binary palindrome (where OR denotes the bitwise OR operator).
0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 5, 4, 3, 2, 1, 0, 1, 0, 9, 8, 1, 0, 9, 8, 3, 2, 1, 0, 3, 2, 1, 0, 1, 0, 17, 16, 9, 8, 25, 24, 5, 4, 21, 20, 1, 0, 17, 16, 3, 2, 1, 0, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 0, 33, 32, 17, 16, 49, 48, 1, 0, 33, 32, 17, 16, 49, 48
Offset: 0
Examples
The first terms, alongside the corresponding binary expansions, are: n a(n) bin(n) bin(a(n)) bin(n OR a(n)) -- ---- ------ --------- -------------- 0 0 0 0 0 1 0 1 0 1 2 1 10 1 11 3 0 11 0 11 4 1 100 1 101 5 0 101 0 101 6 1 110 1 111 7 0 111 0 111 8 1 1000 1 1001 9 0 1001 0 1001 10 5 1010 101 1111 11 4 1011 100 1111 12 3 1100 11 1111 13 2 1101 10 1111 14 1 1110 1 1111 15 0 1111 0 1111
Links
Programs
-
Mathematica
A370427[n_] := With[{r = IntegerReverse[n, 2]}, r - BitAnd[n, r]]; Array[A370427, 2^7, 0] (* Paolo Xausa, Feb 20 2024 *)
-
PARI
a(n) = my (r = fromdigits(Vecrev(binary(n)), 2)); r - bitand(n, r)
Comments