// Function to check if a number is a palindrome
function isPalindrome($num) {
$temp = $num;
$rev = 0;
while ($temp > 0) {
$rev = $rev * 10 + ($temp % 10);
$temp = (int)($temp / 10);
}
return $rev === $num;
}
// Function to find the largest palindrome from the product of two 2-digit numbers
function getLargestPalindromeOfTwo2DigitNumbers() {
$largestPalindrome = 0;
for ($i = 10; $i < 100; $i++) {
for ($j = 10; $j < 100; $j++) {
$product = $i * $j;
if (isPalindrome($product) && $product > $largestPalindrome) {
$largestPalindrome = $product;
}
}
}
return $largestPalindrome;
}
echo "The largest palindrome made from the product of two 2-digit numbers is: " . getLargestPalindromeOfTwo2DigitNumbers() . "\n";
/*
run:
The largest palindrome made from the product of two 2-digit numbers is: 9009
*/