login
Call any positive integer that is a palindrome when written in binary a "binary palindrome". a(n) = the smallest binary palindrome such that a(n)*(the n-th binary palindrome) is not a binary palindrome.
2

%I #28 Jan 10 2023 08:32:21

%S 27,5,5,9,5,17,5,3,5,33,3,7,5,65,9,5,3,15,3,3,5,129,3,5,3,27,3,5,5,

%T 257,17,5,3,5,5,3,3,27,3,3,3,5,3,3,5,513,3,9,3,5,3,3,3,27,7,3,3,5,3,5,

%U 5,1025,33,5,3,9,5,3,3,5,5,5,3,3,3,3,3,27,3,3,5,3,3,3,3,5,3,3,3,5,3,3,5

%N Call any positive integer that is a palindrome when written in binary a "binary palindrome". a(n) = the smallest binary palindrome such that a(n)*(the n-th binary palindrome) is not a binary palindrome.

%C There are no palindromes that work for a(1) and a(2), since the first positive binary palindromes are 0 and 1.

%H Robert Israel, <a href="/A175240/b175240.txt">Table of n, a(n) for n = 3..10000</a>

%F A006995(n)*a(n) = A175241(n), a non-palindrome when written in binary.

%e For n=7, A006995(7) = 15 (1111 in binary). And checking 15*A006995(i) for i>=0, we get 15*0=0, 15*1=15, 15*3=45 that belong to A006995, but 15*5=75 does not, so a(7)=5.

%p bp:= proc(n) local L; L:= convert(n,base,2); L = ListTools:-Reverse(L) end proc:

%p Bp:= select(bp, [$0..10^6]): nBp:= nops(Bp):

%p f:= proc(n) local i;

%p for i from 3 to nBp do

%p if not bp(Bp[i]*Bp[n]) then return Bp[i] fi

%p od;

%p FAIL

%p end proc:

%p map(f, [$3..100]); # _Robert Israel_, Jan 09 2023

%o (PARI) a(n) = my(p=A006995(n), k=1); while(is_A006995(p*A006995(k)), k++); A006995(k); \\ using A006995 PARI codes; _Michel Marcus_, Jan 09 2023

%o (Python)

%o from itertools import count, islice, product

%o def is_bin_pal(n): return (b:=bin(n)[2:]) == b[::-1]

%o def bin_pals(): # generator of positive binary palindromes in base 10

%o yield 1

%o digits, midrange = 2, [[""], ["0", "1"]]

%o for digits in count(2):

%o for p in product("01", repeat=digits//2-1):

%o left = "1"+"".join(p)

%o for middle in midrange[digits%2]:

%o yield int(left + middle + left[::-1], 2)

%o def agen(): # generator of terms

%o g = bin_pals(); next(g)

%o for n in count(3):

%o bn = next(g)

%o yield next(k for k in bin_pals() if not is_bin_pal(k*bn))

%o print(list(islice(agen(), 93))) # _Michael S. Branicky_, Jan 09 2023

%Y Cf. A006995, A175241.

%K base,nonn

%O 3,1

%A _Leroy Quet_, Mar 11 2010

%E Extended by _Ray Chandler_, Mar 13 2010

%E Offset 3 from _Michel Marcus_, Jan 09 2023