Counting Euclid's Steps
Run Euclid's algorithm on (A, B): repeatedly replace (a, b) by (b, a mod b) until b = 0. Print how many replacement steps happen.
Input: one line with two integers A and B.
Output: the number of steps until b becomes 0.
Constraints:
- 1 ≤ A, B ≤ 1018
Sample Tests
Input 1
48 18
Output 1
3
Input 2
7 7
Output 2
1
Discussion (opens after you solve — no spoilers before)
No comments yet.