uses crt; var n,i:longint; {—Chuong-trinh-con—} function nt(i:longint):boolean; var j:longint; begin j:=2; nt:=true; while i mod j<>0 do inc(j); if j<>i then nt:=false; end; {—Chuong-trinh-chinh—} begin clrscr; write(‘Nhap n: ‘); readln(n); for i:=2 to n do if nt(i) then write(i,’ ‘); writeln; readln end.
Program bai1;
uses crt;
var dem,n,i: integer;
begin
clrscr;
write(‘nhap n =’); readln(n);
dem:=0;
for i:= 1 to n do
if i mod 2 = 1 then
begin
write(i:3,’,’);
dem:= dem+1 ;
if dem mod 15 = 0 then writeln;
end;
readln;
end.
uses crt;
var n,i:longint;
{—Chuong-trinh-con—}
function nt(i:longint):boolean;
var j:longint;
begin
j:=2; nt:=true;
while i mod j<>0 do inc(j);
if j<>i then nt:=false;
end;
{—Chuong-trinh-chinh—}
begin
clrscr;
write(‘Nhap n: ‘); readln(n);
for i:=2 to n do
if nt(i) then write(i,’ ‘); writeln;
readln
end.