Basic Number Theory

Linear Congruences

In general, then, to solve ax b (mod m) we need to find the inverse of a modulo m, multiply and simplify:

ax b (mod m)
aax ab (mod m)
x ab (mod m)

The difficult part is finding the inverse a. If aa 1 (mod m) then 1 − aa = km for some integer k. This means, however, that

1 = aa + km

If gcd(a,m) = 1 then we can "run the Euclidean algorithm backwards" to express 1 as a linear combination of a and m; this is exactly what we need to do to find a.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28