Sequence: smallest number with exactly n divisors: Difference between revisions
Content deleted Content added
→{{header|REXX}}: added a second version that uses memoization. |
No edit summary |
||
Line 422:
1, 2, 4, 6, 16, 12, 64, 24, 36, 48, 1024, 60, 4096, 192, 144
</pre>
=={{header|Nanoquery}}==
{{trans|Java}}
<lang nanoquery>def count_divisors(n)
count = 0
for (i = 1) ((i * i) <= n) (i += 1)
if (n % i) = 0
if i = (n / i)
count += 1
else
count += 2
end
end
end
return count
end
max = 15
seq = {0} * max
print format("The first %d terms of the sequence are:\n", max)
i = 1
for (n = 0) (n < max) (i += 1)
k = count_divisors(i)
if (k <= max)
if seq[k - 1] = 0
seq[k - 1] = i
n += 1
end
end
end
println seq</lang>
{{out}}
<pre>[1, 2, 4, 6, 16, 12, 64, 24, 36, 48, 1024, 60, 4096, 192, 144]</pre>
=={{header|Nim}}==
|