Data Structures & AlgorithmsModerateSSC CGL Tier 2 · TCS NQT

Problem: How many prime numbers are there in the range 1 to 200 (inclusive)?

  1. A. 47
  2. B. 46
  3. C. 45
  4. D. 25

Correct answer: B. 46

A sieve up to 200 leaves 46 primes (25 of them up to 100, 21 between 101 and 199). Counting 1 as prime gives 47, counting only odd primes gives 45, and 25 is the count up to 100.

More Coding Interview Problems questions

Exams that ask this topic