- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
function Prime (N: longword): boolean;
var
i : longword;
Max : single;
begin
if N = 2
then Prime := true
else if (N <= 1) or (N mod 2 = 0)
then Prime := false
else begin
Prime := true;
i := 3; Max := sqrt(N);
while i <= Max do begin
if N mod i = 0 then begin
Prime := false;
exit
end;
i := i + 2
end
end
end;
var
a, i : longword;
begin
read(a);
for i := 2 to a do
if Prime(i)
then writeln(i, ' is a prime number');
end.