OFFSET
1,2
COMMENTS
Even numbers cannot be palindromic in base 2 (unless leading zeros are considered), that's why we search for odd numbers 2n-1 their smallest multiple k(2n-1) which is palindromic in base 2. Obviously this must always be odd.
LINKS
Harvey P. Dale, Table of n, a(n) for n = 1..1000
FORMULA
a(n) = (2n-1)*A141707(n).
MATHEMATICA
pal2[n_]:=Module[{k=1}, While[IntegerDigits[k n, 2] != Reverse[ IntegerDigits[ k n, 2]], k++]; k n]; pal2/@Range[1, 121, 2] (* Harvey P. Dale, Feb 29 2012 *)
PROG
(PARI) A141708(n, L=10^9)={ n=2*n-1; forstep(k=1, L, 2, binary(k*n)-vecextract(binary(k*n), "-1..1") || return(k*n))}
(Haskell)
a141708 n = a141707 n * (2 * n - 1) -- Reinhard Zumkeller, Apr 20 2015
(Python)
def binpal(n): b = bin(n)[2:]; return b == b[::-1]
def a(n):
m = 2*n - 1
km = m
while not binpal(km): km += m
return km
print([a(n) for n in range(1, 55)]) # Michael S. Branicky, Mar 20 2022
CROSSREFS
KEYWORD
base,easy,nice,nonn
AUTHOR
M. F. Hasler, Jul 17 2008
STATUS
approved