with Text_io;
procedure PRIMES is -- outputs prime numbers between 1 and 100
-- A prime is a number P that can not be divided evenly
-- by a number between 2 and P-1.
-- 1 is considered to prime.
N:constant integer:=100;-- Largest number to be considered
type PRIME_CLASS is
(PRIME, COMPOSITE); -- All Numbers are prime or composite
STATE: PRIME_CLASS;
P:integer; -- A possible prime number;
D:integer; -- A possible divisor;
package INT_IO is new Text_IO.Integer_io(integer); --need integer output
begin
for P in 1..N loop -- For each possible prime in turn...
STATE:=PRIME; -- Assume P is PRIME until disproved
DIVISIONS:
for D in 2..P-1 loop -- See if D divides P
if P mod D = 0 then -- P is divisible by D
STATE:=COMPOSITE;
exit DIVISIONS;
end if;
end loop DIVISIONS;
if STATE=PRIME then INT_IO.put(P);
end if;
end loop;
Text_IO.New_line;
end PRIMES;