2 câu trả lời
uses crt;
var n,i,dem,chan,le,dem2: integer;
kt:boolean;
begin
clrscr;
repeat
write('nhap so: '); readln(n);
if n mod 2=0 then
chan:=chan+n
else
begin
dem2:=dem2+1;
le:=le+n;
end;
for i:=2 to (n div 2) do
if n mod i =0 then dem :=dem+1;
if dem=0 then kt:=true;
if (n=0) or (n=1) or (dem>0) then kt:=false;
until kt=true;
writeln('tong cac so chan: ',chan);
writeln('trung binh cong cac so le: ',le/dem2:0:0);
readln;
end.
cho mình xin câu trả lời hay nhất
Program BTH;
uses crt;
var n,t:word;
i,k:longint;
Begin
clrscr;
Write('Nhap so can kiem tra: ');readln(n);
k:=0;
t:=n div 2;
For i:=2 to t do
Begin
If n mod i=0 then k:=k+1;
end;
If (n=1) or (n=0) then writeln(n,' khong phai la so nguyen to') else
If k=0 then writeln(n,' la so nguyen to') else
If k>0 then writeln(n,' khong phai la so nguyen to');
readln;
end.