Make Numbers Equal

Problem Overview

  • Given two integers A and B, repeatedly subtract the smaller from the larger (each operation costs 1) until they become equal; output the total cost.
  • Input: two space-separated integers A and B. Output: total cost (number of operations). Constraints: N/A.
  • Domain: basic arithmetic with iterative subtraction, modeling balancing/normalization where each adjustment has unit cost.
  • From Xperi interviews; this problem is a common coding interview and interview question.

Example

Unlock to view complete problem details

and practice with sample input/output

Was this article helpful?

View Test Cases & Run Code requires membership

Input Variables
Execution Result: