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.
package IIO is new Text_IO.Integer_io(integer); --need integer output
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;
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;
if D * D > P then -- D > P/D and so all possible D's have been tested
exit DIVISIONS;
end if;
end loop DIVISIONS;
if STATE=PRIME then
iio.put(P);
if integer(Text_io.col) > 70 then
Text_io.new_line;
end if;
end if;
end loop;
Text_IO.New_Line;
end PRIMES;