 Okay, so let's take a look at what's generally regarded as the first really important result in number theory. And this goes by the name of the Euler Fermat theorem. And that's because it was actually first noted by Fermat, a 17th century mathematician. But Euler, an 18th century mathematician, was the first person to actually do something with it more than just make the observation. So this also goes back to the discrete logarithm problem. DLP, we're trying to solve the congruence a to the power x congruent to b mod n. So again, this is a nonlinear congruence and it's believed to be a very hard problem to solve if n is sufficiently large. Well, let's make our problem at least a little bit easier and try to solve the problem a to the power x congruent to 1 mod n. Now, we've already seen that if the greatest common divisor of a and n is 1, then we know this equation has a solution in some place. We did that last time, but how do we find this solution? Well, let's split the problem into a couple of different cases. Number theory, we like working with prime numbers, so let's assume that n is a prime number. And so for any value less than n, I know the greatest common divisor of a and n is guaranteed to be 1. And so again, I know there's a solution and since all the solutions are integers, there has to be a least positive solution. And I'll call that x equals k. Well, I know that k has to be less than or equal to n minus 1. Again, you might want to think about why that has to be the case. And so let's consider these terms. So I'm going to find the powers of a starting with a to the zero power, that's going to be 1 itself, all the way up to a to the power k minus 1, and I'm going to reduce those mod n. Now, all of these terms have to be different. Again, you might want to think about why that's the case. Remember, we assumed that k was the least positive exponent for which a to the power k was congruent to 1. So none of these in here could be congruent to 1. And what that implies incidentally is that all of the terms there must be different. Now, if k is actually equal to n minus 1, well, there's k terms in this sequence, there's n minus 1 k possible remainders mod n, and so this sequence has to include all possible remainders. Now, if k is not equal to n minus 1, k is something else, then there's at least one remainder that we are not including in this list. There is a remainder that is not among these powers of a. So what I'm going to do is I'm going to multiply every term of that sequence by whatever this remainder that I'm not including is, and they get a new sequence of terms. Now, these terms have to be different from each other, and they also have to be different from the terms in this sequence. In other words, this sequence here and this sequence here consist of completely distinct numbers. They are completely different. And again, you might want to think about why that has to be the case. Now, because they're different, what we have is we have k plus k, we have 2k total values. And what that means is that if all of the remainders are included, either here or here, then 2k is equal to n minus 1. So if all of our remainders are in either this sequence or in this sequence, 2k is n minus 1, so that tells me k is n minus 1 over 2. On the other hand, suppose I don't have all the remainders. Well, in math, you want to do something once, you can do it any number of times. And so if there's a remainder that I don't have, well, I can multiply that remainder that's not represented by all of these, and they get a new sequence. And as before, the terms of this sequence have to be different from each other, and they have to be different from the terms of this sequence and from the terms of this sequence. And so I now have k plus k plus k. I have 3k remainders, and either I have all the remainders, so 3k equals n minus 1, k equals n minus 1 over 3, or I don't. If I don't, if there's some remainder not included, I'll do the same thing. I'll form a fourth sequence, and again, the 4k terms I get will either include all the remainders, in which case n minus 1 is divisible by 4, or they won't. And in general, as I continue this proof, what best tells me is that if n is a prime number, and a to the power of k is congruent to 1 mod n, then I know that k divides n minus 1. Well, okay, let's take a look at what happens if n is composite. Well, it turns out that once you do the proof for n being prime, the proof for n being composite is very similar. The only difference is that this sequence that we have been using has to contain or has to be include only those numbers that are relatively prime to n. Well, there's phi of n such numbers. So as before, this either includes all the numbers that are relatively prime to n, or if one of them is missing, we'll multiply the sequence by the missing number, get a new sequence that, which must be different, but include only things that are relatively prime to n, and so on. And so, all together, if we put everything together, this tells us the following. If I have a number that is relatively prime to whatever n is, the least positive solution to 8 power x congruent to 1 mod n has to be a divisor of phi of n. And the nice thing about this is this gives us a bunch of candidates for the solutions of this equation. Well, let's take a look at that. So, here's a problem. Find the least positive solution to 5 to power x congruent to 1 mod 89. And so what do I know? Well, 89 is prime. So, I can find phi of 89 easily. It's just 88. So, whatever solves this equation, this congruent, must be a divisor of 88. Well, I can just list those divisors. And unfortunately, at this point, what we have to do is we have to try out each one of our candidates to see which one actually works as a solution. So, I need to find 5, well, 5 I know is not going to be a solution, 5 to the second, 5 to the fourth, 5 to the eighth. And so, I'm going to test each one to see which one works. So, 5 squared is 25. Squared again gives us 2. Again, gives us 4. And so on, we can find them. And here we go, 5 to power 44 works out to be congruent to 1. So, x equals 44 is the least positive solution. Now, it's worth noting that this means that the powers of 5 from 5 to the first to 5 to the 44th are all going to be distinct. There's going to be 44 different powers of 5, congruent mod 89. And note that there's actually 88 different possible remainders. So, that says that half the remainders can't be found this way. Well, let's try a different problem. 12 to power x, congruent to 1 mod 91. Now, 91 is not prime, but it is 7 times 13. So, we can find phi of 91. It's the product of 1 less than 7, 6. 1 less than 13, 12. It's going to be 72. So, the candidate solutions are the devices of 72. And again, we'll just list them in this case. And unfortunately, we have to try out each one of these to see which one works. And, well, that didn't take too long. The least positive solution, 12 to power 6, congruent to 1. On the other hand, that also means that there's only 6 different remainders possible when we raise 12 to the power mod 91. And this will become important later on.