Project Euler Question
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.
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.
<?php
function code_solution_4() {
$palindromes = [];
$answer = 0;
$largest_value = 999*999; // 998001
$largest_i = null;
$largest_j = null;
$i = 999;
$j = 999;
$iterations = 3000;
for($i = 999; $i > 99; $i--) {
for($j = 999; $j > 99; $j--) {
$product = $i*$j;
if(is_palindrome($product)) {
$palindromes[] = $product;
if($product > $answer) {
$answer = $product;
$largest_i = $i;
$largest_j = $j;
}
}
}
}
return "{$largest_i} * {$largest_j} = {$answer}";
//return implode(', ', $palindromes);
}