Content deleted Content added
No edit summary |
got rid of some "inline" TeX; added some nonbreakable spaces |
||
Line 5:
Say we want to obtain the GCD of the two integers ''a'' and ''b''. Let ''a'' ≥ ''b''.
* If ''b'' contains only one digit (in the chosen [[radix|base]], say
* If ''a'' and ''b'' differ in the length of digits, perform a division so that ''a'' and ''b'' are equal in length, with length equal to ''m''.
* ''Outer loop:'' Iterate until one of ''a'' or ''b'' is zero:
** Decrease ''m'' by one. Let ''x'' be the leading (most significant) digit in ''a'',
** Initialize a 2
*::<math>\textstyle
\begin{bmatrix} A & B & x\\ C & D & y \end{bmatrix}
Line 15:
\begin{bmatrix} 1 & 0 & x \\ 0 & 1 & y\end{bmatrix}
</math>,
*:and perform the euclidean algorithm simultaneously on the pairs
*:* Compute the quotients ''w''<sub>1</sub> of the long divisions of (''x'' + ''A'') by (''y'' + ''C'') and ''w''<sub>2</sub> of (''x'' + ''B'') by (''y'' + ''D'') respectively. Also let ''w'' be the (not computed) quotient from the current long division in the chain of long divisions of the euclidean algorithm.
*** If ''w''<sub>1</sub> ≠ ''w''<sub>2</sub>, then break out of the inner iteration. Else set ''w'' to ''w''<sub>1</sub> (or
*** Replace the current matrix
**::<math>\textstyle \begin{bmatrix} A & B & x \\ C & D & y \end{bmatrix}</math>
Line 28:
</math>
**:according to the matrix formulation of the extended euclidean algorithm.
***If ''B'' ≠
** If ''B''
** Set ''a'' to ''aA''
==References==
|