A330717 a(n) is the greatest binary palindrome of the form floor(n/2^k) with k >= 0.
0, 1, 1, 3, 1, 5, 3, 7, 1, 9, 5, 5, 3, 3, 7, 15, 1, 17, 9, 9, 5, 21, 5, 5, 3, 3, 3, 27, 7, 7, 15, 31, 1, 33, 17, 17, 9, 9, 9, 9, 5, 5, 21, 21, 5, 45, 5, 5, 3, 3, 3, 51, 3, 3, 27, 27, 7, 7, 7, 7, 15, 15, 31, 63, 1, 65, 33, 33, 17, 17, 17, 17, 9, 73, 9, 9, 9, 9
Offset: 0
Examples
The first terms, alongside the binary representations of n and of a(n), are: n a(n) bin(n) bin(a(n)) -- ---- ------ --------- 0 0 0 0 1 1 1 1 2 1 10 1 3 3 11 11 4 1 100 1 5 5 101 101 6 3 110 11 7 7 111 111 8 1 1000 1 9 9 1001 1001 10 5 1010 101 11 5 1011 101
Links
Programs
-
PARI
a(n,b=2) = { my (d=digits(n,b)); forstep (w=#d, 1, -1, my (h=d[1..w]); if (h==Vecrev(h), return (fromdigits(h, b)))); return (0) }
Comments