 One of the biggest problems in all of mathematics involves finding the greatest common divisor of a set of numbers. So first off, we define the greatest common divisor of two integers m and n, which we write this way, is the largest integer that divides both. Now in some case that largest integer is 1, and so if the greatest common divisor of m and n is equal to 1, we say that m and n are relatively prime. So you've probably learned the worst method to find the greatest common divisor, and that's this. To find the greatest common divisor, we can factor both numbers. And the thing to realize here is this is a terrible method. It only works for very simple and very small numbers, but not really for anything else. So it's all right if you want to find the greatest common divisor of 24 and 36, but finding the greatest common divisor of 1,093 and 2,071 is painful, and these numbers are tiny, and in fact even these numbers are small compared to what we actually need to work with. So a little bit of analysis goes a long way. A useful strategy in mathematics is to ask, what are the properties of the thing I'm looking for? Suppose d is the greatest common divisor of both m and n, where we'll assume that m is greater than n. Then m is d times something, and n is d times something. And what this means is that if I add or subtract m and n, I get ds plus or minus dt, and since both terms have a common factor of d, we could remove it, which tells me that d divides m plus or minus n. So for example, if we want to find the greatest common divisor of 31946 and 31941, well let d be the greatest common divisor, then we know that d will also be a divisor of 31946 plus or minus 31941. Now we note that if we add them, we get a larger number, and the divisors of 6, 3, 8, 8, 7 are too hard to find right now. At the same time, the greatest common divisor of 31946 and 31941 will also be a divisor of 31946 minus 31941, and that's 5, as of the GCD is something that divides 5. But the only things that divide 5 are 1 and 5. And it's worth noting that 5 is not a common divisor. It's not actually even a divisor of either of these two numbers, so it's not a greatest common divisor. And what this means is that our only choice for the greatest common divisor is 1. And so the greatest common divisor 31946 and 31941 is 1. And while we're at it, we might as well note that this means that the numbers are relatively prime. Another useful strategy in mathematics is lather, rinse, repeat. Once we do something one time, we can do it as many times as we want to. So if the greatest common divisor of m and n is d, then m is ds and n is dt. So m minus n is d times s minus t. We figured that out already, but m minus 2n is ds minus 2dt, and a factor of d can be removed, giving us. And so m minus 2n is d times s minus 2t. Similarly, m minus 3n is, which means that m minus any multiple of n is also going to be divisible by d. So for example, we want to find the greatest common divisor 319 in 1005. If d is the greatest common divisor, then d will divide their difference 2014. But 2014 is too big to factor easily, so it'll be a lot of work binding the factors. But we can subtract 1005 again. So if d is the greatest common divisor, then d will also divide 319 minus 2 times 1005, which is. But 1009 is too big to factor easily, so it'll be a lot of work finding the factors. So again, if d is the greatest common divisor, then d will divide 319 minus 3 times 1005. And so d will be a divisor of 4, and that's easy to figure out what divides 4. So d must be either 1, 2, or 4. But since 319 and 1005 are both odd, they can't be divisible by 2 or by 4, which means that our only choice for the greatest common divisor is 1. And so the GCD must also be 1. And this suggests that if the greatest common divisor of m and n, then d must divide all of m minus n, m minus 2n, m minus 3n. But there's a least value, m minus qn, equal to r. What is that least value? Well, if you consider what we're actually doing here, this corresponds to a division, and the least value, m minus qn, is the remainder when we divide m by n. In other words, suppose the greatest common divisor of m and n is d, and we'll assume that m is greater than n, and m divided by n is q with remainder r. Then whatever our greatest common divisor is, that greatest common divisor will also divide our remainder. So for example, let's find the greatest common divisor of 1075 and 255. And so we find by division that 1075 divided by 255 is 4 with remainder 55. And so we know that whatever our greatest common divisor is, it must divide 55. And we're fortunate 55 doesn't have too many divisors. The only divisors of 55 are 1, 5, 11, and 55. Now at this point, the obvious question is, well, how do we know which one of these is the greatest common divisor? And we might engage in a little bit of wishful thinking if only there was a way of figuring out whether one of these numbers divided both of these numbers. Oh, we could actually figure that out because we can just do a trial division. So let's see if 1075 is divisible by 55 or 11 or 5. And since dividing by 55 or 11 leaves us a remainder, these are not divisors. But since dividing by 5 leaves us with a remainder of 0, that means that 5 is the GCD.