login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A161502 a(n) is the smallest number of binary digits that when appended to the right side of the binary representation of n, forms a binary palindrome. 2
0, 1, 0, 1, 0, 2, 0, 1, 0, 1, 2, 2, 1, 3, 0, 1, 0, 2, 3, 3, 0, 1, 2, 2, 1, 2, 0, 3, 2, 4, 0, 1, 0, 3, 4, 1, 3, 2, 3, 3, 2, 1, 4, 4, 0, 1, 2, 2, 1, 3, 0, 4, 1, 2, 3, 3, 2, 3, 1, 4, 3, 5, 0, 1, 0, 4, 5, 2, 4, 3, 4, 4, 0, 2, 5, 1, 4, 2, 3, 3, 2, 1, 5, 5, 0, 3, 4, 4, 3, 4, 2, 5, 0, 1, 2, 2, 1, 4, 0, 2, 4, 3, 4, 4, 3 (list; graph; refs; listen; history; text; internal format)
OFFSET
1,6
LINKS
EXAMPLE
11 (decimal) in binary is 1011. Appending 01 to the right side of 1011 forms the binary palindrome 101101, which is 45 in decimal. Since two binary digits is the smallest number of digits that need to be appended on the right side of binary n to form a palindrome, then a(11) = 2. (Note that 45 is not the smallest positive number that when represented in binary is a palindrome and contains 1011 as a substring. That would instead be 11011 {binary} = 27 {decimal}.)
PROG
(Python)
def A161502(n):
s = bin(n)[2:]
if s == s[::-1]:
return 0
for i in range(1, len(s)):
if s[i:] == s[-1:i-1:-1]:
return i # Chai Wah Wu, Aug 27 2021
CROSSREFS
Sequence in context: A035698 A230204 A325592 * A279628 A241914 A324393
KEYWORD
base,nonn
AUTHOR
Leroy Quet, Jun 11 2009
EXTENSIONS
More terms from Sean A. Irvine, Sep 27 2009
STATUS
approved

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified March 28 14:21 EDT 2024. Contains 371254 sequences. (Running on oeis4.)