Data Structures & AlgorithmsModerateSSC CGL Tier 2 · TCS NQT

Problem: How many prime numbers are there up to 100 (inclusive)?

  1. A. 26
  2. B. 24
  3. C. 25
  4. D. 168

Correct answer: C. 25

A sieve up to 100 leaves 25 primes, from 2 to 97. Counting 1 as prime gives 26, counting only odd primes gives 24, and 168 is the count up to 1000.

More Coding Interview Problems questions

Exams that ask this topic