Data Structures & AlgorithmsModerateTCS NQT · number theory

Problem: How many divisors does 720 have? Run the code.

Problem: How many divisors does 720 have? Run the code.
print(sum(1 for d in range(1, 721) if 720 % d == 0))
What is printed?
  1. A. 30
  2. B. 24
  3. C. 36
  4. D. 28

Correct answer: A. 30

720 = 2^4 * 3^2 * 5, so the divisor count is 5 * 3 * 2 = 30.

More Coding Interview Problems questions

Exams that ask this topic