Skip to content

Count Primes

MediumBit Manipulation & Math
Decode it first. Clues, constraints, pattern and plan before any code.

Return the number of prime numbers strictly less than n. A prime is an integer greater than 1 whose only divisors are 1 and itself.

n = 10  →  4    (2, 3, 5, 7)
n = 0   →  0
n = 1   →  0

Constraints

  • 0 <= n <= 5 * 10^6