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


include "cowgol.coh";
 
const AMOUNT := 15;
typedef I is uint16; 
 
sub divisors(n: I): (count: I) is
    var i: I := 1;
    count := 0;
 
    while i*i <= n loop
        if n%i == 0 then
            if n/i == i then
                count := count + 1;
            else
                count := count + 2;
            end if;
        end if;
        i := i + 1;
    end loop;
end sub;
 
var seq: I[AMOUNT+1];
MemZero(&seq as [uint8], @bytesof seq);
 
var found: I := 0;
var i: I := 1;
 
while found < AMOUNT loop
    var divs := divisors(i) as @indexof seq;
    if divs <= AMOUNT and seq[divs] == 0 then
        found := found + 1;
        seq[divs] := i;
    end if;
    i := i + 1;
end loop;
 
var j: @indexof seq := 1;
while j <= AMOUNT loop
    print_i16(seq[j]);
    print_char(' ');
    j := j + 1;
end loop;
print_nl();