 Let's look at another factorization method that's called Pollard's P-1 factorization. And this is based on the Euler Fermat theorem. And this goes back to the idea, suppose I have two prime numbers and N is a product of those two primes. The Euler Fermat theorem guarantees that for any value A relatively prime to P, A to power P-1 is going to be congruent to one mod P. Now, it's worth pointing out that we don't actually know the value of P. On the other hand, it's a fairly standard strategy in mathematics to say, well, what happens if we just work with it and see what, and then maybe something interesting will happen? So let's start with this idea that I know this congruence holds, even if I don't know what the value of P is. I'll suppose P-1 is a factor of some number L. And then I know that L is P-1 times K. So what can I do? Well, A to power L is going to be congruent to A to power P-1 times K, because it's the same thing. This inside expression here, though, is congruent to one. So that means this entire expression also evaluates to one. And so that tells me P divides the difference A to the L minus one. And remember, P is a factor of N as well. So that tells me that the greatest common divisor of A to the L minus one and N will also include P. And that gives us a way of factoring N with one slight problem. How do we find L? Because if A to the L is not congruent to one mod P, this doesn't work. So I have to know what the right value of L is in order to make this work. Well, it wouldn't be an algorithm if we didn't have some way of finding it. So let's approach that. So this is Pollard's P minus one algorithm. And if I want to factor some number N, I'm going to choose a base that's relatively prime to N. I'm going to evaluate A to the K factorial for K equals 1, 2, 3 up to some practical limit, whatever we want to do as far as we want to take this computation. And we'll find the greatest common divisor of A to the K factorial minus 1 mod N and N itself. And you'll note that because we're finding A to the K factorial, there's a good chance in this product that we're going to include P minus one. And so we'll get A to the P minus one to something. And that may hopefully be congruent to one and our greatest common divisor, A to the K minus one and N will be one of the factors of N. Now, again, we might not have the actual value of P minus one in there. So it's possible that our greatest common divisor is going to be one. And it's also possible that we may have too much in there. And our greatest common divisor is going to be N itself. And so we look for any non-trivial greatest common divisor and whatever it is, that's going to be something that will factor N. For example, let's try to factor 1,403. So I'll take A equals, oh, I don't know, two. And I'll evaluate two to the K factorial mod 1403 for K equals 234. And so on as far as I care to work it. So let's figure that out. Two to the two factorial congruent to four. And I'll find the greatest common divisor of two to the two factorial minus one in 1403. And the GCD is one, which is a trivial factor. So we'll go on to the next. Now, one of the things that makes this computation only feasible is that when I evaluate these higher powers, remember the factorials are defined recursively. So three factorial is two factorial times three. So I can evaluate two to the three factorial as two to the two factorial raised to the third power. And that's going to be four to the third, 64. And again, I'm going to look at the greatest common divisor of that number minus one and 1403. Again, that's going to be one, so I'll continue and find the next term. So four factorial is the previous to the fourth power, 142. I'll find the greatest common divisor of the number minus one and the number of interest. Again, one, so I'll continue. The next greatest common divisor of the number minus one and 1403 is 61, which tells me that 61 divides both of these. I didn't actually care about dividing this, but 61 divides it into 1403, gives us the other factor. Oh, let's take another example. So I'm going to take two again and I'll evaluate a to the k factorial. So again, greatest common divisor of the number minus one and the number of interest is one, trivial factor, we'll go on to the next. Again, every factorial is the preceding factorial raised to a specific power. And again, we find the greatest common divisor, number minus one, number of interest, again one, so we move on to the next. The fourth greatest common divisor, again, one, move on to the next. Greatest common divisor of the number minus one is 41, and that gives us one factor.