Data Structures & AlgorithmsModerateTCS NQT · ICPC regional

Problem: From the list [12, 18, 24, 30, 36], what is the number of distinct prime divisors of the product of all five numbers?

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

Correct answer: B. 3

All five numbers factor into 2, 3 and 5 only, so the product has three distinct prime divisors. Counting prime factors with multiplicity gives a much larger number.

More Coding Interview Problems questions

Exams that ask this topic