-
Notifications
You must be signed in to change notification settings - Fork 0
/
problem004.py
32 lines (23 loc) · 881 Bytes
/
problem004.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
def is_palindromic(number):
is_palindromic = False
number_str = ''.join(map(str, str(number)))
number_str_left_to_right = list(number_str)
number_str_right_to_left = number_str[::-1]
for left,right in zip(number_str_left_to_right,number_str_right_to_left):
if left !=right:
is_palindromic = False
break
else:
is_palindromic = True
return is_palindromic
def main(n):
palindromos = []
for i in range(pow(10,n),pow(10,n+1)):
for j in range(pow(10,n),pow(10,n+1)):
producto = i*j
if is_palindromic(producto):
palindromos.append(producto)
maximo = max(palindromos)
print("El máximo número palindrómico formado por la multiplicación de 2 número de tres cifras es: {}".format(maximo))
return maximo
main(2)