

A162749


Write the nth (odd) binary palindrome in binary. If there are an even number of digits, then combine the middle two digits into one digit. If there are an odd number of digits, then double the middle digit. a(n) is the decimal result.


2



3, 1, 9, 15, 5, 7, 33, 45, 51, 63, 17, 21, 27, 31, 129, 153, 165, 189, 195, 219, 231, 255, 65, 73, 85, 93, 99, 107, 119, 127, 513, 561, 585, 633, 645, 693, 717, 765, 771, 819, 843, 891, 903, 951, 975, 1023, 257, 273, 297, 313, 325, 341, 365, 381, 387, 403, 427
(list;
graph;
refs;
listen;
history;
text;
internal format)



OFFSET

1,1


COMMENTS

a(n) is the A162750(n)th (odd) binary palindrome written in decimal. This sequence (A162749) is a permutation of the (odd) positive integers that are each palindromes when written in base 2.


LINKS

Rémy Sigrist, Table of n, a(n) for n = 1..10000
Rémy Sigrist, Table of n, a(n) and binary palindromes for n = 1..10000


EXAMPLE

The 8th binary palindrome is 21, which is 10101 in binary. Since there are an odd number of digits, double the middle digit to get 101101. a(8) is this written in decimal, which is 45.
51, the 13th palindrome when written in binary, is 110011 when written in base 2. Since this has an even number of digits, combine the middle two digits into one digit to get 11011. a(13) is the decimal equivalent of this, which is 27.


PROG

(PARI) a(n) = my (p=A006995(n+1)); my (l=#binary(p), l2=2^ceil(l/2)); if (l%2==0, (p\(l2*2))*l2+(p%l2), (p\(l2\2))*l2+(p%l2)) \\ Rémy Sigrist, Nov 08 2018


CROSSREFS

Cf. A006995, A162750.
Sequence in context: A318391 A157399 A288852 * A094796 A056843 A076806
Adjacent sequences: A162746 A162747 A162748 * A162750 A162751 A162752


KEYWORD

base,nonn


AUTHOR

Leroy Quet, Jul 12 2009


EXTENSIONS

More terms from Rémy Sigrist, Nov 08 2018


STATUS

approved



