Subtraction and two numbers
Submissions: 916   Accuracy:


  Difficulty: Easy   Marks: 2

You will be given a pair of positive integers (x, y). In one step, you take the greater of the two integers and subtract the smaller one from it. You keep doing this untill one of the integers becomes 0 and then you stop. For example: (5,13) --> (5,8) --> (5,3) --> (2,3) --> (2,1) --> (1,1) --> (1,0). This takes 6 steps in this case. You have to find out the number of steps it takes to reach a situation where one of the integers becomes 0.

The first line of input contains a single integer T denoting the number of test cases. Then T test cases follow. Each test case consists of one line only. The line consists one two space separated positive integers which denote (xi, yi).

Corresponding to each test case, in a new line, print the number of steps.

1 ≤ T ≤ 200
1 ≤  xi, yi ≤ 109

232 8
1 354



** For More Input/Output Examples Use 'Expected Output' option **

Author: Hemang Sarkar

If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.

Need help with your code? Please use, generate link and share the link here.

to report an issue on this page.