📜  eratosthenes c++ 代码示例的筛子

📅  最后修改于: 2022-03-11 14:44:47.816000             🧑  作者: Mango

代码示例2
int n;
vector is_prime(n+1, true);
is_prime[0] = is_prime[1] = false;
for (int i = 2; i <= n; i++) {
    if (is_prime[i] && (long long)i * i <= n) {
        for (int j = i * i; j <= n; j += i)
            is_prime[j] = false;
    }
}