Largest palindrome product: Difference between revisions

Added 11l
(added AWK)
(Added 11l)
Line 13:
Find the largest palindrome made from the product of two n-digit numbers, where n ranges beyond 7,
<br><br>
 
=={{header|11l}}==
{{trans|Wren}}
 
<lang 11l>F reverse(=n)
V r = Int64(0)
L n > 0
r = n % 10 + r * 10
n I/= 10
R r
 
V po = Int64(10)
L(n) 2..7
V low = po * 9
po *= 10
V high = po - 1
V nextN = 0B
L(i) (high .< low - 1).step(-1)
V j = reverse(i)
V p = i * po + j
V k = high
L k > low
I k % 10 != 5
V l = p I/ k
I l > high
L.break
I p % k == 0
print(‘Largest palindromic product of two ’n‘-digit integers: ’k‘ x ’l‘ = ’p)
nextN = 1B
L.break
k -= 2
I nextN
L.break</lang>
 
{{out}}
<pre>
Largest palindromic product of two 2-digit integers: 99 x 91 = 9009
Largest palindromic product of two 3-digit integers: 993 x 913 = 906609
Largest palindromic product of two 4-digit integers: 9999 x 9901 = 99000099
Largest palindromic product of two 5-digit integers: 99979 x 99681 = 9966006699
Largest palindromic product of two 6-digit integers: 999999 x 999001 = 999000000999
Largest palindromic product of two 7-digit integers: 9998017 x 9997647 = 99956644665999
</pre>
 
=={{header|ALGOL 68}}==
Line 143 ⟶ 186:
Largest palindromic product of two 7-digit numbers: 9997647 * 9998017 = 99956644665999
</pre>
 
=={{header|AWK}}==
<lang AWK>
1,480

edits