In [2]:
from __future__ import print_function
In [19]:
def is_palindrome(x):
return x == x[::-1]
In [20]:
def int_to_base(x, base):
if x == 0:
return ''
div, mod = divmod(x, base)
return int_to_base(div, base) + str(mod)
In [27]:
def which_bases(year):
bases = range(2, 9)
return [base for base in bases if is_palindrome(int_to_base(year, base))]
In [30]:
for year in range(2015, 2100):
bases = which_bases(year)
if bases:
print(year, which_bases(year))
In [ ]: