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

TOP OF THREAD FULL DISCUSSION
re: I'm working backwards through the range of numbers beginning with '999.' Hence the extra verbosity in the block with the call to the downto method...

The problem here is that the products you're getting aren't ordered. Which means that if you get a palindrome, you cannot be sure it's the largest.

In fact, I run your code and I got 999 * 91 = 90909, which is not correct. Even if you limit your range to 999 to 100 (we're looking for 3-digit factors after all), you'd get 995 * 583 = 580085. But the largest palindrome is 993 * 913 = 906609, which comes after the others.

code of conduct - report abuse