re: Project Euler #4 - Largest Palindrome Product VIEW POST

FULL DISCUSSION
 

Am still able to just copy and paste from my Euler GitHub repo. 😂

PHP again

$largestThreeDig = 999;
$largestPalindrome = 0;
for($l = $largestThreeDig; $l > 0 && $l * $largestThreeDig > $largestPalindrome; $l--) {
    for($p = $l * $largestThreeDig; $p > $largestPalindrome; $p -= $l) {
        if((string)$p === strrev((string)$p)) {
            $largestPalindrome = $p;
        }
    }
}
 echo "Largest Palindrome: $largestPalindrome\n";
 

This is another solution that I consider working in this particular case (3 digits) but not actually correct in the general case. I explained it here: dev.to/maxart2501/comment/b9me

code of conduct - report abuse