Data Structures & AlgorithmsModerateICPC regional · TCS NQT

Problem: The Euclidean algorithm is run on (1071, 462). How many division steps (a mod b operations) are performed until the remainder becomes 0?

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

Correct answer: C. 3

Each step replaces the pair by (b, a mod b) and counts one division; the loop ends when the remainder is zero. Counting subtraction steps instead gives a far larger number.

More Coding Interview Problems questions

Exams that ask this topic