.;
.;	Calculate prime numbers using the Sieve of Eratosthenes
.;	T. R. Wyant
.;	E. I. DuPont de Nemours
.;	P. O. Box 27001
.;	Richmond, VA 23261
.;	December 4, 1991
.;
.;	The upper limit on number of primes is rather arbitrary (the
.;	hundredth prime being only 541). On the other hand, who really
.;	wants to use a .CMD file as a prime number generator anyway?
.;
	.ENABLE SUBSTITUTION
	.SETS MYFILE <FILSPC>
	; 'MYFILE'
	.SETN P$1 2
	.SETN NP 0.
	.SETN NM 1.
	.ASKN [1.:100.:10.] FP Number of primes to find
	.SETS START <TIME>
.LOOP:
	.INC NM
	.SETN PI 0.
.SIEVE:
	.INC PI
	.IF PI > NP .GOTO PRIME
	.IF Q$'PI' > NM .GOTO PRIME
	.SETN REM NM-((NM/P$'PI')*P$'PI')
	.IF REM = 0 .GOTO LOOP
	.GOTO SIEVE
.PRIME:
	.INC NP
	.SETN P$'NP' NM
	.IF NM < 256. .SETN Q$'NP' NM*NM
	.IF NP < FP .GOTO LOOP
	.SETS FINISH <TIME>
	.SETN PI 0.
.DISPLY:
	.INC PI
	.SETN NM P$'PI'
	; 'NM' is prime.
	.IF PI < NP .GOTO DISPLY
	;
	; Finish: 'FINISH'
	;  Start: 'START'
	.EXIT
