Euclidean Algorithm--can't seem to make it work backwards
I'm working a problem in my textbook and am stuck. Here's what I have so far:
GCD (34, 58)
58 = 34 x 1 + 24
34 = 24 x 1 + 10
24 = 10 x 2 + 4
10 = 4 x 2 + 2 = GCD (4, 2)
So working backwards:
2 = 10 - 4 x 2
= 10 - (24 - 10 x 2) x 2
= 10 x 2 - 24 + 10 x 2
= 10 x 4 - 24
= (34 - 24) x 4 - 24
And that's where I get lost. I work it through and cannot seem to get the right answer. I know that I need to get 12 to go with a and 7 to go with b, but how do I express this going backwards using the algorithm? There must be some mistake I'm making. Thanks in advance