1:
uses crt;
var n,t,i,j,kt:integer;
begin
clrscr;
write('nhap n='); readln(n);
if n>=2 then
begin
kt:=0;
for i:=2 to trunc(sqrt(n)) do
if n mod i=0 then kt:=1;
if kt=0 then writeln(n,' la so nguyen to')
else writeln(n,' khong la so nguyen to');
end
else writeln(n,' khong la so nguyen to');
writeln('cac so nguyen to trong khoang tu 2 toi ',n,' la: ');
t:=0;
for i:=2 to n do
begin
kt:=0;
for j:=2 to i-1 do
if i mod j=0 then kt:=1;
if kt=0 then
begin
write(i:4);
t:=t+i;
end;
end;
writeln;
writeln('tong cac so nguyen to trong khoang tu 2 toi ',n,' la: ',t);
readln;
end.
số hoàn toàn là số như thế nào bạn?
1:
var
n:int64;
function snt2(n:int64):boolean;
var
k:longint;
begin
if n<=1 then exit (false);
if (n=3) or (n=2) then exit (true);
if (n mod 2=0) or (n mod 3=0) then exit (false);
for k:=1 to (trunc(sqrt(n))+1)div 6 do
if (n mod (6*k-1)=0) or (n mod (6*k+1)=0) then exit (false);
exit(true);
end;
begin
readln (n);
if snt2(n)=true then writeln (n,'la so nguyen to')
else writeln (n,'khong la so nguyen to');
readln;
end.