function is_palindrome(s::AbstractString)
= length(s)
l
for i ∈ 1:fld(l, 2)
!= s[l + 1 - i] && return false
s[i] end
return true
end;
is_palindrome(n::Integer) = is_palindrome(string(n));
function p4()
= 0, 0, 0
a, b, largest_palindrome
for x ∈ reverse(100:999)
for y ∈ reverse(100:999)
< y && continue
x = x * y
p < largest_palindrome && break # we can break the inner loop, because the next product is going to be even lesser
p if is_palindrome(p)
= x, y, p
a, b, largest_palindrome end
end
end
# if no palindrome was found:
return (a, b, a*b)
end;
p4()
(993, 913, 906609)