Create a boolean array isPrime of size n, initialized to true.
Set isPrime[0] and isPrime[1] to false (0 and 1 are not prime).
For each number p from 2 to √n: if isPrime[p] is true, mark all multiples of p (starting from p²) as false.
Count how many entries in isPrime are true.