ExtendedGCD
Usage
• ExtendedGCD[n, m] 给出整数 n 和 m 的扩充最大公约数.
Notes
• ExtendedGCD[n, m] 返回列表 g, r, s  , 其中 g 是 GCD[n, m], r 和 s 满足关系  . • 参见 Mathematica 全书 : 节 3.2.4.
Further Examples
The first element in the output from ExtendedGCD[n, m] is the greatest common divisor of the integers n and m.
In[1]:=
|
Out[1]=
|
In[2]:=
|
Out[2]=
|
The second element is a pair of integers. The linear combination of n and m with these as coefficients gives the gcd.
In[3]:=
|
Out[3]=
|
These two numbers are relatively prime.
In[4]:=
|
Out[4]=
|
Therefore this linear combination gives .
In[5]:=
|
Out[5]=
|
ExtendedGCD works on Gaussian integers as well.
In[6]:=
|
Out[6]=
|
This checks the results.
In[7]:=
|
Out[7]=
|
In[8]:=
|
Out[8]=
|
In[9]:=
|
Out[9]=
|
This clears the definitions.
In[10]:=
|
|