Data Structures & AlgorithmsModerateTCS NQT · SSC CGL Tier 2

Problem: How many composite numbers lie in the range 2 to 50 (inclusive)?

  1. A. 35
  2. B. 15
  3. C. 34
  4. D. 33

Correct answer: C. 34

2..50 holds 49 numbers, 15 of them prime, so 34 are composite. Counting 1 as composite gives 35, 15 is the prime count, and stopping at 49 gives 33.

More Coding Interview Problems questions

Exams that ask this topic