This repository has been archived on 2024-01-26. You can view files and clone it, but cannot push or open issues or pull requests.
project-euler/e0007/euler0007.jl
2017-08-08 23:04:26 +02:00

36 lines
565 B
Julia

#!/usr/bin/julia
function euler007(n)
if n < 1
return NaN
elseif n == 1
return 2
end
primes = Array{Int64, 1}([])
foundCount = 1
number = 3
while foundCount < n
isPrime = true
for prime primes
if number % prime == 0
isPrime = false
break
end
end
if isPrime
push!(primes, number)
foundCount += 1
end
number += 2
end
return last(primes)
end
euler007(1)
@time euler007(10001)