Const m=1000;
var
a:array[1..m] of integer;
n,i,p,k,j:integer;
begin
write('n = '); readln(n);
i:=0; p:=1;
while p begin
k:=0;
for j:=2 to round(sqrt(p)) do
if p mod j = 0 then k:=k+1;
if k=0 then begin i:=i+1; a[i]:=p; end;
p:=p+1;
end;
for j:=1 to i do write(a[j],' ');
writeln;
end.
Пример:
n = 100
1 2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97