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

Added AutoHotkey
m (Swift: removed unnecessary variable, renamed another one)
(Added AutoHotkey)
Line 59:
1 2 4 6 16 12 64 24 36 48 1024 60 4096 192 144
</pre>
 
=={{header|AutoHotkey}}==
{{trans|Go}}
<lang AutoHotkey>max := 15
seq := [], n := 0
while (n < max)
if ((k := countDivisors(A_Index)) <= max) && !seq[k]
seq[k] := A_Index, n++
for i, v in seq
res .= v ", "
MsgBox % "The first " . max . " terms of the sequence are:`n" Trim(res, ", ")
return
 
countDivisors(n){
while (A_Index**2 <= n)
if !Mod(n, A_Index)
count += A_Index = n/A_Index ? 1 : 2
return count
}</lang>
Outputs:<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|AWK}}==
299

edits