Prime numbers p for which the sum of primes less than or equal to p is prime: Difference between revisions

(→‎{{header|jq}}: simplify)
Line 246:
 
=={{header|jq}}==
'''Adapted from [[#Wren|Wren]]'''
{{works with|jq}}
'''Works with gojq, the Go implementation of jq'''
 
This entry adopts the straightforward approach as used for example in the [[#awk|awk]] entry.
The jq implementation of this approach also turns out to be significantly faster than the jq implementation of the approach used in the [[#Wren|Wren]] entry.
 
See [[Erdős-primes#jq]] for a suitable definition of `is_prime` as
Line 261 ⟶ 263:
# Output: a stream of primes satisfying the condition
def results($n):
[foreach primes($n)] as $primesp (0;
| ($primes | add). as+ $maxSump;
| [range select(0; $maxSumis_prime) | is_prime]$p as $c);
| foreach $primes[] as $p (0;
. + $p;
select($c[.]) | $p );
 
def task($n):
2,460

edits