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


100H:
/* CP/M CALLS */
BDOS: PROCEDURE (FN, ARG); DECLARE FN BYTE, ARG ADDRESS; GO TO 5; END BDOS;
EXIT: PROCEDURE; CALL BDOS(0,0); END EXIT;
PRINT: PROCEDURE (S); DECLARE S ADDRESS; CALL BDOS(9,S); END PRINT;
 
/* PRINT A NUMBER */
PRINT$NUMBER: PROCEDURE (N);
    DECLARE S (7) BYTE INITIAL ('..... $');
    DECLARE (N, P) ADDRESS, C BASED P BYTE;
    P = .S(5);
DIGIT:
    P = P - 1;
    C = N MOD 10 + '0';
    N = N / 10;
    IF N > 0 THEN GO TO DIGIT;
    CALL PRINT(P);
END PRINT$NUMBER;
 
/* COUNT THE FACTORS OF A NUMBER */
COUNT$FACTORS: PROCEDURE (N) ADDRESS;
    DECLARE (N, I, COUNT) ADDRESS;
    IF N<2 THEN RETURN 1;
    COUNT = 1;
    DO I=1 TO N/2;
        IF N MOD I = 0 THEN COUNT = COUNT + 1;
    END;
    RETURN COUNT;
END COUNT$FACTORS;
 
DECLARE MAX$FACTORS ADDRESS INITIAL (0);
DECLARE SEEN BYTE INITIAL (0);
DECLARE N ADDRESS INITIAL (1);
DECLARE FACTORS ADDRESS;
 
DO WHILE SEEN < 20;
    FACTORS = COUNT$FACTORS(N);
    IF FACTORS > MAX$FACTORS THEN DO;
        CALL PRINT$NUMBER(N);
        MAX$FACTORS = FACTORS;
        SEEN = SEEN + 1;
    END;
    N = N + 1;
END;
CALL EXIT;
EOF