 One of the nice simple methods of determining whether a number is composite is known as the Miller-Rabin test. Again, like the Euler-Fermat test, this does not guarantee a number is prime, but it will tell us when a number is composite, particularly those Carmichael numbers. And the Miller-Rabin test works as follows. As always, we're going to choose a base that is relatively prime to the modulus. And you might consider why we need that, what if the base is not relatively prime to the modulus? If n is odd, we'll let n minus 1 be 2 to the k m, where m is odd, so essentially we're factoring out all powers of 2 from n. And again, the question you might consider is what happens if n is even. And we're going to evaluate the following sequence, a to the m, a to the m squared, a to the m to the fourth, to the eighth, and so on all the way up to a to the m to the 2k, which is m times 2k is n minus 1. Now, what we're going to do is we're going to look through this sequence, and we're going to find the first term in the sequence that's congruent to 1. So again, if we are even applying this test, we know this last term has to be congruent to 1, which suggests that the number might be prime. And then we'll find this first term that's congruent to 1, and we'll look at the preceding term. If the preceding term is not congruent to minus 1, then we know that n is a composite number, and a is a witness that n is composite. For example, let's take a look at 561 and see whether that's composite. And so we'll first of all factor 561 minus 1, that works out to be 2 to the fourth times 35. And again, I'll pick a equals 2 as a convenient base to work with. We'll find 2 to the power of 35, 2 to the power of 35 squared, 2 to the power of 35 to the fourth, to the eighth, to the sixteenth, and at this point we can stop. We now have a term that's congruent to 1 mod 561, so we look at the preceding term. If this preceding term is not congruent to negative 1, we know that our original number has to be composite. So this is very similar to the test that we have in the Euler Fermat theorem. We look at the value of a power of the base, but we can actually go a little bit farther. Once we have our term not congruent to negative 1, then we actually are able to factor the number, and that proceeds as follows. Because every term in this sequence is the square of the preceding term, this last set of congruences gives us something very useful. If I square 67, I get 1 mod 561. So 67 squared is going to be 1, because that's this squared, and I'll rearrange that a little bit. This is 67 squared minus 1 is 0 mod 561, which tells me that 67 squared minus 1 factors as a sum and difference, 66 times 68. Well, because the product is congruent to 0 mod 561, I know that 561 divides the product 66 times 68. However, 66 and 68 are both less than 561, so that means that some of the factors of 561 have to be in 66, and the rest of them have to be in 68. And so that tells me if I look for the greatest common divisor between 66 and 561, I'll get some of the factors. And if I look at the greatest common divisor of 68 and 561, I'll get the other factors. So I'll use the Euclidean algorithm to find that the greatest common divisor of 561 and 66 is 33, which is 3 times 11. And once I have the two factors of 561, I can find the others by division. But I can also use the Euclidean algorithm and find that the greatest common divisor of 561 and 68 is 17. And that gives me my factorization. Well, what about 89 and 11? Well, let's try that again. Again, we'll use a equal to 2, and we'll verify that the greatest common divisor of our base and our modulus is going to be 1. The n minus 1 is 8910, which is going to be 2 times 4455. So I'll evaluate 2 to the 4455 mod 8911 and square it. And again, the first term where the power is 1 and the preceding term is not congruent to negative 1. So I know that my original number 8911 has to be composite. And again, I can find what those factors are because I know that this squared is congruent to 1. And again, that gives me the possibility of factoring by the difference of two squares. And I know, again, because the product is congruent to 0, I know 8911 divides these two numbers. And I know, therefore, that some of the factors have to come from here and the rest of the factors have to come from there. So I'll find the greatest common divisor of the two numbers, and that gives me my factorization. And if we want to, we can go a little bit farther. 201273 does also factor its 19 times 67. So this number 8911 is 7 times 19 times 67.