 So, let's take a look at a more efficient way of performing a factorization. And so, we saw that you could factor n by using a difference of squares. And in general, one way we could find that was by finding two numbers, a and b, different numbers, whose squares were congruent mod n. Unfortunately, this in general takes too much time to be useful. It relies too much on happily picking the correct sets of numbers. And so, a more productive approach is to create such numbers whose squares are congruent mod n. And we'll approach that in the following way. We'll introduce the following term. A number is said to be b smooth. If all of its prime factors are less than or equal to whatever the number b is. And we can choose b to be arbitrary. And so, what this suggests is the following approach to factorization. What we might do is we might find some sequence of numbers and not necessarily consecutive numbers, but these are any set of numbers whose squares are all b smooth mod n. Now, when I take some of these numbers and multiply them together, because all of these numbers are formed by primes which are less than or equal to b, then when I multiply some of them together, I also end up with a number that's b smooth. And if I'm clever enough enough I have the right sequence of numbers, I have a chance of forming a product of some of these numbers, again not necessarily all of them, but some of these numbers whose square is a perfect square. So, for example, let's say I want to factor the numbers 63,787. And because I'm human, I'm going to choose to focus on values whose perfect squares are 19 smooth, which is to say all of the prime factors are 19 or less. And this does require the most amount of work here, so I have to kind of go through the numbers. And I find, for example, 439 squared congruent to 1360, which if I factor 2, 4, 5, and 17, likewise 441 squared, 3120 will factor as a product of primes that are less than 19. And I can find a few others that also satisfy this particular requirement. And the value 19 here I'll emphasize is really limited only by how much I want to work with. Again, because I'm human I'm going to limit myself to 19 smooth numbers, but if I were a computer and or if I were a computer program, this number could be as large as the largest prime that I want to work with. And so maybe I'll find another and at some point I'll decide I want to stop. And so I take a look at my list and I want to find a product of some of these numbers here that will give me a perfect square over here. And for right now I'll just make the observation that if I take the first number here, the fourth number, and the last number, let's get rid of all the rest of those. If I multiply these together, notice what's going to happen. Well there's my first number, 2 to the fourth 517, there's my second 2 to the third 7 squared 17, and there's my last 2 to the 11 times 5, and after all the dust settles, all of my prime factors have even powers, which means that the right hand side is a perfect square. The left hand side is a perfect square because it's a product of perfect squares. The right hand side is a perfect square because it is a product of primes raised even powers, and after all the dust settles, I find that I have produced the congruent 7270 squared congruent to 44942 squared. And then I can use my quadratic factorization method and my greatest common divisor of the difference between the two roots and the number I want to factor is going to be potentially one of the factors of the number, and that works out to be 227. And I can find the other factor 281. Well the difficulty with this approach is that I have to stare at this list of numbers and try to figure out how to put them together to form a perfect square. Fortunately, that's not actually that difficult if we do a little bit of algebra. So rather than rely on our keen powers of observation squirrel, we can do some algebra instead. Let's see, so what can we do here? All right, well so here's our idea here. Suppose I want to include some number of factors of this, some number of factors of this, some number of factors of this, some number of factors of this, some number of factors of this, and so on. So I want to include this number possibly more than once, so in practice it's not worth including it more than once, but if I were to do that, then what I can do is I can look at the number of primes in the factorization of the product. So for example, the number of twos in the product, well if I have x1 factors of this, I get four twos for each of those factors, so there's four x1 twos. I have x2 factors of this, and each of those contribute four twos, so again there's four x2 more twos. There's x3 factors of this, that doesn't give us any twos. There's x4 factors of this, that gives us three per factor, so there's three x4. There's eight per factor of this, and eleven per factor of this. So the number of twos in that product of x1 of these, x2 of these, x3 of these, and so on, the number of twos in that product is going to be given by that sum. Likewise, I can find the number of threes in that product. The ones that contribute to threes, the x2 contributes a three. The x3 contributes a three. And the x5 contributes a three. So there's my number of threes, and I can do the same thing for the other prime factors. Now here's why it's important that we work with b smooth numbers, because if I didn't have a b smooth numbers, I'd have two threes, five sevens, and potentially any prime up to whatever the largest prime I have. By focusing only on the b smooth numbers, I limit the number of, well these are equations, and I can do a little bit of algebra. Now, since our goal is to produce a perfect square, what I want to make sure of is that all of these numbers are even numbers. And I can work about two, because for two reasons. One, I only care whether these numbers are even, and so it doesn't make a difference to me whether this number is four, eight, 32, or 724. What matters is that it's not one, seven, 35, and so on. So I want to make sure that all of these are evens. Also, again, we're not going to ever take more than one factor of any of these numbers. So we might take zero factors, we might take one factor, but as far as this problem is concerned, no numbers besides zero or one exist, which says that it's just as easy to work on two. And so that system reduces considerably because things like eight x five, well that's a number congruent to zero mod two, and that's going to drop out entirely. And so I get a much nicer system of congruences. And I can apply some linear algebra to this system. I don't have to, it's just a lot easier if I do. Realistically, we are working with a system of eight unknown, so it's probably easy to apply linear algebra here. We have a system of congruences looking something like this. And we have a coefficient matrix looking something like this. And let's do a little bit of simplification. Now what's going to make our life much, much, much, much easier is that we're working mod two, which means that when I add one to one, I get zero. And everything else is just going to be what I would expect it to be. So I might reorder the rows a little bit. I'll move the seventh row up to the top. I'll swap those two rows around. And then I'll use this first row to clear everything below it. I'll add this to the third row. Remember, one plus one mod two is going to be zero. So I can add row one to row three, wipe those things out. And that column is all set. So now I'll move on to the second row. Now I'll take row two. I'll keep that in place. I'll add it to row three and row five. And I'll eliminate those. And again, my third row, I like that in place. I'm going to clear the third column. I'm going to take row three, add it to row four. Here's my row three, add it to row four. That's gone. Next row gone. Next row gone. And let's see. Now let's clear the fourth column. I'll clear those out, adding the numbers up. And last column wipes everything out. All right, now I'll convert this back into a system of equations. So what do I have? X one plus X four congruent to zero. That's our first row. X two, three, and five, congruent to zero. Three, four, five, and six. Four, five, six, and five, congruent to zero. And I can solve this using back substitution. So X five definitely has to be equal to zero. X four, if I make X four and X, if I make X four is zero, X five being zero, X six has to be zero. All of these being zero, X three has to be zero, both of these zero, X one has to be zero, X four zero, X one zero. If I make X four equal to zero, everything is zero, which doesn't give me any solution at all. It says take no factors of anything and that's not interesting. Here I'll take X four, kind of equal to one. That tells me that X six, if X four is one, X six also has to be one. And let's see, so I have X four, five, and six, and what do I have to X, X three? So four is one, five is zero, six is one. So that's one, one, X three has to be zero. X two, X three is zero, X five is zero, X two also has to be zero, if the congruence is going to be satisfied. And finally X one is going to be zero. And so remember what that tells me is that I should include the first factor, the fourth factor, and the sixth factor, which is what conclusion we came to earlier by just staring at the numbers. Here we did some linear algebra that made our lives a lot easier.