Data Structures & AlgorithmsModerateTCS NQT · number puzzle

Problem: What is the smallest positive integer whose decimal digits multiply to 36? Run the search code.

Problem: What is the smallest positive integer whose decimal digits multiply to 36? Run the search code.
x = 1
while True:
    p = 1
    for ch in str(x):
        p *= int(ch)
    if p == 36:
        break
    x += 1
print(x)
What is printed?
  1. A. 49
  2. B. 66
  3. C. 94
  4. D. 36

Correct answer: A. 49

Digits 4 and 9 multiply to 36. Two-digit numbers below 49 have digit products other than 36, so 49 is the smallest.

More Coding Interview Problems questions

Exams that ask this topic