nhập 1 dãy phân tích nt số đó

1 câu trả lời

 uses crt;
Var
d,n,j,i:longint;
 function nt(x:longint):boolean;
  begin
   nt:=true;
   if x<2 then exit(false);
   if x=2 then exit(true);
   if x>2 then
    for j:=2 to trunc(sqrt(x)) do if x mod j=0 then exit(false);
  end;
Begin     clrscr;
 readln(n);  d:=0;
 for i:=2 to (n div 2) do if nt(i) and nt(n-i) then
  begin
   writeln(i,'-----',n-i);
   d:=d+1;
  end;
 writeln(d);
Readln;
End.

Câu hỏi trong lớp Xem thêm