The anti-primes
(or highly composite numbers, sequence A002182 in the OEIS)
are the natural numbers with more factors than any smaller than itself.



Task

Generate and show here, the first twenty anti-primes.



Related tasks

   Factors of an integer
   Sieve of Eratosthenes


include "cowgol.coh";
const AMOUNT := 20;
 
sub countFactors(n: uint16): (count: uint16) is
    var i: uint16 := 1;
    count := 1;
    while i <= n/2 loop
        if n%i == 0 then
            count := count + 1;
        end if;
        i := i + 1;
    end loop;
end sub;
 
var max: uint16 := 0;
var seen: uint8 := 0;
var n: uint16 := 1;
var f: uint16 := 0;
 
while seen < AMOUNT loop;
    f := countFactors(n);
    if f > max then
        print_i16(n);
        print_char(' ');
        max := f;
        seen := seen + 1;
    end if;
    n := n + 1;
end loop;
print_nl();