Solution for problem 3 in Julia

This commit is contained in:
David Doblas Jiménez 2021-06-17 20:28:13 +02:00
parent cb9e385215
commit 400efe427c

34
src/Julia/Problem003.jl Normal file
View File

@ -0,0 +1,34 @@
#=
Created on 15 Jun 2021
@author: David Doblas Jiménez
@email: daviddoji@pm.me
Solution for Problem 3 of Project Euler
https://projecteuler.net/problem=3
=#
function Problem3()
#=
The prime factors of 13195 are 5, 7, 13 and 29.
What is the largest prime factor of the number 600851475143 ?
=#
ans = 600_851_475_143
factor = 2
while factor * factor < ans
while ans % factor == 0
ans = ans ÷ factor
end
factor += 1
end
return ans
end
println("Time to evaluate Problem 3:")
@time Problem3()
println("")
println("Result for Problem 3: ", Problem3())