Extended Euclidean Algorithm
Submissions: 192   Accuracy:


  Difficulty: Basic   Marks: 1

We already know Basic Euclidean Algorithm. Now using Extended Euclidean Algorithm, Calculate the GCD and integer coefficients x, y using the same. x and y must satisfy the equation ax + by = gcd(a, b) 

The first line of input contains integer T denoting the numer of testcases.T testcases follow. Each testcase contains one line on input containing two numbers a and b.

For each testcase, in a new line, print the GCD g for a, b, integer coefficients x, y calculated using Extended Euclidean Algorithm.

1 <= T <= 103
1 <= a, b <= 106


35 15
5 1 -2

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

Author: SIDG

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 ide.geeksforgeeks.org, generate link and share the link here.

to report an issue on this page.