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


% Count factors
factors = proc (n: int) returns (int)
    if n<2 then return(1) end
    count: int := 2
    for i: int in int$from_to(2, n/2) do
        if n//i = 0 then count := count + 1 end
    end
    return(count)
end factors
 
% Generate antiprimes
antiprimes = iter () yields (int)
    max: int := 0
    n: int := 1
    while true do
        f: int := factors(n)
        if f > max then
            yield(n)
            max := f
        end
        n := n + 1
    end
end antiprimes
 
% Show the first 20 antiprimes
start_up = proc ()
    max = 20
    po: stream := stream$primary_output()
    count: int := 0
 
    for i: int in antiprimes() do
        stream$puts(po, int$unparse(i) || " ")
        count := count + 1
        if count = max then break end
    end
end start_up