Special neighbor primes: Difference between revisions
Content added Content deleted
m (→{{header|Julia}}: include 3) |
|||
Line 133: | Line 133: | ||
=={{header|Julia}}== |
=={{header|Julia}}== |
||
{{incorrect|Julia|omits 3,5}} |
|||
<lang julia>using Primes |
<lang julia>using Primes |
||
function specialneighbors(N) |
function specialneighbors(N) |
||
neighbors, p1 = Pair{Int}[], 2 |
neighbors, p1 = Pair{Int}[], 2 |
||
while (p2 = nextprime(p1 + |
while (p2 = nextprime(p1 + 1)) < N |
||
isprime(p2 + p1 - 1) && push!(neighbors, p1 => p2) |
isprime(p2 + p1 - 1) && push!(neighbors, p1 => p2) |
||
p1 = p2 |
p1 = p2 |
||
Line 155: | Line 154: | ||
p1 p2 p1 + p2 - 1 |
p1 p2 p1 + p2 - 1 |
||
-------------------------- |
-------------------------- |
||
3 5 7 |
|||
5 7 11 |
5 7 11 |
||
7 11 17 |
7 11 17 |