Linear Congruences

Example: Find the inverse of 14 modulo 19.

19 = 1 * 14 + 5
14 = 2 *  5 + 4
 5 = 1 *  4 + 1
 4 = 4 *  1 + 0
 
Now reverse things to express 1 as a linear combination of 14 and 19:
1 =  1 *  5 − 1 *  4
  =  1 *  5 − 1 * (14 − 2 * 5)
  = −1 * 14 + 3 *  5
  = −1 * 14 + 3 * (19 − 1 * 14)
  =  3 * 19 − 4 * 14
  =  3 * 19 + (−4) * 14