Euclid's algorithm tutorial

376 Views Asked by At

I am learning about the Euclidean algorithm, and here is an image with the workings.

enter image description here

I got stuck towards the end.

My friend tried to help me, saying just put the three together. I understand that on the second line the equation is rearranged, however I do not understand how we got to the third line:

3 - 1*26 + 8*3 
= 3 + 8*3 - 1*26 
= (1+8)*3 - 1*26

In the image, I can see that v = 9 because of the 3v where 9 * 3. However, I do not understand why w = -1 when on the last line 9*3 = 1+1 * 26 has no negative numbers?

1

There are 1 best solutions below

2
On

The last line is not in the form $3v + 26w = 1$.

So you aren't done yet.

To get $3\cdot 9 = 1 + 1\cdot 26$ to the form $3w +26v = 1$ where the $3w$ and $26v$ are both on the LEFT HAND SIDE and the $1$ is all by itself on the RIGHT HAND SIDE, we will have to subtract $26\cdot 1$ from both side.

$3\cdot 9 = 1 + 1\cdot 26$
$3\cdot 9 - 1\cdot 26 = 1 $

NOW it is in the form of $3v + 26w = 1$. ...

(Note: If $3v+26w =1$ and $3,26 >1$ we know from the get-go that one of the numbers will have to be negative. Otherwise you'd get a number much bigger than $1$)

.....

Actually, it is funny how (at least to me) the equation

$9 w + 26v = 1$

looks a feels very different to me than

$9 w = 1 + 26b$

But the are completely equivalent.