Extended Euclidean algorithm for two integers
This functionality does not run in MATLAB.
igcdex(x, y) computes the nonnegative greatest common divisor g of the integers x and y and integers s and t such that g = sx + ty.
igcdex(x, y) returns an expression sequence g, s, t with three elements, where g is the nonnegative greatest common divisor of x and y and s, t are integers such that g = sx + ty. These data are computed by the extended Euclidean algorithm for integers.
igcdex(0, 0) returns the sequence 0, 1, 0. If x is non-zero, then igcdex(0, x) and igcdex(x, 0) return abs(x), 0, sign(x) and abs(x), sign(x), 0, respectively.
If both x and y are non-zero integers, then the numbers s,t satisfy the inequalities and .
The function numlib::igcdmult is an extension of igcdex for more than two arguments.
We compute the greatest common divisor of some integers:
The returned numbers satisfy the described equation:
[g, s, t] := [igcdex(9, 15)]; g = s*9 + t*15
If one argument is not a number, the result is the a symbolic igcdex call:
delete x: igcdex(4, x)
arithmetical expressions representing integers
Sequence of three integers, or a symbolic igcdex call.