Return the number of prime numbers strictly less than n. A prime has exactly two divisors, 1 and itself.
For n = 10 the answer is 4 (2, 3, 5, 7).
The starter code tests every number by trial division. It is correct but too slow for large n.
Example 1
Input:
count_primes(10)
Output:
4
Example 2
Input:
count_primes(2)
Output:
0
0 <= n <= 2000000No results yet
Run your code to check it against the examples, or submit to run every test.