aboutsummaryrefslogtreecommitdiff
path: root/julia/004-largest_palindrome_product.jl
diff options
context:
space:
mode:
Diffstat (limited to 'julia/004-largest_palindrome_product.jl')
-rw-r--r--julia/004-largest_palindrome_product.jl16
1 files changed, 3 insertions, 13 deletions
diff --git a/julia/004-largest_palindrome_product.jl b/julia/004-largest_palindrome_product.jl
index 32be760..308ce48 100644
--- a/julia/004-largest_palindrome_product.jl
+++ b/julia/004-largest_palindrome_product.jl
@@ -7,20 +7,10 @@
# Find the largest palindrome made from the product of two 3-digit numbers.
###
-function is_palindrom(n)
+function is_palindrom(n::Integer)::Bool
s = string(n)
s == reverse(s)
end
-
-top = -1
-
-for x in 100:999
- for y in 100:999
- if is_palindrom(x * y)
- global top = max(top, x * y)
- end
- end
-end
-
-println(top)
+result = maximum(x * y for x in 100:999, y in 100:999 if is_palindrom(x * y))
+println(result)