- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProblem4.py
More file actions
Latest commit
24 lines (18 loc) · 668 Bytes
/
Copy pathProblem4.py
File metadata and controls
24 lines (18 loc) · 668 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
"""
@author:mc-es
Problem 4
A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99.
Find the largest palindrome made from the product of two 3-digit numbers.
Answer: 906609
"""
defis_palindrome(n):
returnstr(n) ==str(n)[::-1]
deflargest_palindrome():
largest_palindrome=0
foriinrange(999, 99, -1):
forjinrange(999, 99, -1):
product=i*j
ifis_palindrome(product) andproduct>largest_palindrome:
largest_palindrome=product
returnlargest_palindrome
print(largest_palindrome())