Jump to content

Duffinian numbers: Difference between revisions

→‎{{header|jq}}: def primeSieve:
(Created Nim solution.)
(→‎{{header|jq}}: def primeSieve:)
Line 554:
| . == ($sqrt | .*.);
 
# Input: a positive integer
# return an array, $a, of length . or slightly greater, such that
# $a[$i]Output: isan $i ifarray, $ia, isof prime,length and.+1 falsesuch otherwise.that
# $a[$i] is $i if $i is prime, and false otherwise.
def primeSieve:
# erase(i) sets .[i*j] to false for integral j > 1
def erase($i):
if .[$i] then
reduce (range(2*$i; (1 + length) /; $i)) as $j (.; .[i * $j] = false)
else .
end;
Line 701 ⟶ 702:
Number of triplets: 50
</pre>
 
 
=={{header|Julia}}==
2,495

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.