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


MODULE A005179;
FROM InOut IMPORT WriteCard, WriteLn;
 
CONST Amount = 15;
VAR found, i, ndivs: CARDINAL;
    A: ARRAY [1..Amount] OF CARDINAL;
 
PROCEDURE divisors(n: CARDINAL): CARDINAL;
    VAR count, i: CARDINAL;
BEGIN
    count := 0;
    i := 1;
    WHILE i*i <= n DO
        IF n MOD i = 0 THEN
            INC(count);
            IF n DIV i # i THEN
                INC(count);
            END;
        END;
        INC(i);
    END;
    RETURN count;
END divisors;
 
BEGIN
    FOR i := 1 TO Amount DO A[i] := 0; END;
 
    found := 0;
    i := 1;
    WHILE found < Amount DO
        ndivs := divisors(i);
        IF (ndivs <= Amount) AND (A[ndivs] = 0) THEN
            INC(found);
            A[ndivs] := i;
        END;
        INC(i);
    END;
 
    FOR i := 1 TO Amount DO
        WriteCard(A[i], 4);
        WriteLn;
    END;
END A005179.