Project Euler Problem 4
- Brodie Mooy
- Jan 6
- 1 min read

Finding the Largest Palindrome Product with Python
Project Euler Problem 4 asks us to find the largest palindrome made from the product of two 3-digit numbers. Let's solve it with Python.
The Problem
A palindromic number reads the same both ways - like 9009 or 906609. We need to multiply all combinations of 3-digit numbers and identify the largest palindrome in those products.
The Solution
python
palindrome_product = []
for i in range(0,999):
for j in range(0,999):
g = str(i*j)
g1 = g[::-1]
if g == g1:
palindrome_product.append(int(g))
print(max(palindrome_product))How It Works
Nested loops iterate through numbers from 0 to 998
String conversion converts each product to a string g
String reversal using Python's slice notation [::-1] creates the reversed version g1
Palindrome check compares g with g1
Track results by appending palindromes to the list and finding the maximum
The Result
The largest palindrome from the product of two numbers in this range is 906609.



Comments