Data Structures & AlgorithmsModerateCodeforces Div2 B · ICPC regional warm-up

Problem: How many prime numbers are there that are less than or equal to 10^6?

  1. A. 78512
  2. B. 77777
  3. C. 78498
  4. D. 79001

Correct answer: C. 78498

Pi(10^6) = 78498, a standard value obtained from a sieve of Eratosthenes. Quick estimates such as x / ln x give about 72,000, which is the wrong magnitude for a contest bound check.

More Coding Interview Problems questions

Exams that ask this topic