Pascal
uses crt;
var dem,i:word;
function nt(n:word):boolean;
var i:word;
begin
for i:=2 to trunc(sqrt(n)) do
if n mod i = 0 then exit(false);
exit(true);
end;
begin
clrscr;
dem:=0;
i:=2;
while dem<10 do
begin
while nt(i)=false do inc(i);
inc(dem);inc(i);
end;
dem:=0;
writeln('So nguyen to thu 10: ',i-1);
// readln;
for i:=100 to 999 do
begin
if nt(i)=true then writeln(i);
end;
readln;
end.
c++? =))
#include <iostream>
#include <math.h>
using namespace std;
bool nt(int n)
{
for (int i = 2;i <= sqrt(n);i++)
{
if (n % i == 0)
return false;
}
return true;
}
int main()
{
int dem = 0;
int i = 2;
while (dem < 10)
{
while (nt(i) == false)
i++;
dem++;i++;
}
printf("So nguyen to thu 10: %d\n",i-1);
for (i = 101;i<=999;i += 2)
{
if (nt(i))
{
printf("%d\n",i);
}
}
return 0;
}