@betaProjects/

Project Euler 4

Python 2.7

Project Euler 4: Find the largest palindrome product

fork
loading
Files
  • main.py
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."