Skip to content

Instantly share code, notes, and snippets.

@j605
Created January 23, 2012 09:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save j605/1662086 to your computer and use it in GitHub Desktop.
Save j605/1662086 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