Largest palindrome product: Difference between revisions
Content added Content deleted
(Added XPL0 example.) |
(→{{header|Wren}}: Optimized inner loop - run time now less than 0.7 seconds.) |
||
Line 165: | Line 165: | ||
// we assume here the palindromes will end in 9 |
// we assume here the palindromes will end in 9 |
||
if (p % 10 != 9) continue |
if (p % 10 != 9) continue |
||
// k can't be even nor end in 5 to produce a product ending in 9 |
|||
var k = high |
|||
while (k > low) { |
|||
if ( |
if (k % 10 != 5) { |
||
var l = p / k |
|||
if (l > high) break |
|||
if (p % k == 0) { |
|||
System.print("%(k) x %(l) = %(p)") |
|||
nextN = true |
|||
break |
|||
} |
|||
} |
} |
||
k = k - 2 |
|||
} |
} |
||
if (nextN) break |
if (nextN) break |