You are given two non-negative integers num1 and num2.
You repeatedly perform the following operation:
If num1 ≥ num2, replace num1 = num1 - num2.
Otherwise, replace num2 = num2 - num1.
Continue performing operations until either num1 = 0 or num2 = 0.
Your task is to count how many such operations are required.
This process behaves like repeatedly subtracting the smaller number from the larger until one becomes zero.
Input: num1 = 2, num2 = 3
Output: 3
Explanation:
Step 1: 3 - 2 → (2, 1) Step 2: 2 - 1 → (1, 1) Step 3: 1 - 1 → (0, 1) num1 is now zero → total operations = 3
Input: num1 = 10, num2 = 10
Output: 1
Explanation:
10 - 10 = 0 → only 1 operation needed.
Accepted:
Submission: