Count Primes
Given an integer n, return the number of prime numbers that are strictly less than n.

30:00

Count Primes
medium
Topics
Companies

Given an integer n, return the number of prime numbers that are strictly less than n.

Example 1:
Input: 10
Output: 4
Constraints:
  • 0n5×1060 \leq n \leq 5 \times 10^6

Input
arr =10

Sieve of Eratosthenes

0123456789
n: 10
Current: 0
Primes found: 0
Prime
Composite
Current
Variables
VariableValue
n10
DepthFunction Call
Stack empty
0/5