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


puts:	equ	9	; MS-DOS print string syscall
amount:	equ	20 	; Amount of antiprimes to find
	cpu	8086
	org	100h
	xor	si,si	; SI = current number
	xor	cx,cx	; CH = max # of factors, CL = # of antiprimes
cand:	inc	si	
 	mov	di,si	; DI = maximum factor to test
	shr	di,1
	mov	bp,1	; BP = current candidate
	xor	bl,bl	; BL = factor count
.test:	mov	ax,si	; Test current candidate 
	xor	dx,dx
	div	bp
	test	dx,dx	; Evenly divisible?
	jnz	.next
	inc	bx	; Then increment factors
.next:	inc	bp	; Next possible factor
	cmp	bp,si	; Are we there yet?
	jbe	.test	; If not, try next factor
	cmp	bl,ch	; Is it an antiprime?
	jbe	cand	; If not, next candidate
	inc	cx	; If so, increment the amount of antiprimes seen
	mov	ch,bl	; Update maximum amount of factors
	mov	bx,nbuf	; Convert current number to ASCII
	mov	ax,si
	mov	di,10
digit:	xor	dx,dx	; Extract a digit
	div	di
	add	dl,'0'	; Add ASCII 0
	dec	bx
	mov 	[bx],dl	; Store it
	test	ax,ax	; Any more digits?
	jnz	digit	; If so, get next digit
	mov	dx,bx
	mov	ah,puts
	int	21h	; Print using MS-DOS
	cmp 	cl,amount	; Do we need any more antiprimes?
	jb	cand	; If so, find the next one
	ret		; Otherwise, back to DOS
	db	'.....'	; Placeholder for decimal output
nbuf:	db	' $'