I manually checked the first 20 base 2 palindromes and I did not find any base 3 palindromes among them.
Is there any definite way of determining this? What about other bases?
I manually checked the first 20 base 2 palindromes and I did not find any base 3 palindromes among them.
Is there any definite way of determining this? What about other bases?
Note that what you are looking for is basically the sequence $\text{A0607092}$ on OEIS.
However, examining the comments on the OEIS page, it seems unlikely that we will find a closed form for all such $n$ that satisfies the condition. Also, it seems that such $n$ grows very quickly. You probably should just write a code.
A collections of code can be seen here. For example, you can code this on Python by
from itertools import islice
digits = "0123456789abcdefghijklmnopqrstuvwxyz"
def baseN(num,b):
if num == 0: return "0"
result = ""
while num != 0:
num, d = divmod(num, b)
result += digits[d]
return result[::-1] # reverse
def pal2(num):
if num == 0 or num == 1: return True
based = bin(num)[2:]
return based == based[::-1]
def pal_23():
yield 0
yield 1
n = 1
while True:
n += 1
b = baseN(n, 3)
revb = b[::-1]
#if len(b) > 12: break
for trial in ('{0}{1}'.format(b, revb), '{0}0{1}'.format(b, revb),
'{0}1{1}'.format(b, revb), '{0}2{1}'.format(b, revb)):
t = int(trial, 3)
if pal2(t):
yield t
for pal23 in islice(pal_23(), 6):
print(pal23, baseN(pal23, 3), baseN(pal23, 2))