Objective
The modular inverse of a modulo m is the number x between 0 and m-1 such that a * x % m == 1. It exists only if a and m are coprime, and it is computed with the extended Euclidean algorithm.
Instructions
- The first line has the number
nof cases. Each case is a line withaandm. - Show the inverse of
amodulom, or-1if it does not exist.
3
3 7
2 4
10 17
5
-1
12
Open the editor in full screen: the statement on the left and your code, the output and the tests on the right.
Start exercise