Count Primes
Given an integer n, return the number of prime numbers that are strictly less than n.
Count Primes
Given an integer n, return the number of prime numbers that are strictly less than n.
Example 1
Input: n = 10 Output: 4
Example 2
Input: n = 0 Output: 0
Show hint
Use Sieve of Eratosthenes: mark multiples of each prime as non-prime. Start from 2, mark all multiples, then move to next unmarked number.
Sign in to submit, save progress and mark problems as solved. You can still run your code.
Loading editor...
n =
10
Expected
4