[ create a new paste ] login | about

Link: http://codepad.org/ZhmC1VPT    [ raw code | output | fork ]

tenten321 - Python, pasted on Dec 22:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
n=999*999
pal=0

def is_pal(n):
  nlist = list(str(n))
  front = nlist[:int(len(nlist)/2)]
  nlist.reverse()
  back = nlist[:int(len(nlist)/2)]
  if front == back:
    print str(n) + " is a palindrome."
    return 1
  else:
    return 0

while pal == 0:
  if n%11 == 0 and is_pal(n):
    pal = n
  n -= 1


Output:
1
997799 is a palindrome.


Create a new paste based on this one


Comments: