 This lecture is part of Berkeley Math 115, an introductory undergraduate course on number theory, and will be about primitive roots. So I will start by recalling what a primitive root is. So we're going to work modulo m for some positive integer m. And we recall that the order of a mod m is the smallest integer greater than zero with a to the n is congruent to 1 modulo m. Here we take a to be co-prime to m, otherwise there's no such integer. And we also recall Euler's theorem, which says that a to the phi of m is congruent to 1 modulo m. Here phi is Euler's totian function, which I will recall in a moment. So the order of a divides phi of m because we recall that the order of a divides any exponent such at a to that exponent equals 1. So the maximum possible order of a is going to be phi of m. And we say a is called a primitive root of m if the order of a is equal to the maximum possible value phi of m. The reason for the name primitive root is you can think of a as being a root of 1 because a to the power of something is equal to 1. And primitive means in some sense it has maximal possible order. So primitive root is kind of short for primitive root of 1. This condition is equivalent to the condition that the powers of a, such as a to the 0, a to the 1, up to a to the 5 m minus 1, are exactly the residue classes co-prime to m. That's because the number of residue classes co-prime to m is phi of m, more or less by definition of phi. So if a is order exactly phi of m, these are all different. And as they're all residue classes co-prime to m, they must be exactly the residue classes. And conversely, you can see that if the powers of a are exactly the residue classes, then it must have order exactly phi of m. So what we're going to do is answer the following question, which numbers have primitive roots? How many primitive roots do they have if they have any? And how do we find the primitive roots? And you can do this in a very clever way by writing down lots of theorems, but we're going to do it in the stupid way just by starting with numbers m equals 1, 2, 3, 4 and so on and working out the primitive roots and trying to see what patterns there are. So let's try various numbers m. So then we need to know the numbers co-prime to m. We need to know phi of m and we want to work out the primitive roots. So for m equals 1, it's not very interesting. There's only one residue class co-prime to it, which can be taken as 0 or 1 if you like. Phi of m is 1 and the only primitive root is 0 or 1. So I'm going to put the primitive roots in red. So for m equals 2, the only thing is co-prime to 2 is 1. Phi of m is 1 and 1 is order 1. So this is a primitive root. So let's try m equals 3. Here we've got two residue classes. So phi of m is 2. And let's work out the orders of 1 and 2. Well, 1 is order 1 and 2 is order 2. So this is the only primitive root. And let's do 4. Well, here the residue classes are 1 and 3. And again, 1 is order 1 and 3 is order 2. And 5m is 2. So we can see there's exactly one primitive root. And 5 gets a little more interesting. So here the residue classes are 1, 2, 3 and 4. So 5m is 4. And let's work out the orders. Well, that is order 1. 4 is order 2 and 2 and 3 have order 4. So we now see that there are now two primitive roots of 5. Order 6. The only residue classes are 1 and 5. That's a co-prime to 6. And again, these are orders 1 and 2. And 5m is 2. So there's only one primitive root. 7 starts to get a little bit trickier. So the residue classes are 1, 2, 3, 4, 5 and 6. So 5m is 6. And now if we work out the orders, it's getting a little more complicated. So this is order 1. We have 2 cubed is 8, which is 1. So these all have order 3. And 6 is minus 1. So this is order 2. And the remaining ones, 3 and 5, both have order 6. And now there are two primitive roots, which are 3 and 5. So what about 8? Well, 8 gets a bit weird. So the residue classes are 1, 3, 5 and 7. So 5m is 4. And this time, if we look at the orders, they're 1, 2, 2 and 2. Because all of these have square equal to 1. So there are no primitive roots, mod 8, as we recall earlier. In fact, for this reason, 8 is a counter-exhaunt or a lot of things. It's the first number that doesn't have a primitive root. And we notice one of the obstructions to having a primitive root is 8 has four solutions to x squared is congruent to 1 mod n. And we notice that if there is a primitive root, so I suppose g is a primitive root with g to the phi of m equals 1 and no smaller power of g equals 1, then the only solutions to x squared is congruent to 1 are g to the phi m and g to the phi m over 2. You can easily check that if all the powers of g up to phi m are different, then these are the only possibilities for square roots of minus 1. So if there are four elements of order 1, so four elements whose square is 1, then the number can't have a primitive root. And we will see this coming up quite often. In fact, this turns out to be a necessary and sufficient condition for a number to have a primitive root. OK, well, let's go a bit further and see if we can find any other patterns. So for 9, well, if we've got a primitive root g of 9, this implies g is a primitive root of 3. And the reason for that is that all the powers of g give all the residue classes mod 9, so they certainly give all the residue classes mod 3 because 3 divides 9. So to find a primitive root of 9, we should start by looking at the primitive roots of 3 and see which of them are primitive roots of 9. So the number's modular 9 are 1, 2, 4, 5, 7, 8. Now, the ones that are primitive roots of 3 are things that are 2 mod 3, so it's 2, 5, and 8. So these are the only ones we have to look at. And if we look at their orders, we see the order of these as 1. Well, the order of 8 is 2, so that's not going to be a primitive root of 9. So it's a primitive root of 3, but not of 9. And these two, however, 2 has order 6 and 5 has order 6. So we found two primitive roots of 9. In fact, these are the only possible primitive roots. We don't need to bother about 4 and 7 because these are not primitive roots modulo 3. So now let's do 10. Well, we could write out the numbers modulo 10. There's a co-prime to 10, which are 1, 3, 7, and 9. And now we could check these and work out their orders, but there's a lazy way to do this. What we notice is that if we look at the numbers modulo 5, there's 1, 2, 3, and 4, and we notice that the numbers modulo 10 kind of correspond exactly to the numbers modulo 5 in a different order. And what we recall is by the Chinese remainder theorem 10 is equal to 2 times 5. So the numbers mod 10 can be identified with numbers mod 5 and numbers mod 2. And since the only number mod 2 co-prime to 2 is 1, the residue classes mod 10 co-prime to 10 can be sort of identified with the residue classes mod 5 to co-prime to 5. And now we've got two primitive roots of 5. So these are just going to be primitive roots of 10. And the same works whenever n is odd and we look at the number 2n, we see that the residue classes mod n co-prime to n correspond to the residue classes mod 2n to co-prime to 2n. And so if g is a primitive root mod n, then g might not be a primitive root modulo 2n because it might not be co-primed to 2n, but either g or g plus n, whichever is odd, is then a primitive root mod 2n. So if n is odd and has a primitive root, then 2n has a primitive root. This fails if n is even. We see 4 has a primitive root, but 8 doesn't. So that's done 10. What about 11? Well, the number 11 is prime, so we can write out the things modulo, the residue classes co-prime to 11, and we could check these and work out their orders, but this is really getting a little bit tedious. So we should ask, is there an easier way to show that 11 has a primitive root without actually checking anything? Well, here's an easier way to do it. We notice the order divides phi of 11, which is just 10, so is 1, 2, 5, or 10. And we can ask, how many elements can the b of each order? So if g has order d, then g to the d equals is congruent to 1, and we know this has most d solutions because we're working over a prime number, and we remember that modulo of prime, an equation, the number of roots is at most a degree. So let's work out the number of elements of various orders. Well, there's most 1 element of order 1, most 2 of order 2, and most 5 of order 5. So there are, at most 1 plus 2 plus 5 is equal to 8, and elements of order not equal to 10. So there must be at least 10 minus 8, which is at least 2 elements of order 10. And these are, of course, just the primitive roots. So by carefully counting, we can show that there are primitive roots without all the tedious labour and actually checking whether something is a primitive root. So this shows that 11 has primitive roots without actually finding any. It's not too difficult to actually find some primitive roots. For instance, you can see the number 2 doesn't have order 5 because 2 to the 5 is congruent to minus 1 modulo 11, and 2 squared is obviously not congruent to 1. So 2, for example, is a primitive root. And there may be some others, and we'll see how to find the others a little bit later. So let's try 12. Well, 12 and numbers are 1, 5, 7 and 11. So these are the residue classes, mod 12, co-prime to 12. And we notice that they all have order 2, or 1 or 2. So there's no primitive root. And let's sort of think a bit about why there's no primitive root. Well, we notice that 12 is equal to 4 times an odd number 3. And now we can count the number of solutions to x squared is congruent to 1. Well, the number of solutions here is going to be at least, so it's going to be exactly 2, and the number of solutions modulo and odd number that's greater than 1 is going to be at least 2. So there are going to be at least 4 solutions to x squared is congruent to 1. And as we saw earlier, that's not possible if there's a primitive root. And the same works for 4 times any odd number. So if m is equal to 4 times an odd number greater than 1, there are no primitive roots. So now let's try 13. And that method for 11 worked so well. Let's try it for 13 and see what happens. So we've got these numbers 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 and 12. And of course, we don't want to check all these. That would be really tiresome. So let's work out what the order can be. Well, the order of an element must divide by 13, which is equal to 13 minus 1, which is 12. So it's 1, 2, 3, 4, 6 or 12. And the number of elements of this order is going to be at most 1, at most 2, at most 3, at most 4, at most 6 of these orders. So all we do is we add them up 1 plus 2 plus 3 plus 4 plus 6, which is 10, 11, 12, 13, 14, 15, 16. Whoops. Well, this doesn't work because 16 is bigger than 12. So our argument seems to have failed. We've tried adding up all the elements of order less than 12 and the problem is we seem to be getting more than 12 of these. So the argument seems to fail. Well, the reason it's failed is we were being a bit sloppy and we need to count more accurately or more carefully. So let's see. We said there are at most six elements of order 6, but we can actually do better than that. So let's look at the number of elements of order 6. And suppose there's at least one element of order 6 because if there are no elements of order 6, then we've got this really good upper bound of zero. So suppose there's at least one. So suppose g has order 6. Well, then the elements 1g, g squared, g cubed, g to the 4, g to the 5 are all roots of x to the 6 is congruent to 1. And this has at most six roots. So they are exactly the roots of x to the 6 equals 1. So any element of order 6 must be one of these. However, if you look at these elements, only two of them have ordered 6. So this one has ordered 2, this one has ordered 3, 3, and that one has ordered 1. So there are at most two elements of order 6. And you can see what's going on is that there are at most five of the elements of order d because if g has ordered d, if there's order exactly d, then the solutions to x to the d equals 1 are just the powers of g, g to the 0, g to the 1 to g to the d minus 1. And this is order d. So g to the k has ordered d if and only if k is co-prime to d because if it's got a factor in common with d, it's going to a smaller order. So the number of elements of order d is bounded by d, but we can actually do much better. It's bounded by phi of d. So let's go back. The number of elements of order 1, 2, 3, 4, 6, and 12, well, we originally said the number of elements of this order is at most 1, 2, 3, 4, 6, 12. But now we can see that the number is at most phi of 1, which is 1. It's at most phi of 2, which is 1. At most phi of 3, which is 2, phi of 4 is 2, and phi of 6 is now 2. So we get at most 1 plus 1 plus 2 plus 2 plus 2 of order less than 12. Let's count these up. Well, that's 2, 4, 6, 7, 8. So we get 8 elements of order less than 12 and 8 is less than 12. So we get at least 12 minus 8 equals 4 of order 12. Well, phi of 12 is actually 4. So we found there must be exactly 4 elements of order 12. Well, now this argument now works for all primes. We can show that we can now prove a theorem. If p is prime, p has a primitive root. And this depends on two facts. First of all, x to the d congruent to 1 mod p has at most d roots. And we saw this is true because p is prime. So polynomials to the degree d have at most d roots. And if p is not prime, then this thing fails. The second key fact we need is that sum over d divides n and phi of d is equal to n. This is true for any n. And we'll prove this a little bit later. But for meanwhile, let's just assume this and show that there's a primitive root. So what we do is we look at the elements of order d divides p minus 1. So here we're going to take n to be p minus 1. So we look at all the devices d or p minus 1. So it might be 1, 2, p minus 1. And the number of elements of this order is at most phi of 1, phi of 2, and phi of d, whatever d is, up to phi of p minus 1. And now we know that sum of all these numbers is p minus 1. And there are most phi of 1 elements of order 2, phi of 2 of order 2, and phi of d of order d. So the total number of elements is at most phi of 1 plus phi of 2 plus phi of... This is the sum of all numbers d dividing p minus 1. However, since the total number of elements is actually equal to p minus 1, we must actually have equality here because if there were fewer than phi of p minus 1 elements of order p minus 1, say, then this sum would actually be less than p minus 1, which it can't be because it's equal to p minus 1. So if d divides p minus 1, there are exactly phi of d elements of order d. In particular, if we take d equals p minus 1, we see that there are phi p minus 1, which is greater than what? Greater than or equal to 1, primitive roots. So all we've got to do to finish off is to prove this theorem that sum over d divides n of phi of d is equal to n. So this is a result due to... I'm not quite sure whether it's Euler or Gauss. And let's just try it for d equals 12 and see what happens. So the divisor, sorry, right for n equals 12. So the divisors are 1, 2, 3, 4 and 6. Well, what I'm going to do is in order to prove n equals 12, I'm going to write out the numbers 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 and 11. And I'm going to figure out... Sorry, there should be a 0 here. I'm going to figure out the order in the additive group. So I want the smallest number such that k times i is congruent to 0. So the smallest number k is going to be 0 here. It's going to be 12 here. 6, 4, 3, 12, 2, 12, 3, 4, 6 and 12. And now what we can do is we can count up the number of elements for each value of k. Sorry, I guess that should be 1. And what we notice is that there are pi of d numbers of order d, where d divides 12. For instance, if d is 12, we see there are exactly 4, which is 512 elements of order 12. And for d equals 6, we see that there are exactly 2 numbers of order 6 and 2 is equal to 5 of 6. And the reason for this is we can understand... If we look at, say, the number where k is 6. So we see that these numbers 2 and 10 are 2 times 1 and 2 times 5, are the numbers co-prime to 6. And similarly, if we take the numbers of order 4, say, we notice that these numbers are 3 and 9, which are 3 times 1 and 3 times 3. And these numbers 1 and 3 are the numbers co-prime, the residue class is co-prime 4. So the same thing works for all n. So the elements of additive order k mod n, we look at the elements of additive order k and for k dividing n, and we see the number is just phi of k. And that's because they're given by n over k times 1 and various other numbers, where these are the numbers co-prime to k. So we find n is equal to sum over all divisors of n phi of k. And because this just adds up all residue classes mod n, and we count them by the order, by the additive order of the residue class modulo n. So that completes the proof of this theorem, which in turn completes the proof that all primes have primitive roots. Now let's go a little bit further. If we have 14, this is equal to 2 times an odd prime, so it has a primitive root, because the odd prime does. And 15, well, this actually has no primitive roots, and one way to see this is to note that 15 is equal to 3 times 5. And now let's count the number of elements of order minus, number of square roots of minus 1. So the solutions for x squared equals 1. Well, there are two solutions, mod 3, and two solutions, mod 5. So there are 2 times 2 equals 4 solutions, mod 15. So this implies that 15 has no primitive root. And the same thing works for any odd primes. So if m is equal to p times q with p, q, odd primes, and p not equal to q, there's no primitive root. What about 16? Does 16 have a primitive root? Well, we notice that 8 divides 16, and any primitive root of 16 would be a primitive root of 8, because if a number a has a primitive root, sorry, if a number a, b has a primitive root, then so does a, because any primitive root of a, b will automatically be a primitive root of a. So 16 has no primitive root. And let's kind of put things together, what we've got so far. So there's no primitive root of m if m is divisible by 8 or 4p or pq, where p and q are odd primes. So what other possibilities are there? So what numbers are there that are not divisible by 8 or 4p or pq? Well, we can have left over numbers, 1, 2 and 4, obviously. Well, then we can have powers of an odd prime, so p to the n for p, odd. But we can also have 2p to the n. p, odd. And some of these have primitive roots. So we've shown that 1, 2 and 4 have primitive roots. That's kind of trivial. We've shown that p to the 1 has a primitive root. And we've shown that 2 times p to the 1 has a primitive root, because if something is odd, then 2 times that has a primitive root. So we've almost figured out which numbers have primitive roots. There's still a bit of ambiguity about which odd prime powers have primitive roots. Well, that's a little bit tricky. I'm going to leave that till the next lecture. And meanwhile, I'll just finish off a bit about primitive roots modulo primes. So first of all, how to find primitive roots? Well, this is actually a bit messy. We can sort of do trial and error. So suppose you've got to find a primitive root modulo p. What you do is you can factor p minus 1. And if you can't factor p minus 1, you're going to have a bit of a problem finding primitive roots. But suppose we can factor p minus 1. So this is going to be q1 times q2 and so on. And then what we do is we pick some random number a. And we want to show that a has ordered p minus 1. So we calculate a to the p minus 1 over q1, a to the p minus 1 over q2, and so on. If these are all not congruent to 1, then a is a primitive root. So for example, let's find a primitive root p modulo 11. Well, so let's... We notice that p minus 1 is equal to 10, which is equal to 2 times 5. So we want a squared is not... Let me write that as a to the 10 over 2 is not congruent to 1, and a to the 10 over 5 is not congruent to 1. Well, let's just try a equals 2 at random. We have 2 to the 5 is congruent to minus 1 and 2 to the... 2 is congruent to 4. So 2 is a primitive root. So we found one primitive root of 11. Now, how do we find the other primitive roots of 11? Well, once we found one primitive root, it's easy to find the others. So if a is primitive root modulo m, so the order of a is then phi of m. And we notice that an a to the b has order phi of m, if and only if b is coprime the phi of m. So once we found one primitive root, it's easy to find the others. For example, let's find the all primitive roots modulo 11. Well, phi of 11 is equal to 10. So what we want are the numbers b with b 10, b coprime to 10. So we take b equals 1, 3, 7 and 9. So the primitive roots are just 2 to the 1, 2 to the 3, 2 to the 7 and 2 to the 9. Modulo 11. Of course, we could reduce these modulo 11 if we want. So I'm feeling too lazy to do that. We also see that we've actually seen, we also see how many primitive roots there are. The number of primitive roots is just phi of phi of m. Because if we've got one primitive root, the other primitive roots are just that root to the numbers that are coprime to phi of m. And the number of these is just phi of phi of m. So we've got this really rather funny formula for the number of primitive roots of m. That's provided the number of primitive roots is at least 0. So the number of primitive roots is either phi of 5m or 0, depending on whether or not the number has a primitive root. So it's a little bit tricky finding the first primitive root. But once you've found the first primitive root, it's easy to find the others and to find the total number of primitive roots. Okay, so the next video, I'll be looking in more detail at the slightly tricky case of primitive roots for prime powers rather than primes.