loading
open in
main.py
1
2
3
4
5
6
7
8
9
10
11
def is_palindromic(n): n=str(n); return n==n[::-1]

pmax, L = 0, 10000000000
for i in range(99999, 90000, -1):
    for j in range(99990, 90000, (-11 if i%11 else -1)):
        p = i*j
        if p < pmax: break
        if p < L and is_palindromic(p): x, y, pmax = i, j, p
 
print "Largest palindome product = %3d x %3d = %6d" % (x, y, pmax) \
  if pmax > 0 else "None found."
Python 2.7.10 (default, Jul 14 2015, 19:46:27) [GCC 4.8.2] on linux