#include
#include
using namespace std;
bool prost(int m){
int k = 0;
for (int i=2; i<=sqrt(m); i++)<br> if (m % i == 0) k++;
return k==0;
}
int main(){
int n;
int m = 1, i = 1;
cout << "n = ", cin >> n, cout << "\n";<br> cout << 1 << " ";<br> while (m i++;
if (prost(i)) {
cout << i << " ";<br> m++;
}
}
return 0;
}
Пример:
n = 10
1 2 3 5 7 11 13 17 19 23