Deceptive numbers: Difference between revisions

→‎{{header|jq}}: simplify and speedup
(→‎{{header|jq}}: simplify and speedup)
Line 318:
support unbounded precision integer arithmetic.
 
Execution time using gojq on a 3GHz machine: 0.26s20s
<syntaxhighlight lang=jq>
def is_prime:
Line 338:
# Output: a stream
def deceptives:
{n:17, repunitnextrepunit: 1111111111111111}
| foreach range(17; infinite; 2) as $n (.;
| while(true;
.emitrepunit = null.nextrepunit
| if (.nnextrepunit | is_prime | not) and (.n % 3 != 0) and (.n %* 5100 !=+ 0)11;
then ifselect( (.repunit$n %| .nis_prime ==| 0not)
then .emit and ($n % 3 != .0) and ($n % 5 != 0)
else and (.repunit % $n == 0 ))
| $n end);
else .
end
| .n += 2
| .repunit |= . * 100 + 11)
| select(.emit).emit;
 
"The first 25 deceptive numbers are:", [limit(25;deceptives)]
2,442

edits