Data Structures & AlgorithmsModerateTCS NQT · Product Company OA

Problem: What is the smallest integer x >= 100 divisible by 13? Run the code.

Problem: What is the smallest integer x >= 100 divisible by 13? Run the code.
print(next(x for x in range(100, 200) if x % 13 == 0))
What is printed?
  1. A. 104
  2. B. 100
  3. C. 117
  4. D. 130

Correct answer: A. 104

100 = 13 × 7 + 9, so 100 itself fails the test and the first multiple at or above 100 is 13 × 8 = 104. Jumping to 13 × 9 = 117 skips that first valid multiple.

More Coding Interview Problems questions

Exams that ask this topic