 So, we've seen that if n is prime, then every element, 1, 2, 3, up to n minus 1, has an inverse under multiplication mod n, and so these elements form a group under multiplication. We've also seen that the powers of A under multiplication mod n also form a closed set under multiplication. So, let's see where this takes us. In this, we'll follow in the footsteps of Leonard Euler, who in 1755 presented a paper whose English title might be something like theorems about the remainders left by division of powers. It will also be helpful to remember that if n is prime, the multiplicative group of integers mod n has n minus 1 elements. So, suppose n is prime and A is less than n. Let's consider the powers of A mod n, that's A, A squared, A cubed, and so on. Since there's a finite number of remainders mod n, we must eventually have a repetition. A to the power m must be congruent to A to the power n, and we'll assume that m is greater than n. Now if A to the m is congruent to A to the n, then we know their difference is a multiple of n, and let's factor out that A to the power n. Now, since we've assumed that n is prime, it must divide either A to the n or A to the m minus n minus 1. But if it divides A to the n, it must divide A, but it can't because A is less than n. And that means it must divide A to the m minus n minus 1, and so A to the m minus n must be congruent to 1 mod n. And so we know there's sub-k, where A to the power k is congruent to 1 mod n. But remember, if it happens at all, it happens a first time. And so there's a least solution, x, to A to the power x, congruent to 1 mod n. So Euler proceeded as follows. But k be the least power for which A to the power k is congruent to 1 mod n, where again we're assuming that n is prime. And the terms 1, A, A squared, and so on, up to A to the power k minus 1, have to be distinct. And for reference purposes, we'll call this set A. Now we claim they have to be distinct, but you should prove it. And so suppose A to the power i is congruent to A to the power j, then, well, bad stuff happens. I won't say exactly what that bad stuff is, because you should be able to prove this on your own, and you should do your own homework. However, here's the important thing. There are, at this point, two possibilities. Either we found all possible remainders mod n, and remember, if n is prime, the multiplicative group of integers has n minus 1 elements. So that means k is equal to n minus 1. Or we haven't found all possible remainders mod n. So if we haven't found all remainders, then there's some b that is not an element of A. And so let's consider the products b, bA, bA squared, and so on, and we'll refer to this set as bA. Now to begin with, none of these can be a power of A. Well, we should prove that. Suppose bAi is equal to Aj, then, bad stuff happens. We'll leave that as a homework problem. Additionally, every element in this set must be distinct. And again, suppose one of these, bA to power i, is equal to bA to power j. Then, well again, more bad stuff happens, and we'll leave that as a homework problem. But if we put our two results together, that says if A is the set of powers, and for b not in A, bA is the set of powers multiplied by b, then not only is bA disjoint from A, but it has the same number of elements as A. And so again, either we've found all possible remainders mod n among the two sets, and so 2k is n minus 1, or we haven't found all possible remainders mod n. So if we haven't found all remainders, there's some c not in A and not in bA. So let's consider cA, again, the product of c times each of the powers. And again, they're all distinct. They're all distinct from A because c is not in A, and we have our lemma. And they're distinct from bA because c is not in bA. We can't use our lemma for that, which means we have to prove this statement. Well, let's check it out. Suppose cAi equals bAj. Well, let's see what actually happens here. Because I know that A to the power k is congruent to 1, let's supply those missing factors and multiply both sides by A to the power k minus i. And so that gives me c to A to the k equals bA to the something. And A to the k is congruent to 1. And so that I know that c is congruent to b times A to the something. And so c is in bA. It is b times the power of A, except we assume that it wasn't. And so this is the bad stuff we run into. And so once again, there are two possibilities. We've produced all remainders mod n, and so 3k is equal to n minus 1. Or we haven't found all possible remainders. And we can lather, rinse, repeat. And if we want to summarize our results, we have the following. Suppose n is prime and A is less than n. Let k be the least power, where A to the power k is congruent to 1 mod n. Then what is the following must be true? k is equal to n minus 1, or 2k is n minus 1, or 3k is n minus 1, and so on. And in general, n minus 1 must be a multiple of k. Equivalently, we often state this result as follows. Let n be prime. The least k for which A to the power k is congruent to 1 mod n is a divisor of n minus 1. So how could we use this? Well, suppose we want to solve 2 to the power x congruent to 1 mod 43. Now 43 is a prime number, and so the Euler Fermat theorem applies. And so we know that the least power that makes this congruence true must be a divisor of 43 minus 1, 42. And so our solution has to be one of those divisors, which we can list. And so we can try each one of these in sequence. So we'll find 2 to the second, 2 to the third, 2 to the sixth. Well, we can find that because that's 2 to the third squared. And working mod 43 means never having to work with large numbers. So we can reduce and find 2 to the seventh. Well, that's 2 to the sixth times 2, and so that will be 2 to the 14th. Well, that'll be 2 to the seventh squared, but I don't really want to multiply 42 by itself. So we might notice that 42 is also congruent to negative 1 mod 43. And so 2 to the 14th will be, and that gives us our least solution.