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(n,' 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: integer;
Begin
Clrscr;
Writeln('IN RA CAC SO NGUYEN SO <=N');
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,' la:');
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;
Readln;
End.
Ý kiến bạn đọc
Những tin cũ hơn