with Text_io; procedure PRIMES is package IIO is new Text_IO.Integer_io(integer); --need integer output N:constant integer:=79; --largest number to be considered type PRIME_CLASS is (UNKNOWN, PRIME, COMPOSITE); type PRIME_CLASSES is array(1..N) of PRIME_CLASS; STATE: PRIME_CLASSES:=(1..N=>UNKNOWN); begin iio.Put(1); STATE(1):=PRIME; for P in 2..N loop -- For each possible prime in turn... if STATE(P)=UNKNOWN then -- it isn't a multiple of a smaller prime iio.put(P); STATE(P):=PRIME; for MULTIPLIER in 2..N loop exit when MULTIPLIER * P > N; STATE(MULTIPLIER * P):=COMPOSITE; end loop; text_io.new_line; for i in 1..N loop case STATE(i) is when UNKNOWN => text_io.put("u"); when PRIME => text_io.put("P"); when COMPOSITE=> text_io.put("."); end case; end loop; text_io.skip_line; end if; end loop; end PRIMES;