Answer the question
In order to leave comments, you need to log in
I came up with an algorithm, evaluate its fidelity?
I came up with an algorithm based on the Eratosphere sieve, evaluate its accuracy
int main() {
bool *A;
long N;
cin >> N;
A = new bool[N * 100 + 1];
int i, k;
for (int i = 2; i <= N * 100; i++)
A[i] = true;
k = 2;
while (k * k <= N * 100) {
if (A[k]) {
i = k * k;
while (i <= N * 100)
{
A[i] = false;
i += k;
}
}
k++;
}
int j = 0;
for (int i = 2; i <= N * 100; i++) {
if (A[i] && j < N) {
cout << i << " ";
j++;
}
if (j == N)
break;
}
return 0;
}
Answer the question
In order to leave comments, you need to log in
Sorry. You did not come up with an algorithm, Eratosthenes invented it, you just implemented it.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question