Sieve of Eratosthenes - GeeksforGeeks

PHOTO EMBED

Fri Aug 20 2021 11:18:35 GMT+0000 (UTC)

Saved by @faisals

 bool prime[n + 1];
    
 
    for (int p = 2; p * p <= n; p++)
    {
        // If prime[p] is not changed,
        // then it is a prime
        if (prime[p] == true)
        {
            
           
            for (int i = p * p; i <= n; i += p)
                prime[i] = false;
        }
    }
content_copyCOPY

https://www.geeksforgeeks.org/sieve-of-eratosthenes/