Gaussian primes: Difference between revisions
→{{header|jq}}: streamline GPrimes
(→{{header|jq}}: rm extraneous comment) |
(→{{header|jq}}: streamline GPrimes) |
||
Line 236:
# emit a stream of Gaussian primes with real and imaginary parts within the given radius
def GPrimes($Radius):
($Radius | norm) as $R2
| range(-$Radius; $Radius + 1) as $r
| range(-$Radius; $Radius + 1) as $i
|
|
|
elif $r == 0 then select($i|check)
▲ | select( $m|isPrime and ($m - 3) % 4 == 0 ) | [0, $i]
▲ else [$r, $i] | select(norm | isPrime)
end ;
|