-
Notifications
You must be signed in to change notification settings - Fork 0
/
Euler_project_4.py
30 lines (26 loc) · 918 Bytes
/
Euler_project_4.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
# -*- coding: utf-8 -*-
"""
Created on Tue Jul 9 17:08:27 2019
@author: aurelio
"""
'''
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.
'''
numberA = 0
numberB = 0
previousPalindricNumber = 0
for i in range(100,1000):
for j in range(100,1000):
palindricNumber = i*j
stringNumber = str(palindricNumber)
index = 0
for k in range(len(stringNumber)):
if stringNumber[k] == stringNumber[len(stringNumber)-1-k]:
index+=1
if index == len(stringNumber)-1:
if palindricNumber > previousPalindricNumber:
previousPalindricNumber = palindricNumber
numberA = i
numberB = j
print(numberA*numberB)