program tim_so_nguyen;
uses crt;
var i,N:integer;
begin
clrscr;
write('nhap so nguyen:');
readln(N);
if N <= 2 then write(N,' khong phai la so nguyen to')
else
begin
i:=2;
while ( N mod i <> 0 ) do i:=i+1;
if i=N then write(N,' la so nguyen to')
else write(N,' khong phai la so nguyen to');
end;
readln;
end.
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n,i,kt;
cin>>n;
for (int i=2; i<=n; i++)
{
kt=0;
for (int j=2; j*j<=i; j++)
if (i%j==0) kt=1;
if (kt==0) cout<<i<<" ";
}
}