login

Reminder: The OEIS is hiring a new managing editor, and the application deadline is January 26.

a(n) = the smallest positive integer that when written in binary contains both binary n and {the string formed from the reversal of the binary digits of n, with leading 0's removed} as (possibly overlapping) substrings.
1

%I #16 Jul 22 2023 21:04:41

%S 1,2,3,4,5,6,7,8,9,10,27,12,27,14,15,16,17,18,51,20,21,45,93,24,51,90,

%T 27,28,93,30,31,32,33,34,99,36,165,102,231,40,165,42,107,108,45,93,

%U 189,48,99,306,51,180,107,54,119,56,231,186,119,60,189,62,63,64,65,66,195

%N a(n) = the smallest positive integer that when written in binary contains both binary n and {the string formed from the reversal of the binary digits of n, with leading 0's removed} as (possibly overlapping) substrings.

%H John Tyler Rascoe, <a href="/A161978/b161978.txt">Table of n, a(n) for n = 1..5000</a>

%e 22 in binary is 10110. The binary string with the smallest numerical value that contains both 10110 and its reversal (with the leading 0 removed), 1101, is 101101. a(22) is the numerical value (written in decimal) of this binary string, which is 45.

%o (Python)

%o def A161978(n):

%o b,i = bin(n)[2:],-1

%o r = b[::-1]

%o s = r.index('1')

%o while n:

%o i += 1

%o k = bin(n+i)[2:]

%o if k.find(b) != -1:

%o if k.find(r[s:]) != -1: break

%o return n+i # _John Tyler Rascoe_, Mar 11 2023

%Y Cf. A030101.

%K base,look,nonn

%O 1,2

%A _Leroy Quet_, Jun 23 2009

%E Corrected and extended by _Sean A. Irvine_, Nov 09 2009