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

(Rename Perl 6 -> Raku, alphabetize, minor clean-up)
Line 308:
</pre>
 
=={{header|J}}==
Rather than factoring by division, this algorithm uses a sieve to tally the factors. Of the whole numbers below ten thousand these are the smallest with n divisors. The list is fully populated through the first 15.
<lang>
sieve=: 3 :0
range=. <. + i.@:|@:-
tally=. y#0
for_i.#\tally do.
j=. }:^:(y<:{:)i * 1 range >: <. y % i
tally=. j >:@:{`[`]} tally
end.
/:~({./.~ {."1) tally,.i.#tally
)
</lang>
<pre>
sieve 10000
0 0
1 1
2 2
3 4
4 6
5 16
6 12
7 64
8 24
9 36
10 48
11 1024
12 60
13 4096
14 192
15 144
16 120
18 180
20 240
21 576
22 3072
24 360
25 1296
27 900
28 960
30 720
32 840
33 9216
35 5184
36 1260
40 1680
42 2880
45 3600
48 2520
50 6480
54 6300
56 6720
60 5040
64 7560
</pre>
=={{header|Java}}==
{{trans|C}}
Anonymous user