3 The following algorithm finds the highest common factor of two positive integers. ("int (x)" stands for the integer part of x, e.g. int (7.8) = 7.)
\begin{figure}[h]
\includegraphics[alt={},max width=\textwidth]{b9ee9306-18ca-42b3-9f2e-b23849374b5e-4_888_693_422_717}
\captionsetup{labelformat=empty}
\caption{Fig. 3.1}
\end{figure}
- Run the algorithm with \(\mathrm { A } = 84\) and \(\mathrm { B } = 660\), showing all of your calculations.
- Run the algorithm with \(\mathrm { A } = 660\) and \(\mathrm { B } = 84\), showing as many calculations as are necessary.
- The algorithm is run with \(\mathrm { A } = 30\) and \(\mathrm { B } = 42\), and the result is shown in Table 3.2 below.
\begin{table}[h]
| A | B | Q | R 1 | R 2 |
| 30 | 42 | 1 | 12 | |
| 12 | 30 | 2 | | 6 |
| | | 6 | |
| 6 | 12 | 2 | | 0 |
\captionsetup{labelformat=empty}
\caption{Print 6}
\end{table}
Table 3.2
The first line of the table shows that \(12 = 42 - 1 \times 30\).
Use the second line to obtain a similar expression for 6 in terms of 30 and 12.
Hence express 6 in the form \(\mathrm { m } \times 30 - \mathrm { n } \times 42\), where m and n are integers.