You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
455 B
24 lines
455 B
9 years ago
|
import math
|
||
|
|
||
|
|
||
|
def isPalindrome(number):
|
||
|
num_str = str(number)
|
||
|
|
||
|
if len(num_str) % 2 != 0:
|
||
|
return False
|
||
|
|
||
|
for i in range(0, int(len(num_str) / 2)):
|
||
|
if num_str[i] != num_str[len(num_str) - (i + 1)]:
|
||
|
return False
|
||
|
|
||
|
return True
|
||
|
|
||
|
|
||
|
largest_number = 0
|
||
|
|
||
|
for x in range(0, 999):
|
||
|
for y in range(0, 999):
|
||
|
if isPalindrome(x * y) and largest_number < x * y:
|
||
|
largest_number = x * y
|
||
|
|
||
|
print(largest_number)
|