You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
365 B
Plaintext

8 months ago
{ This program determines whether a number is prime }
PROGRAM prime;
VAR p,c : integer;
BEGIN
readln(p);
c := 2;
while c * c <= p do
begin
if p mod c <> 0 then
begin
c := c + 1;
if c * c > p then
writeln(1)
else
begin
end
end
else
begin
writeln(0);
c := p + 100 { Exit condition that also works for p = 1 }
end
end
END
.