TheAlgorithms-Python/Project Euler/Problem 04/sol1.py

17 lines
522 B
Python
Raw Normal View History

2017-10-24 23:41:19 +08:00
'''
Problem:
A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 x 99.
Find the largest palindrome made from the product of two 3-digit numbers which is less than N.
'''
from __future__ import print_function
2017-10-24 23:41:19 +08:00
n=int(input())
for i in range(n-1,10000,-1):
temp=str(i)
if(temp==temp[::-1]):
j=999
while(j!=99):
if((i%j==0) and (len(str(i/j))==3)):
print(i)
2017-10-24 23:41:19 +08:00
exit(0)
j-=1