Ramanujan primes: Difference between revisions
Content added Content deleted
m (use primes instead of primesmask) |
|||
Line 98: | Line 98: | ||
=={{header|Julia}}== |
=={{header|Julia}}== |
||
<lang julia>using Primes |
<lang julia>using Primes |
||
const MASK = [[false]] |
|||
const PRIMES = [primes(625000)] |
|||
⚫ | |||
if n > length(first(MASK)) |
|||
⚫ | |||
⚫ | |||
if n > first(PRIMES)[end] |
|||
⚫ | |||
push!(PRIMES, primes(2n)) |
|||
end |
end |
||
return |
return n < 100000 ? findfirst(x -> x > n, first(PRIMES)) - 1 : |
||
findlast(x -> x <= n, first(PRIMES)) |
|||
end |
end |
||
function Ramanujan_prime(n) |
function Ramanujan_prime(n) |