Skip to content

Instantly share code, notes, and snippets.

@DanBrink91
Created March 10, 2014 22:49
Show Gist options
  • Save DanBrink91/9476080 to your computer and use it in GitHub Desktop.
Save DanBrink91/9476080 to your computer and use it in GitHub Desktop.
Pure number palindrome, no string or array
n = [121, 100, 1337, 404, 33]
def num_digits(n):
digits = 0
while n > 0:
n /= 10
digits+= 1
return digits
def is_palindrome(n):
digits = num_digits(n)
for x in xrange(digits/2):
if (n/(10**(digits-x-1)))%10 != (n/(10**(x)))%10:
return False
return True
#print is_palindrome(n[2])
for num in n:
print is_palindrome(num)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment