Skip to content

Instantly share code, notes, and snippets.

@gsathya
Forked from j605/k2.py
Created January 23, 2012 09:48
Show Gist options
  • Save gsathya/1662116 to your computer and use it in GitHub Desktop.
Save gsathya/1662116 to your computer and use it in GitHub Desktop.
simple coding question
def change_base(n, b):
rem = ''
while n > 0:
rem += str((n % b))
n /= b
return rem[::-1]
def pal_base(n):
base = 2
while 1:
num = change_base(n, base)
if num == num[::-1]:
return base
base += 1
t = int(raw_input())
i = 0
N = []
while i < t:
N.append(int(raw_input()))
i += 1
for i in N:
print pal_base(i)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment