The number of palindromes that have the same value when read from either the left or right is called the number of palindromes. Of the number of palindromes represented by the product of two-digit numbers, the maximum is 9009 = 91 x 99.
Now, find the maximum number of palindromes represented by the product of three-digit numbers. http://odz.sakura.ne.jp/projecteuler/index.php?cmd=read&page=Problem%204
I solved it instinctively. I have not confirmed whether it is the correct answer.
(i,j)=(999,999)
max=1
while i>0:
while j>0:
k = i*j
if k <= max: break
if str(k)==str(k)[::-1]: max=k
j -= 1
(i,j)=(i-1,999)
print max
If there are other possibilities, 1. Create a 6-digit palindromic number with 3 digits + 3 digits in reverse order, and check whether it is represented by 3 digits x 3 digits. 2. Using list comprehension notation I wonder if there are two points. Let's try it later.
Recommended Posts