 In this video, I want to introduce some vocabulary associated to divisibility of integers and then also use this as an opportunity to introduce the Euclidean algorithm, which is a very important algorithm for number theory related to divisibility of integers. Suppose we have two integers A and B, like so. Now if we have, if the following equation holds, if B equals A times K for some other integer K, then we say that A divides B, and so you'll write that as A slash B, which I should mention that you actually can use the vertical line button on the keyboard, but from a late tech point of view, a better symbol to do would be to write this as A backslash mid B. It'll be type set better, the spacing will be automatic and it won't look so primitive. Use backslash mid when one wants to latech this symbol. This is also the same symbol you can use when you just write a set of some kind. If ever you need to say that something is not divisible by, you just draw a slash through it. Again, latech has a little bit of a problem with this. With most symbols, you can just write not, not in front of it, and then you can negate the symbol, like you could say not equal and that would give you the not equal sign. You could do not, you know, sharp or something like that, although it's a protected symbol seen in slash there as well. You could do that. Now that'll just draw a slash through the symbol, which often works good, but for some situations there's built-in characters, like if you say backslash anyq, that gives you not equal sign, so you don't have to do a not equal. That's a little bit shorter. For the, for the divisibility symbol, you're going to want to do backslash in mid. That'll actually put the symbol, the slash in the right location, because if you don't use that, if you just type it's not mid, you'll actually get something that kind of looks like the following, which the slash is at the right position, so it looks kind of crude, so watch out for that. So we say that A divides B if, if there's some other number which we multiply by A gives you B, basic divisibility definition right there. And so the one would say that A is a divisor of B. We say that D is a common divisor of A and B if D divides A and D divides B. So it's a common divisor. Next we get to the definition we really want to get to in this, in this video here. The idea of the greatest common divisor. So if we have again two integers A and B, we will denote the greatest common divisor as the GCD of AB, which will often just say GCD itself as an abbreviation. So the greatest common divisor is going to be a positive integer D, such that D is a common divisor of AB. So first of all, the greatest common divisor is a common divisor itself. But what does the greatest mean in this situation? Well, oftentimes people define this in terms of inequalities of integers, right? So D would be the greatest common divisor because it's bigger than all the others. Now that, that is what we mean here, and that is true for the integers. But we're actually going to take a slightly different perspective because we actually want one that's going to be adaptable to other situations. So we say that the, the, the G is the greatest common divisor. If you take, it's a common divisor. And if you take any other divisor, common divisor, D prime, you have that D prime divides D. So it's the biggest common divisor. It's the biggest divisor because every other common divisor divides it. You don't have to worry about absolute value. We don't have to worry about less than or equal to something like that. The greatest common divisor is divisible by every common divisor of the two numbers. If the common divisor, if the greatest common divisor of two integers itself is one, we say that the integers are relatively prime, or sometimes we call this coprime for short, coprime. Now one important aspect about GCDs is the, if you have two non-negative integers A and B, then there exist integers R and S such that the GCD of A and B is equal to AR plus BS. That is to say that the greatest common divisor can be written as a linear combination, an integer linear combination of the two numbers you started with. There's some combination, some integer combination of the two numbers A and B that produces the GCD. And I should also mention that the GCD of any two integers is a unique quantity. And uniqueness basically is coming from this expression right here. In terms of linear combinations of the integers A and B, turns out that the GCD is actually the minimal number which can be written as a linear combination of A and B, right? And so how would one see that? Well, it turns out the proof of this theorem about GCDs as linear combinations is another application of the well-ordering principle. I'm gonna leave it as an exercise for the viewer here to prove this. It's very similar to how we prove the division algorithm. But I do want to mention that the set you would consider would be the following. Take the set of all possible linear combinations of A and B, where A and M are both integer values, but AM plus BN is strictly positive. Now, if that does positive, it doesn't mean that A and B have to be positive, right? But we do want the combination has to be positive. This will give us a, and let's see, I guess, I guess it could be great, that's fine as well. So equality, equality is fine if it's equal to zero. The reason we do this is that that would then force this set to be a subset of the natural numbers, and you can argue why that set is not empty. For example, this set would contain the numbers A and B themselves. Assuming those numbers are positive, right? So I guess we should say it would contain the absolute value of A, it would contain the absolute value of B. Because to get the absolute value of A, you're gonna take 0 times B, and then you'll take plus or minus A, depending on whether A is positive or negative, right? And so that'll get you in there, you can do the same thing for B. So this is a non-empty subset of the natural numbers. We can invoke the well-ordering principle, right? And then that gives us a minimal element. We're gonna call that minimal element D. And then we have to argue that that element D is, in fact, the greatest common divisor using the minimality condition. If it, again, I won't steal all the details for those watching. Just kind of give you an idea. It's very similar to what we did with the division algorithm. But like the proof of the division is gonna be non-constructive, it doesn't actually tell you what the GCD is. It just tells you that they exist and they're unique. Wonderful. We actually need an algorithm, and unlike the division algorithm, which we had this very nice algorithm from primary school, you don't typically have a good algorithm for finding GCDs from primary school. I mean, at some point, you might, what's the GCD between 12 and 18? Well, the algorithm typically gives you a factor, right? So I'm gonna get four times three, which factors as two and two, right? 18 factors as like nine and two. Then you factor that, I get three and three. And so putting the prime divisors together, you have a common two, you have a common three. So the GCD of 12 and 18 is equal to six. This wasn't so bad because 12 and six are pretty simple, but factoring an integer turns out is a very computationally difficult problem, right? Modern day RSA cryptosystems and things similar to that are actually based upon the fact that factoring numbers is a hard problem. And so any algorithm that relies on factoring integers turns out is an inefficient algorithm. So if our GCD calculation is based upon factoring, then it's gonna take a long time, so to speak. Factoring is a hard process. Issued algorithm for finding the GCD, kind of like the division algorithm that doesn't depend on factoring whatsoever. And the answer is the Euclidean algorithm, which I wanna present this in case we haven't seen this before, even if we have, it's probably a good review. The Euclidean algorithm gets its name because basically a version of the type of algorithm we're gonna see right here can be found in Euclidean's elements. The classic, classic mathematical text, you really can't get more classic than Euclidean's elements which are here. And so I'm gonna demonstrate the algorithm via example, that's not always the best way to do it, but I think there'll be sufficient purposes. Let's take two integers, 945 and 2415. I wanna take integers that are not immediately obvious what their factorizations are. You might already be thinking in your head, they're both divisible by five, and although that's true, let's look at how the Euclidean algorithm works. So the Euclidean algorithm really basically comes in two phases. So the first phase of the Euclidean algorithm, this is gonna be the division phase. In which case we're gonna use the division algorithm we talked about earlier, and this is actually gonna be a repeated division phase. So what you're gonna do is you're gonna take the smaller of the two numbers and divide it by the bigger of the two. So we wanna find a quotient and a remainder, right? So we're supposed to find our numbers Q and R such that A equals Q times B plus R. And so we can see very quickly, when you take 2415 divided by 945, you're gonna get a quotient of two and a remainder of 525. Great, that's the first step. You do division there. Then once you do division, you're gonna take the second number and then you're gonna divide that by the remainder. So you're gonna repeat this process. You're gonna take the second number and divide it by its remainder. So 945 divided by the remainder, you're gonna get a 525. And so every time you do this you're kinda getting a new remainder. So your first remainder, we're gonna call it R0, that was the smaller of the two numbers, in this case it was an A. Then we find the first remainder, you get 525. Now you're gonna divide R0 by R1 and get a new remainder, R2, which is going to be 420 right here. Then you're gonna take R1 divided by R2 and find the remainder in that regard. So you get R1 right here, R2. You're gonna get a quotient of one remainder of 105. And so that's gonna be our R3. Now you're gonna take R2 divided by R1. So you just repeatedly divide the old remainder by the new remainder until eventually you get divisibility here, right? So eventually our next one here is gonna be we take R2 divided by R3. In this case, the remainder gives us zero. This tells us that R3 divides R2. Whenever you find a divisibility statement like this, this tells us that R3 is the GCD that we were seeking. So this is how we can find our GCD. So we now have a constructive algorithm. We just will continue to just do, we just repeat division over and over and over again, dividing remainders by new remainders over and over again till we find a place where this terminates. It'll terminate at the GCD. Explanation why that's gonna work here, right? Because if 2415 and 945 have a common divisor, then that means that common divisor has to divide 525 as well. This is basically, this just follows from like collectivizability conditions, right? Because if you subtract the two numbers, right, you're gonna get 2415 minus two times 945. This equals 525, right? So our common divisor divides this number, divides this number, so divides the difference, which is 525. So whatever the greatest common divisor is, it's gonna divide the remainder R1. So therefore, R0 and R1 have a common divisor, which would be the GCD of those two numbers, and that's why we play this game again, all right? So these two numbers will have, their GCD will divide 420. And then the GCD of those two will also divide 105. And then do we eventually go until we find divisibility there? And the fact that the GCD is the greatest common divisor will then give us, it'll guarantee that this thing, when this process terminates, we get the GCD. So this tells us how one can compute GCDs, which is very useful. But what about the combination business? How do we write 2415 and 945 as a combination to give us 105? Well, it turns out that's where we get into phase two of the Euclidean algorithm, because when we do all these divisions, we don't just record the remainders, we actually want to keep track of everything along the way. We kept very good notes, right? We kept this sequence of equations. What we're going to do is we're going to start reversing this process. Let me kind of get these things out of the way here. We're going to reverse this process. So in phase two, the second phase, we're going to back substitute, back substitute to find this combination. So if you take, for example, the previous equation, so you don't do the last equation. The last equation tells you who the GCD is. The equation above that will of course have that GCD. Solve for the remainder in that situation. So you're going to get that 105 when you solve for it in this equation. That's equal to 525 minus 420. Now 420, right? 420 was the remainder of the previous equation. Solve this equation for 420, right? That would give us 945 minus 525. And you're going to substitute that in for 420. When you do that, you get the following expression right here. 525 minus 945 minus 525. You can notice there's 525s here. You can combine those together. And you're going to get 2 times 525 minus 945. Now the number of 525 was also a remainder. I mean, admittedly, no, actually, no, it was a remainder. Yeah, so we saw 525 also as the remainder of the first equation. So taking this equation, we could substitute, we could solve for 525, get 2415 minus 2 times 945. Like so, substitute that in right here. And when one does that, you get the following equation. Two times, well, the 525 popped away. You get 2415 minus 292 times 945. But you also have a minus 945 right there. Combine like terms, right? You're going to end up with 2 times 2415 minus 5 times 945. And so as we did this process, we were always equal to 105 the entire time, the GCD. And therefore, we see that, I think I switched up my A and my B right there. We're going to get, this is that 105 is 2 times B minus 5 times A, keeping the same A and B we had from before here. But we now found our combination. We want to take 2 times 2415, and we want to take minus 5 times 945. And so we had expressed the GCD as a linear combination for any two-in injurers. And in fact, this process is very quick. The division algorithm works very, very, very quickly. The difficulty really just comes down to finding the quotients, which we won't go into saying the division algorithm is optimal, a very fast algorithm. And then when you couple it with this back substitution process, that's also pretty quick in terms of computational complexity. In fact, we can be a little bit more predictive on what the coefficients are going to be. We can actually kind of jump all of these steps right here and get to the final linear combination by looking at coefficients along the way. I'm not going to worry about a general formula right here, but be aware that on a computer algebra system, the algorithm can be done very, very, very quickly. And so we can find GCDs, impact linear combinations of GCDs in very quick time. In which case, finding GCDs probably going to be clear to us why that's important, but we'll see later on why finding linear combinations will be important for us when it comes to GCDs in the not too distant future.