# Primes by Trial Division - DRI PL/I-86

24 April 2017

DRI PL/I-86 does not allow an array to be declared using a variable, or a non-integer type to be used as an array index.

It will also overflow and hang the machine if COUNT exceeds 32767.

NPRIMES: PROCEDURE OPTIONS (MAIN); %REPLACE N BY 100; /* N BY 1000; */ DECLARE (I, FOUND, COUNT) INT, PRIMES (N) DECIMAL FIXED (6); FOUND = 0; COUNT = 2; DO WHILE (FOUND < N); FOUND = FOUND + 1; PUT SKIP LIST (COUNT); PRIMES (FOUND) = COUNT; NOTPRIME: COUNT = COUNT + 1; I = 1; NEXT: IF (MOD (COUNT, PRIMES (I)) = 0) THEN GO TO NOTPRIME; ELSE DO I = I + 1; IF (I <= FOUND) THEN GO TO NEXT; END; END; END NPRIMES;