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
for (k in high..low+1) {
// k can't be even nor end in 5 to produce a product ending in 9
var l = p / k
var k = high
if (l > high) break
while (k > low) {
if (p % k == 0) {
if (k % 10 != 5) {
System.print("%(k) x %(l) = %(p)")
var l = p / k
nextN = true
if (l > high) break
break
if (p % k == 0) {
System.print("%(k) x %(l) = %(p)")
nextN = true
break
}
}
}
k = k - 2
}
}
if (nextN) break
if (nextN) break