Files
project-euler/src/Julia/Problems001-050/Problem007.jl
2023-04-01 18:12:04 +02:00

45 lines
914 B
Julia

#=
Created on 24 Jun 2021
@author: David Doblas Jiménez
@email: daviddoji@pm.me
Solution for Problem 007 of Project Euler
https://projecteuler.net/problem=7
=#
using BenchmarkTools
using Primes
using Transducers
function Problem007()
#=
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
=#
count::Int32 = 10_000
# 2 is prime but not included to speed-up
# 150_000 should be big enough to find 10_000 primes
for number::Int32 in 1:2:150_000
if isprime(number)
count -= 1
if count == 0
return number
end
end
end
# prime_list::Vector{Int64} = primes(250_000)
# return prime_list[10_001]
end
println("Took:")
@btime Problem007()
println("")
println("Result for Problem $(lpad(7, 3, "0")): ", Problem007())