Program 1:
var
i, k, n, count, prim: word;
begin
readln(n);
k := 1;
prim := 0;
while prim < n do
begin
count := 0;
for i := 1 to k do
begin
if k mod i = 0 then inc(count)
end;
if count = 2 then begin
write(k, ' ');
inc(prim)
end;
inc(k)
end
end.
Program 2:
var
m, i, n: longint;
function simple(n: longint): boolean;
var
i: longint;
begin
simple := true;
for i := 2 to round(sqrt(n)) do
if n mod i = 0 then
begin
simple := false;
break;
end;
end;
begin
write('Numarul n: ');
readln(n);
for i := 2 to n do if simple(i) then write(i, ' ');
end.