Clean-up
This commit is contained in:
36
src/Julia/Problems001-050/Problem007.jl
Normal file
36
src/Julia/Problems001-050/Problem007.jl
Normal file
@@ -0,0 +1,36 @@
|
||||
#=
|
||||
Created on 24 Jun 2021
|
||||
|
||||
@author: David Doblas Jiménez
|
||||
@email: daviddoji@pm.me
|
||||
|
||||
Solution for Problem 7 of Project Euler
|
||||
https://projecteuler.net/problem=7
|
||||
=#
|
||||
|
||||
using Primes
|
||||
|
||||
function Problem7()
|
||||
#=
|
||||
By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13,
|
||||
we can see that the 6th prime is 13.
|
||||
|
||||
What is the 10_001st prime number
|
||||
=#
|
||||
number = 2
|
||||
primeList = Int[]
|
||||
while length(primeList) < 10_001
|
||||
if isprime(number)
|
||||
append!(primeList,number)
|
||||
end
|
||||
number += 1
|
||||
end
|
||||
|
||||
return primeList[length(primeList)]
|
||||
end
|
||||
|
||||
|
||||
println("Time to evaluate Problem 7:")
|
||||
@time Problem7()
|
||||
println("")
|
||||
println("Result for Problem 7: ", Problem7())
|
||||
Reference in New Issue
Block a user