Program SO_NGUYEN_TO;
Uses crt;
Var i,n: integer;
Begin
Clrscr;
Writeln('KIEM TRA SO NGUYEN TO:');
Writeln('---------------------------------------');
Write ('Nhap so can kiem tra n = '; readln(n);
If (n=0) or (n=1) then
Writeln('Khong phai la so nguyen to')
Else
Begin
i:=1;
Repeat
i:= i+1;
Until (n mod i= 0) or (i*i>n);
If i*i>n then Writeln (n,' la so nguyen to'):
Else Writeln (n;,'khong phai la so nguyen to');
end;
Readln;
end.
Program CAC_SO_NGUYEN_TO;
Uses crt;
Var n,i,t,s: integer;
Begin
Clrscr;
Writeln('IN RA CAC SO NGUYEN SO ');
Writeln('---------------------------------------------');
Write('Nhap n = ');readln(n);
If n<2 then
Writeln('Khong co so nguyen to nao ',n)
Else
Begin
writeln('cac so nguyen to',n);
for i:=2 to n do
Begin
t:= 1;
Repeat
t:= t+1;
Until ( i mod t = 0) or ( t*t>i ) ;
If( t*t>i) then
Write(i:4);
end;
End;
s:=0;
for i:=2 to n do
s:=s+i;
wreln( tong cua chung',s);
Readln;
End.