Count Primes
Given an integer n, return the number of prime numbers that are strictly less than n.
Open official problem prompt ↗Count how many primes lie below a possibly very large bound n, fast enough for n up to five million.
Standing at each prime and crossing off every one of its multiples on a numbered list, like striking out every second, third, fifth seat in a stadium.
- Input
- n = 10
- Output
- 4
- Why
- The primes strictly below 10 are 2, 3, 5, and 7, which is 4 primes.
0 <= n <= 5 * 10^6