Witam, podczas kompilacji na ideone wypisuje mi, że jest błąd kompilacji dla n równego np. milion.
Czy wie ktoś w czym jest błąd?
#include <iostream>
#include <cmath>
using namespace std;
const int MAX = 1e6;
int sito[MAX + 7];
void sito_eratostenesa() {
sito[0] = sito[1] = 1;
for (int i = 2; i <= sqrt(MAX); ++i) {
if (sito[i] == 1) continue;
for (int j = i * i; j <= MAX; j+=i) {
sito[j] = 1;
}
}
}
int main()
{
int n;
cin >> n;
sito_eratostenesa();
//cout << sito[1000000] << endl;
int ind = 1,i=2;
while (ind <= n && i <= MAX) {
if (sito[i] == 0) {
cout << ind << ". " << i << '\n';
++ind;
}
++i;
}
return 0;
}