Extended Euclidean Algorithm - need help understanding 1 step

•

**This comes from my notes. At the bottom where it says: 2*(50 - 1*35) = 3*35 - 2*50,**

**I am not figuring out 3 and the 2 come from in 3*35 - 2*50. I tried multiplying which gives me the 2*50 but the 3*35 I do not understand how they getting that.**

**This is easier with an example: **

**Solve 135***x*** + 50***y*** = gcd(135, 50) **

**135 = 2****·50 + 35 **

**50 = 1·35 + 15 **

**35 = 2·15 + 5 **

**15 = 3·5 + 0, so gcd(135, 50) = 5 **

**5 = 35 – 2·15 **

**15 = 50 – 1·35, **

**so 5 = 35 – 2·(50 – 1·35) = 3·35 – 2·50 **

**35 = 135 – ****2****·50, **

**so 5 = 3·(135 – ****2****·50) – 2·50 = 3·135 – 8·50 (x = 3, y = -8) **