Data Structures & AlgorithmsModerateSSC CGL Tier 2 · TCS NQT

Problem: How many prime numbers lie strictly between 100 and 150?

  1. A. 12
  2. B. 35
  3. C. 25
  4. D. 10

Correct answer: D. 10

101, 103, 107, 109, 113, 127, 131, 137, 139, 149: ten primes. Sieving only by 2, 3, 5, 7 lets 121 and 143 through for 12, 35 counts primes up to 150, and 25 counts primes up to 100.

More Coding Interview Problems questions

Exams that ask this topic