Ormiston pairs: Difference between revisions

m
Line 347:
'''Preliminaries'''
<syntaxhighlight lang=jq>
# Assuming . > 2, return an array, $a, of length .+1 or .+2 such that
# $a[$i] is $i if $i is prime, and falsenull otherwise.
def primeSieve:
# erase(i) sets .[i*j] to false for integral j > 1
def erase(i):
if .[i] then
reduce range(2; (1 + length) / i) as $j (.; .[i * $j] = falsenull)
else .
end;
2,442

edits