Neighbour primes: Difference between revisions
Content added Content deleted
m (→{{header|REXX}}: changed the GENP subroutine.) |
|||
Line 418: | Line 418: | ||
Found 20 such primes. |
Found 20 such primes. |
||
</pre> |
|||
=={{header|jq}}== |
|||
{{works with|jq}} |
|||
'''Works with gojq, the Go implementation of jq''' |
|||
This entry uses `is_prime` as defined at [[Erd%C5%91s-primes#jq]]. |
|||
<lang jq>def next_prime: |
|||
if . == 2 then 3 |
|||
else first(range(.+2; infinite; 2) | select(is_prime)) |
|||
end; |
|||
def is_neighbour_prime: |
|||
is_prime and ((. * next_prime) + 2 | is_prime); |
|||
# The task |
|||
(2,range(3;500;2)) |
|||
| select(is_neighbour_prime)</lang> |
|||
{{out}} |
|||
<pre> |
|||
3 |
|||
5 |
|||
7 |
|||
13 |
|||
19 |
|||
67 |
|||
149 |
|||
179 |
|||
229 |
|||
239 |
|||
241 |
|||
269 |
|||
277 |
|||
307 |
|||
313 |
|||
397 |
|||
401 |
|||
419 |
|||
439 |
|||
487 |
|||
</pre> |
</pre> |
||