Find squares n where n+1 is prime: Difference between revisions
Content added Content deleted
Catskill549 (talk | contribs) (added AWK) |
|||
Line 351: | Line 351: | ||
{{out}} |
{{out}} |
||
<pre>1 4 16 36 100 196 256 400 576 676</pre> |
<pre>1 4 16 36 100 196 256 400 576 676</pre> |
||
=={{header|jq}}== |
|||
{{works with|jq}} |
|||
'''Works with gojq, the Go implementation of jq''' |
|||
See [[Erdős-primes#jq]] for a suitable definition of `is_prime` as used here. |
|||
<lang jq>def squares_for_which_successor_is_prime: |
|||
(. // infinite) as $limit |
|||
| {i:1, sq: 1} |
|||
| while( .sq < $limit; .i += 1 | .sq = .i*.i) |
|||
| .sq |
|||
| select((. + 1)|is_prime) ; |
|||
1000 | squares_for_which_successor_is_prime</lang> |
|||
{{out}} |
|||
<pre> |
|||
1 |
|||
4 |
|||
16 |
|||
36 |
|||
100 |
|||
196 |
|||
256 |
|||
400 |
|||
576 |
|||
676 |
|||
</pre> |
|||
=={{header|Julia}}== |
=={{header|Julia}}== |