Data Structures & AlgorithmsHardTCS NQT · CAT

Problem: The number of integers from 1 to 100 that have exactly three divisors is what value? (Numbers with exactly three divisors are squares of primes.)

  1. A. 4
  2. B. 5
  3. C. 3
  4. D. 6

Correct answer: A. 4

A number has exactly three divisors precisely when it is the square of a prime. The squares of primes up to 100 are 4, 9, 25, 49 for primes 2, 3, 5, 7, so the count is four.

More Coding Interview Problems questions

Exams that ask this topic