aboutsummaryrefslogtreecommitdiff
path: root/julia/004-largest_palindrome_product.jl
blob: 308ce480804bea4d58bd6939334913f1448b18d0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
###
# Largest palindrome product
# Problem 4
#
# A palindromic number reads the same both ways. The largest palindrome made from the
# product of two 2-digit numbers is 9009 = 91 × 99.
# Find the largest palindrome made from the product of two 3-digit numbers.
###

function is_palindrom(n::Integer)::Bool
    s = string(n)
    s == reverse(s)
end

result = maximum(x * y for x in 100:999, y in 100:999 if is_palindrom(x * y))
println(result)