Testing each number from 2 to n individually is too slow. For each number, you would check divisors up to √n. Total time: O(n × √n).
The Sieve of Eratosthenes solves this in O(n log log n) time. Much faster.
After running the sieve, count how many entries in the isPrime array are true.