Program hotrotinhoc;
var a: array[1..32000] of integer;
d,i,n: integer;
function snt(x: integer): boolean;
var j: integer;
begin
snt:=false;
if x<2 then exit;
for j:=2 to trunc(sqrt(x)) do
if x mod j=0 then exit;
snt:=true;
end;
begin
write('n='); readln(n);
for i:=1 to n do
begin
write('a[',i,']='); readln(a[i]);
end;
d:=0;
for i:=1 to n do
if nt(a[i]) then inc(d);
write('So luong so nguyen to trong day la : ',d);
readln
end.
progran baitap6_chuong4;
uses crt;
var
array[1..100] of integer;
if: boolean;
N, i„ l: integer; so_nt, so_chan: integer;
begin
for i := -1000 to 1000 do if i>0 then NT:= false;
so_chan:=0; so_nt:=0;
{Nhap vao)
repeat
write('So phan tu cua day A (N<=100), N= *);
readln(N);
until (N>0) and
(N<=100);
for i:= 1 to N do
begin
{kiem tra cac phan tu cua day khi nhap vao}
repeat
write('A[',i,']= ');readln(A[i]);
if (a[i]>1000) or (a[i]<-1000) then
write('Moi nhap lai ");
until (a[i]>-1000) and (a[i]<1000); = if A[i] mod 2 =0 then so_chan:= so_chan + 1; if A[i] >1 then
begin
u: = 2 ;
while ((u<=sqrt (A[i])) and (A[i] mod u<>0))) do u: = u + 1; if u>sqrt(A[i]) then so_nt:= so_nt + 1;
end,
uses crt;
var a:array[1..100]of integer;
n,i,kt,j,dem:integer;
begin
clrscr;
write('nhap so phan tu:'); readln(n);
for i:=1 to n do
begin
write('a[',i,']='); readln(a[i]);
end;
{----------------------------------------------------}
for i:=1 to n do write(a[i],' ');
{----------------------------------------------------}
writeln;
dem:=0;
for i:=1 to n do
if a[i]>1 then
begin
kt:=0;
for j:=2 to a[i]-1 do
if a[i] mod j=0 then kt:=1;
if kt=0 then dem:=dem+1;
end;
writeln('so luong so nguyen to trong day so la: ',dem);
readln;
end.