 Let's take a look at solving a couple more linear diaphantine equations. So, for example, we want to take the problem, find a multiple of 5 that leaves remainder 4 when divided by 17. Now, we can solve this equation the same way we did before. A multiple of 5 is going to be 5x, and if that's going to leave remainder 4 when divided by 17, it has to be a 17y plus 4 number. And so we have our equation 5x equals 17y plus 4. We'll divide by 5. We'll split off a part that's divisible by 5 and what's left over. We'll make sure our fraction is equal to some whole number, and we'll cross multiply and continue to get this sequence of equations. And once we've formed this sequence of equations, substituting any value into the last variable is going to give us a solution. But the question at hand is maybe we can look for an easier way to produce the sequence of equation. So, a little analysis goes a long way. Let's see where these equations are really coming from. So our first equation comes from solving the equation 5x equals 17y plus 4. And so we had our equation. We divided by 5. We split off a portion of our y term that was divisible by 5, and then we had what was left over. And that first portion was reducible to a nice simple expression, 3y in this case, and we get our final equation. And let's take this equation apart. There's four key components to it. First, we have the whole number y term, 3y. Next, we have this fraction where there's a y term in the numerator, 2y. There's a whole number portion of this numerator, 4. And the denominator of that fraction is going to be 5. And so what we might want to do is figure out where each of these four components come from. And the key here is to remember that we got this by dividing 17 by 5. And if we do that division, 17 divided by 5, we get 3 with remainder 2. And now let's compare our quotient with the four terms of our new equation. Well, the quotient itself, 3, is the coefficient of the whole number y term. The remainder 2 is the coefficient of y in the numerator of our fraction. The divisor is the denominator of our fraction. And that whole number part of our numerator, that plus 4, that actually comes from the desired remainder of the original problem. Remember, we wanted a remainder 4 when divided by 5. And so that's where that 4 comes from. And what this suggests is that the pieces of this new equation come from performing a specific division. Well, let's see if we can get our second equation that way. So our second equation we got by mandating that this fractional part 2y plus 4 over 5 should be a whole number. And so we rearranged it. 5z is equal to 2y plus 4. We solved for the term with the smaller coefficient 2y equals 5z minus 4. We divided by 2. We split our variable portion into a part that was divisible by 2. And the leftover. And again, we have four parts. We have a whole number z term, 2z. We have a z term in the numerator, z, but we'll think about that as 1z. We have a whole number part of the numerator, which is negative 4. We have the denominator of the fraction, which is going to be 2. And again, the key observation here is we're dividing 5 by 2. And if I do 5 divided by 2, what I get is 2 with remainder 1. And once again, that quotient 2 is going to be the coefficient of the whole number z term. The remainder 1 is going to be the coefficient of the z term in the numerator of our fraction. The divisor 2 is going to be the same as the denominator of our fraction. And again, the whole number portion of our numerator came from the original problem. We wanted remainder 4, but notice this time we're subtracting instead of adding. And if we put that together, this suggests a faster way to produce our equations. So let's think about that. If I have the equation x equals py plus ay plus b over c, where a is less than c, what I'm going to do is I'm going to divide c divided by a. Remember, a is a smaller number, so I'm going to divide the larger by the smaller. And that'll give me some quotient with some remainder. And that allows me to write down the next equation almost immediately. y is going to be q, that quotient times a new variable, z, plus remainder times new variable minus b divided by a. So r plus b in the original becomes minus b in the next one. And our denominator is going to be whatever we were dividing by. And we'll continue this process until we get a equals 1, at which point this fractional part is automatically going to be a whole number. So let's try it out. Let's say we want to find a multiple of 7 that leaves remainder 5 when divided by 19. And so a multiple of 7 that leaves remainder 5 when divided by 19 means we're looking for a multiple of 7, 7x, to be 5 more than a multiple of 19, to be 19y plus 5. Now we do have to make sure that our fractional part is in the right form. So if I divide through by 7, I get x equals 19y plus 5 over 7, but that'll reduce to 2y plus 5y plus 5 over 7. So there's my first equation, and I want 5y plus 5 over 7 to be a whole number. So I'm going to divide 7 by 5 to give me 1 with remainder 2. And that tells me the next equation is going to be 1z plus 2z minus 5 divided by 5. And so there's my next equation. Now once again, I want 2z minus 5 over 5 to be a whole number. So I'll divide 5 divided by 2. That gives me 2 with remainder 1. And that tells me my next equation is going to be 2w plus 1w plus 5 divided by 2. And again, I want w plus 5 divided by 2 to be a whole number. So I'm going to divide 2 by 1 to give me 2 with remainder 0. So our last equation is going to be w equals 2v plus 0v minus 5 divided by 1. And since I'm dividing by 1, I'm guaranteed that that last term is actually going to be a whole number. So that simplifies w equals 2v minus 5. And at this point, I can substitute a value for v to find w, to find z, to find y, to find x, and then to find my multiple of 7. Now, it's inconvenient to work with negative numbers, so this last equation w equals 2v minus 5. I can use any value I want to for v, but I'll pick v equals 3, so I'm at least starting with a positive number. So I'll pick v equals 3, that gives me w is equal to 2 times 3 minus 5, that's 1. Once I know the value of w, I'll substitute that into my equation for z, that's 2 times 1 plus 1 plus 5 over 2. And after all the dust settles, I get z equal to 5. I'll drop that into my equation for y. y equals 1 times 5 plus 2 times 5 minus 5. Substituting that in and letting the dust settle, I get y equal to 6. I'll drop that into my equation for x. x equals 2 times 6 plus 5 times 6 plus 5 over 7. And again, after all the dust settles, I get x equals 17. And finally, remember that we're actually looking for the multiple of 7. x is not the multiple of 7, but it's what you're going to multiply by 7. So our actual solution is going to be 7 times 17, that's 119. And we check if we divide 119 by 19, we get 6, which we don't really care about, but we do get remainder 5, which is what we do want. And there's the solution, one of the solutions to our problem.