 So let's talk about finding the greatest common divisors of two numbers, and the most efficient way of doing this is something called the Euclidean Algorithm. And this is actually based on some of our properties of divisor. Suppose I have d dividing two numbers, m and n, so d is a common divisor of the two numbers. Now, by my definition of divisibility, m is d times something, and n also is d times something. Now, that means that if I add or subtract m and n together, I get the addition or subtraction of two things that are d times something. My distributive property allows me to factor the d out, and so my definition of divisibility once again says that d is a divisor of m plus or minus n. And this is the basis for the Euclidean Algorithm. In general, if d divides two things, then d also divides their sum or difference. And remarkably, this rather simple observation allows us to find the greatest common divisors of two numbers very, very quickly and very, very easily. For example, here's the simple version of it. Suppose I want to find the greatest common divisor of these two numbers. Now, I can sit around trying to factor them, but that's going to take quite a while, but I may make the observation that if I have a number that divides both, then whatever that number is will divide their sum and their difference. So I can just figure out what their sum is, so I can be looking for something that divides this. Well, maybe that's a more difficult problem, but I could also be looking for something that divides the difference, which is just going to be five. And the nice thing here is there aren't that many possibilities. So the candidates, the things that could be a common divisor are things that divide five, and the only possibilities I have, five and one. And I can take a look at the two numbers themselves, and by inspection, or dividing if I don't notice that this is the case, five does not divide 37,897. So whatever the common divisor is, it can't be five, which means it has to be one. And so one is the greatest common divisor of the two numbers. Well, we can actually make our Euclidean algorithm a little bit more efficient if we include a little theorem. If I have a number that's a product of two other primes and P does not divide N, then neither does D. So if I have something I think or I hope will divide N, if I have a prime that doesn't divide N, the product can't either. And this is actually a theorem that it's easy to prove, so we can actually do a proof by contradiction here. So let's go and see what that looks like. So in general, we can always assume the antecedent of any statement we want to prove. We can always assume that we have the antecedent, this portion that follows the if and precedes the then, which means that my starting point is that I have a number that's a product of two primes and one of the primes does not divide N. So I get to assume this is true, that this is what I have. Now if I'm going to do a proof by contradiction, what I want to do is I want to take the then, the consequent, and I'm going to assume the negation of it. So here I want to prove that D does not divide N. So my starting point is I'm going to assume that I have D equals P times Q. P and Q are both primes and that P does not divide N. So I'll start with this. And I will also assume that D does in fact divide N. So I will assume that D does actually divide N. So this is again, I am assuming the opposite of what I want to actually prove. I want to prove D does not divide N. I'll assume that it does and see what happens. So let's take a look at that. So since D divides N, then I know by the definition of divisibility that N is D times X for some other number I don't know what it is. I don't really care what it is. I also know that D is equal to P times Q. So because this is an equality, I can replace the one with the other. So instead of writing D, I can write PQ. So N is PQ times X. And again, by our definition of divisibility, because N is P times some other stuff, I know that P divides N. However, I assume that P does not divide N. So I have a conclusion, P divides N, that contradicts something that I know to be true. And so there's my contradiction. And the only way to resolve this contradiction is that the additional assumption that we made at D does divide N must not be correct, must be impermissible. And so we must conclude that D does not divide N, which is what we wanted to prove. All right, so how can we use that? Well, let's consider the problem finding the greatest common divisor, 1,392 and 1,407. So again, by the preceding logic, anything that divides both will also divide their sum and also their difference. And again, their sum is a little bit more difficult to work with because it's a larger number, but the difference is pretty easy. It's 1,407 minus 1,392 is 15. So I can start by looking for things that divide 15. And it's useful to think about these things that divide 15 as candidates for the greatest common divisor. The greatest common divisor will be one of the things that divide 15, and we just have to figure out which one it is. So our possible candidates, things that divide 15, are 15 itself, 5, 3, and 1. Now it's useful to focus on the primes on the list because by the preceding theorem, if a prime doesn't divide N, then a prime that divides D, then D also does not divide N. So if I know that a prime doesn't divide N, I can get rid of a whole bunch of possibilities for what the greatest common divisor could be. So again, focusing on those primes, 5 doesn't divide 1,392, which means that whatever it is, it can't possibly be a common divisor, which means this has no chance of being the greatest common divisor. So 5 doesn't work. However, our preceding result notes that because 5 doesn't divide 1,392, neither can anything divisible by 5. So that also strikes 15 from the list of possibilities. If 5 fails, so will 15. Now we can do a direct division. It turns out 3 does actually work to divide both numbers. And again, our possibilities for the greatest common divisor, 15 fails, 5 fails, 3 succeeds, and it is larger than the other possibility. So 3 is going to be our greatest common divisor. Now, this actually gives us a number of ways of implementing the Euclidean algorithm. So here's an easy version. Let's see if we can find the greatest common divisor, 764 and 370. So again, whatever divides both, we'll also divide the difference of the two numbers. Again, we'll ignore the sum because we know that's going to be harder to work with. So whatever our greatest common divisor is, it's going to divide 390 as well. Now, I could do the same thing and figure out what divides 390, but if I have something that divides 764, 370, and 390, then it will also divide the sum and difference of any two of these numbers. And usefully, it will divide 390 minus 370. If it divides both of these, it'll divide their difference, which means it'll also divide 20. Again, whatever the greatest common divisor is, it has to divide these three numbers, which means it also has to divide 20, and that sharply limits our possibilities. So we look for things that divide 20, and I'll go ahead and set up our list of candidates, 20, 10, 5, 4, 2, and 1. So those are our possibilities. Now, it's probably easiest to start striking out things. So for example, 5 does not divide 764, which means not only does 5 not work, neither will anything that is divisible by 5. So 10 doesn't work, and 20 won't work as our greatest common divisor. We've just eliminated a whole bunch of possibilities. Now, we look at our prime cell in the list. 2 does divide both numbers. So that means 2 does divide, so it is a common divisor, and 4 is the case that we have to look at fairly closely, because 4 might work, but again, through direct division, we can find that 4 does not divide 370. So 4 fails, 5, 10, 20 also fail. 2 is the last prime standing, and so 2 is the greatest common divisor.