A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is
\[\begin{align}
9009 = 91 \times 99
\end{align}\]
Find the largest palindrome made from the product of two 3-digit numbers.
Solution
functionisPalindrome(num::Int64) x =Vector{Int}(undef, 18)for i ineachindex(x) x[i] = num %10 num ÷=10end y = x[1:findlast(i -> i >0, x)]for i ineachindex(y)if !(y[i] == y[end- i +1])returnfalseendendreturntrueendfunctionmain() current =0 idx = (0, 0)for i in999:-1:900for j in999:-1:900new= i*jif (new> current &&isPalindrome(new)) current =new idx = (i, j)endendendprintln("$(current) = $(idx[1]) x $(idx[2])")endmain()