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 "seed7_05.s7i";
 
const func integer: countDivisors (in integer: number) is func
  result
    var integer: count is 1;
  local
    var integer: num is 0;
  begin
    for num range 1 to number div 2 do
      if number rem num = 0 then
        incr(count);
      end if;
    end for;
  end func;
 
const proc: main is func
  local
    var integer: maxDiv is 0;
    var integer: count is 0;
    var integer: number is 1;
    var integer: divisors is 1;
  begin
    writeln("The first 20 anti-primes are:");
    while count < 20 do
      divisors := countDivisors(number);
      if divisors > maxDiv then
        write(number <& " ");
        maxDiv := divisors;
        incr(count);
      end if;
      incr(number);
    end while;
    writeln;
  end func;