program so_nguyen_to;
uses crt;
var i,n:integer;
function kt(n:integer):boolean;
var i,j:integer;
begin
j:=0;
for i:=1 to n do
if n mod i=0 then inc(j);
if j=2 then kt:=true
else kt:=false;
end;
BEGIN
clrscr;
write('nhap n:');readln(n);
if kt(n) then writeln(n,' la so nguyen to')
else writeln(n,' khong phai la so nguyen to');
writeln('cac so nguyen to be hon hoac bang ',n,' la:');
for i:=1 to n do
if kt(i) then write(i:5);
writeln;
writeln('cac cap so le lien tiep la so nguyen to be hon hoac bang ',n,' la:');
for i:=1 to n do
if (i mod 2=1) and (kt(i)) and (kt(i+2)) then write(i,',',i+2);
readln;
end.
Đúng 1
Bình luận (1)