in reply to Largest palindrome number for a 3 digit product of 2 numbers

Hello, why to not just use reverse treating numbers as strings?

Also reversing numbers, from biggest to smallest, gives the answer sooner:

#!/usr/bin/perl use warnings; use strict; foreach my $num (reverse (999 ... 999*999)) { # I skipped the 'produc +t of two 3 digit integers' part: see LanX below if ($num eq reverse $num){ print "largest palindrome is: $num\n"; exit; } } # or just: perl -we "for(reverse 999 .. 999*999){($_ eq reverse $_ )?(print qq(la +rgest palindrome $_)and exit 0 ): 1}" largest palindrome 997799

L*

There are no rules, there are no thumbs..
Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.

Replies are listed 'Best First'.
Re^2: Largest palindrome number for a 3 digit product of 2 numbers
by LanX (Saint) on Jul 05, 2017 at 08:32 UTC
    997799 is the product of two 3 digit integers?

    Cheers Rolf
    (addicted to the Perl Programming Language and ☆☆☆☆ :)
    Je suis Charlie!