Cousin primes: Difference between revisions

(→‎{{header|jq}}: correction)
Line 1,060:
'''The Count'''
 
To compute the pairs and the count at the same time without saving them as an array:<lang jq># Use null as the EOS marker
foreach ((997|cousins),null) as $c (01; .+1; if $c == null then "\nCount is \(.)" else $c end)</lang>
<lang jq>def count(s): reduce s as $x (0; .+1);
 
# Use null as the EOS marker
foreach ((997|cousins),null) as $c (0; .+1; if $c == null then "\nCount is \(.)" else $c end)</lang>
{{out}}
<pre>
Line 1,109 ⟶ 1,106:
[967,971]
 
Count is 4241
</pre>
 
2,442

edits