Solution for problem 4 in Julia
This commit is contained in:
parent
30b3be58a0
commit
1b6922fe6a
33
src/Julia/Problem004.jl
Normal file
33
src/Julia/Problem004.jl
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
#=
|
||||||
|
Created on 17 Jun 2021
|
||||||
|
|
||||||
|
@author: David Doblas Jiménez
|
||||||
|
@email: daviddoji@pm.me
|
||||||
|
|
||||||
|
Solution for Problem 4 of Project Euler
|
||||||
|
https://projecteuler.net/problem=4
|
||||||
|
=#
|
||||||
|
|
||||||
|
function Problem4()
|
||||||
|
#=
|
||||||
|
Statement
|
||||||
|
=#
|
||||||
|
ans = 0
|
||||||
|
for i in 100:1000
|
||||||
|
for j in 100:1000
|
||||||
|
palindrome = i * j
|
||||||
|
s = string(palindrome)
|
||||||
|
if (s==reverse(s)) & (palindrome > ans)
|
||||||
|
ans = palindrome
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return ans
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
println("Time to evaluate Problem 4:")
|
||||||
|
@time Problem4()
|
||||||
|
println("")
|
||||||
|
println("Result for Problem 4: ", Problem4())
|
Loading…
x
Reference in New Issue
Block a user