Sequence: smallest number with exactly n divisors: Difference between revisions

Line 721:
=={{header|jq}}==
 
<lang jq># unsorted factors
def factors:
. as $num
| reduce range(1; 1 + sqrt|floor) as $i
([];
if ($num % $i) == 0 then
($num / $i) as $r
| if $i == $r then . + [$i] else . + [$i, $r] end
else .
end );
# smallest number with exactly n divisors
def A005179:
. as $n
| first( range(1; infinite) | select( (factors|length) == $n ));
 
# The task:
"The first 15 terms of the sequence are:",
[range(1; 16) | A005179]
</lang>
 
''Invocation'': jq -nc -f A005179.jq
{{out}}
<pre>"The first 15 terms of the sequence are:"
[1,2,4,6,16,12,64,24,36,48,1024,60,4096,192,144]</pre>
 
=={{header|Julia}}==
2,467

edits