Concept Flow - Sieve of Eratosthenes Find All Primes
Initialize array of size n+1 with True
Set 0 and 1 as False
Start with p=2 (first prime)
Is p*p <= n?
No→Collect all indices with True as primes
Yes
Mark multiples of p as False
Increment p to next True
↩Back to check p*p <= n
The sieve marks multiples of each prime starting from 2 as not prime, repeating until p squared exceeds n, then collects all primes.
