Extended Euclid’s algorithm also computes (integer coefficients) such that:

The algorithm works as follows:

  • if then
    • return
  • else
    • return

Where is the quotient of the division (for ).