-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproblem4.py
More file actions
24 lines (24 loc) · 878 Bytes
/
problem4.py
File metadata and controls
24 lines (24 loc) · 878 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#palindromes' number and his factors list
palindromes_and_factors = []
#the product of tow 3-digits
for i in range(100, 1000):
for j in range(100, 1000):
product = j * i
#if product == revarse product
if str(product) == str(product)[::-1]:
palindromes_and_factors.append([i, j, product])
#len palindromes for search in palindromes-list
len_p = len(palindromes)
#the list of palindromes' numbers
palindromes = []
#serch in palindromes_and_factors-list
for n in range(len_p):
#append palindrome number to palindromes-list
palindromes.append(palindromes_and_factors[n][2])
#sort palindromes-list for find larges palindrome number
palindromes.sort()
print(palindromes[-1])
for i in range(len_p):
#find larges palindrome and factors
if palindromes[-1] == palindromes_and_factors[i][2]:
print(palindromes_and_factors[i])