text: If  divides  evenly, the algorithm executes only one iteration, and we have  at the end of the algorithm. It is the only case where the output is an integer.
  Computing multiplicative inverses in modular structures
  The extended Euclidean algorithm is the essential tool for computing multiplicative inverses in modular structures, typically the modular integers and the algebraic field extensions. A notable instance of the latter case are the finite fields of non-prime order.
  Modular integers
  If  is a positive integer, the ring  may be identified with the set  of the remainders of Euclidean division by , the addition  and the multiplication consisting in taking the remainder by  of the result of the addition and the multiplication of integers. An element  of  has a multiplicative inverse (that is, it is a unit) if it is coprime to . In particular, if  is prime,  has a multiplicative inverse if it is not zero (modulo ). Thus  is a field if and only if  is prime.
  Bézout's identity asserts that  and  are coprime if and only if there exist integers  and  such that
  Reducing this identity modulo  gives
  Thus , or, more exactly, the remainder of the division of  by , is the multiplicative inverse of  modulo .