You are calibrating a hash table whose bucket count should be prime. As a first step you need to know how many candidate primes exist below a threshold. Given a non-negative integer n, count how many prime numbers are strictly less than n.
A prime is an integer greater than 1 whose only positive divisors are 1 and itself.
A single line with one non-negative integer n.
A single integer: the count of primes p with p < n.
Example 1
Input
10
Expected
4
Explanation
The primes below 10 are 2, 3, 5, 7, so the answer is 4.
Example 2
Input
2
Expected
0
Explanation
There are no primes strictly less than 2, so the answer is 0.
Ready to solve this?
Sign in to open the editor, run your code against the sample tests, and submit against the full test suite.
Sign in to solve →