Data Structures & AlgorithmsHardProduct Company SDE · CP practice

Problem: What is the smallest positive integer with exactly 10 positive divisors? Run the search.

Problem: What is the smallest positive integer with exactly 10 positive divisors? Run the search.
n = 1
while sum(1 for d in range(1, n + 1) if n % d == 0) != 10:
    n += 1
print(n)
What is printed?
  1. A. 24
  2. B. 30
  3. C. 48
  4. D. 36

Correct answer: C. 48

Since 48 = 2^4 * 3 has divisor count 5 * 2 = 10, it is the smallest; 24, 30 and 36 have 8, 8 and 9 divisors.

More Coding Interview Problems questions

Exams that ask this topic