OFFSET
1,2
LINKS
John Tyler Rascoe, Table of n, a(n) for n = 1..5000
EXAMPLE
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.
PROG
(Python)
def A161978(n):
b, i = bin(n)[2:], -1
r = b[::-1]
s = r.index('1')
while n:
i += 1
k = bin(n+i)[2:]
if k.find(b) != -1:
if k.find(r[s:]) != -1: break
return n+i # John Tyler Rascoe, Mar 11 2023
CROSSREFS
KEYWORD
AUTHOR
Leroy Quet, Jun 23 2009
EXTENSIONS
Corrected and extended by Sean A. Irvine, Nov 09 2009
STATUS
approved