Project Euler problem 4 sol 2 small fix (#632)

This commit is contained in:
Sanders Lin 2019-02-11 10:42:43 +08:00 committed by John Law
parent dbe3f062ad
commit 42d42c3136

View File

@ -4,16 +4,14 @@ A palindromic number reads the same both ways. The largest palindrome made from
Find the largest palindrome made from the product of two 3-digit numbers which is less than N. Find the largest palindrome made from the product of two 3-digit numbers which is less than N.
''' '''
from __future__ import print_function from __future__ import print_function
arr = [] n = int(input().strip())
for i in range(999,100,-1): answer = 0
for j in range(999,100,-1): for i in range(999,99,-1): #3 digit nimbers range from 999 down to 100
for j in range(999,99,-1):
t = str(i*j) t = str(i*j)
if t == t[::-1]: if t == t[::-1] and i*j < n:
arr.append(i*j) answer = max(answer,i*j)
arr.sort() print(answer)
n=int(input())
for i in arr[::-1]:
if(i<n):
print(i)
exit(0) exit(0)