# Is there a number that is palindromal in both base 2 and base 3?

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?

• Our current year, 2017, is actually the smallest positive integer which is a palindrome in two consecutive bases - base 31 and 32. – mathematics2x2life Feb 3 '17 at 16:40
• @mathematics2x2life Can you tell me the source? – S.C.B. Feb 3 '17 at 16:42
• @S.C.B.: One place that cites it, though not as the smallest, is a-number-a-day.blogspot.com/2017/01/number-of-day-2017.html – Ross Millikan Feb 3 '17 at 16:49
• @S.C.B. I have not checked it for myself but it was claimed in this video: youtube.com/watch?v=z6jMU-AwX34 . But if it's on the internet it certainly must be true! – mathematics2x2life Feb 3 '17 at 17:42

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))