Uses crt;
var i,dem,j,n:Integer;
Begin
write('Nhap so nguyen n');ReadLn(n);
if n>0 Then
begin
WriteLn('Cac so nguyen to tu 2 den ',n,' la:');
for j:=2 to n Do
begin
dem:=0;
for i:= 1 to j do if j mod i=0 then dem:=dem+1;
if dem=2 then write(j,' ');
end;
end;
Readln
End.
đúng ko z?
uses crt;
var a:array[1..100]of integer;
i,n,x,dem,kt:integer;
begin
clrscr;
repeat
write('nhap n='); readln(n);
if n<=0 then writeln('ban da nhap sai , yeu cau ban nhap lai');
until n>0;
if n=1 then a[1]:=2
else
begin
a[1]:=2;
x:=1;
dem:=1;
repeat
x:=x+2;
kt:=0;
for i:=2 to trunc(sqrt(x)) do
if x mod i=0 then kt:=1;
if kt=0 then begin
dem:=dem+1;
a[dem]:=x;
end;
until dem=n;
end;
writeln('so nguyen to thu ',n,' la: ',x);
readln;
end.
program bai1;
var i,n,k,m:longint;
function nto(a:longint):boolean;
var i,s:longint;
b:boolean;
begin
b:=false;s:=0;
for i:=1 to a do
if a mod i0 then s:=s+1;
if s=2 then b:=true;
nto:=b;
end;
begin
readln(n);
i:=0;k:=2;
while i<=n do
begin
if nto(k)=true then
begin
m:=k;
i:=i+1;
end;
k:=k+1;
end;
write(m);
readln
end.
uses crt;
var n,i:integer;
begin
clrscr;
write('Nhap vao mot so nguyen : ');readln(n);
if n<=1 then writeln('n khong phai la so nguyen to')
esle
begin
i:=2;
while (n mod i< >0) do i:=i+1;
if i=n then writeln(n,' la so nguyen to !')
else writeln(n,' khong phai la so nguyen to !');
end;
readln;
end.
uses crt;
var a:array[1..100]of integer;
i,n,x,dem,kt:integer;
begin
clrscr;
repeat
write('nhap n='); readln(n);
if n<=0 then writeln('ban da nhap sai , yeu cau ban nhap lai');
until n>0;
if n=1 then a[1]:=2
else
begin
a[1]:=2;
x:=1;
dem:=1;
repeat
x:=x+2;
kt:=0;
for i:=2 to trunc(sqrt(x)) do
if x mod i=0 then kt:=1;
if kt=0 then begin
dem:=dem+1;
a[dem]:=x;
end;
until dem=n;
end;
writeln('so nguyen to thu ',n,' la: ',x);
readln;
end.