Previous Page Next Page Contents

igcdex -- the extended Euclidean algorithm for two integers

Introduction

igcdex(x, y) computes the nonnegative greatest common divisor g of the integers x and y and integers s and t such that g = s*x + t*y.

Call(s)

igcdex(x, y)

Parameters

x, y - arithmetical expressions representing integers

Returns

a sequence of three integers, or a symbolic igcdex call.

Related Functions

div, divide, factor, gcd, gcdex, ifactor, igcd, ilcm, lcm, mod, numlib::igcdmult

Details

Example 1

We compute the greatest common divisor of some integers:

>> igcdex(-10, 6)
                                  2, 1, 2
>> igcdex(3839882200, 654365735423132432848652680)
                     109710920, -681651885490791809, 4

The returned numbers satisfy the described equation:

>> [g, s, t] := [igcdex(9, 15)];
   g = s*9 + t*15
                                [3, 2, -1]
      
                                   3 = 3

If one argument is not a number, the result is the a symbolic igcdex call:

>> delete x:
   igcdex(4, x)
                               igcdex(4, x)

Changes




Do you have questions or comments?


Copyright © SciFace Software GmbH & Co. KG 2000