Calculate the sequence where each term   an   is the smallest natural number that has exactly   n   divisors.



Task
Show here, on this page, at least the first  15  terms of the sequence.



Related tasks

 Sequence: smallest number greater than previous term with exactly n divisors
 Sequence: nth number with exactly n divisors‎‎


See also

 OEIS:A005179


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