Count Primes
Return how many prime numbers are strictly less than n.
Example 1
n 10
returns 4
2, 3, 5 and 7.
Example 2
n 2
returns 0
No prime is below 2.
Constraints
0 <= n <= 1000
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.
More Math problems
- Day of the WeekMedium
- Fast PowerMedium
- Friday the 13th CountMedium
- Last Digit of a PowerMedium
- Last Person StandingMedium
- Minimum Moves to Equal ElementsMedium
- Multiply StringsMedium
- Power ModMedium