uses crt; var n,i,s:longint; {—Ham-nguyen-to—} function nt(n:longint):boolean; var i:longint; begin i:=2; while n mod i<>0 do inc(i); if i=n then nt:=true else nt:=false; end; {—Chuong-trinh-chinh—} begin clrscr; write(‘Nhap n: ‘); read(n); for i:=2 to n do if nt(i) then inc(s,i); writeln(‘Tong nguyen to: ‘,s); readln end.
uses crt;
var i,n,s:longint;
{——————————-}
function nt(x:longint):boolean;
var h:longint;
begin
for h:=2 to trunc(sqrt(x)) do if (x mod h=0) then exit(false);
exit(true);
end;
{———————————-}
begin
clrscr;
readln(n);
s:=0;
for i:=1 to n do if (nt(i)) then s:=s+i;
write(s);
readln
end.
uses crt;
var n,i,s:longint;
{—Ham-nguyen-to—}
function nt(n:longint):boolean;
var i:longint;
begin
i:=2;
while n mod i<>0 do inc(i);
if i=n then
nt:=true
else
nt:=false;
end;
{—Chuong-trinh-chinh—}
begin
clrscr;
write(‘Nhap n: ‘); read(n);
for i:=2 to n do
if nt(i) then
inc(s,i);
writeln(‘Tong nguyen to: ‘,s);
readln
end.