 Welcome back, we were talking about Fermat's little theorem. So, the Fermat's little theorem says that if you have a P to be a prime and you take any norm 0 element in G P, then a power P minus 1 is congruent to 1 modulo P. Now, I also told you that there are some naughty numbers which satisfy Fermat's little theorem, but there we have to be slightly careful. What happens is that if you have a number A in Zn which is co-prime to n, only then we can expect a power P minus 1 to be 1 modulo n. Because if the GCD of A and n is bigger than 1, then of course all the powers of A will have GCD with n bigger than 1 and therefore all these powers cannot be equal to 1. So, indeed Fermat's little theorem can be used to find the whether a given number is prime or not. However, there are some numbers n which have the property that there is some A less than n which has the possibility that A power n minus 1 is 1 modulo n. So, if you were to start with the given n, you were to start with choosing a random number A in Zn and then checking A power n minus 1, it may happen that you get it to be 1 modulo n, but n need not be prime. I will let you find more information about this by working out some examples. For the moment we will go ahead with something else. What we now want to do is to observe that there are elements in Zn which behave in a nicer way. So, Zp has very nice arithmetic because whenever you take any two elements in Zp which are not 0, their product gave you a non-zero number. This is not true in general for Zn. Again, for instance if we were taking n equal to 8, there are these two numbers 2 and 4, these are not 0 modulo 8, but their product is 0 modulo 8. So, these are the elements the 0 divisors in Zn which create problem for the arithmetic in Zn. So, we would like to take these elements out or in other words we want to find elements which have the property that they are not 0 divisors. What does it mean to say that something is not a 0 divisor? It means that when I take such an element A in Zn and I multiply by various B's then I do not get 0. I would always get non-zero elements when can such a thing happens. So, for instance if your element A happens to be equal to 1 then 1 into any number will give you that number 1 into A always gives you A. It will never give you 0 unless A itself is equal to 0. So, when you have such a number one more just an example, we would like to find elements such that when you multiply to them by any non-zero number you should get a non-zero number modulo n you should not get something which is 0. But after all you have only finitely many elements and when you are going to look at it modulo n you have the property that A into I minus A into J is A into I minus J and if your A has the property that A into I minus J is 0 implies I minus J is 0 that would tell you that whenever you have A i equal to A j you will have that i equal to j. So, the elements which have the property that they are not 0 divisors these are also the elements which can be cancelled and we want to find the set of these elements. So, in other words these are elements which are invertible in Z n so that is there is some another element B in Z n with the property that A into B will give you 1. So, what we are looking for are the elements A modulo n such that A x congruent to one mod n has a solution. We should have a solution for the linear congruence A x congruent to one mod n. Now, linear congruence is something that we are trained so well in that even if I wake you up in your sleep you should be able to give me the condition for the existence of solution here. You should be able to tell me right away that the GCD of A and n divides 1. Now, GCD of A and n divides 1 in natural numbers we tell you that the GCD be better equal to 1. So, these are all the elements A with the property that the GCD of A and n is 1. So, starting from something which had something to do with the multiplication in Z n asking for elements which are invertible in Z n we have now come up with a number theoretic concept that the GCD of these numbers and n should be equal to 1. If you observe that whenever n is a prime p this condition a, n equal to 1 holds for all numbers less than p except of course 0. So, these are the numbers that we are looking for these are the numbers which are all the elements in Z p all the nonzero elements in Z p these are the nice elements in Z n which we are looking for. As mathematicians are trained to do perhaps what we then do is that we define a function you may think that it would be easier to compute this for particular n's but mathematicians will tell you by experience and rightly so that it is good to have this function defined for all n and then study the property of this as a function from natural numbers to natural numbers. So, we define this function phi n this is a function and what does it do it computes the number of elements in Z n remember this is Z by n Z which are co prime to n that means these elements are the ones which are not the 0 divisors when you are looking at them in Z n. So, phi n which is the function that we have just now defined is the cardinality of all the numbers from 0 to n with the property that the GCD of these numbers with n is equal to 1. It may look like a very daunting thing we are going to study the property of all properties of this function which is now defined for all n but that is the beauty in mathematics that when you generalize something then studying it becomes much simpler. So, for the moment let us try to compute some values of phi n of course phi 1 is 1 because there is the element 1 which is less than or equal to n and you have. So, here the number of elements that you are looking for is simply the single turn 1 this is the element which goes from 0 to n and has the GCD 1 with n n itself being equal to 1. Second is phi 2. So, we are going to look at this set 0 or you may say we are looking at the set 1, 2 this is the set Z 2 and you remove the elements which are not co-prime 2, 2. So, again here we are left with only one element which is single turn 1. If you go one step further phi 3 this happens to be 2 let us write all the elements from 1 to n and now we remove the element which is not co-prime 2, 3. 1 and 2 happen to be co-prime 2, 3. So, here the value of the function phi at the number 3 is equal to 2. Phi 4 once again here we write all the elements of Z by 4 Z this will have to be removed and 2 will also have to be removed because 2 is also not co-prime to 4. The GCD of 2 and 4 is 1 is 2. The GCD of 2 and 4 is 2 which is bigger than 1 as well as the GCD of 4 and 4 is 4 which is also bigger than 1. So, these are the 2 elements which we need to remove and so phi 4 is indeed equal to 2. You may now think that we had 1, 1 and then 2, 2 and if you ask anybody to complete the sequence ahead or compute the sequence ahead the most natural answer would be 3. But if you want to compute phi of 5 the Euler phi function of the number 5 you will get it to be 4 and the reason being that all 1, 2, 3, 4 are co-prime to 5. 5 is the thing that you will have to remove so you are left with 4 elements. So, phi of 5 is 4 and now brace yourself phi of 6 is equal to 2 it is a smaller number than phi of 5. The sequence is not quite an increasing sequence. So, let us write all the numbers up to 6 and let us see where we are getting the GCD to be not equal to 1 GCD of 6 with itself is 6. So, that has to be removed 4 has to be removed because the GCD of 4 and 6 is equal to the GCD of 2 and 6 which is 2. 2 also needs to be removed 3 also needs to be removed because 3 and 6 the GCD is 3 all the GCDs are bigger than 1. So, the only set that is left is the set 1, 5. Therefore, phi of 6 is equal to 2. Now, from the example of phi 5 you should be ready for the answer of phi 7 and that answer is indeed equal to 6. In fact, you should be able to generalize this by saying that whenever we are looking at a prime P phi of P is equal to P minus 1. In fact, we have also seen this that in ZP all the nonzero elements are invertible you can invert all the nonzero elements and therefore, phi of P is P minus 1. Let us check one more example phi of 8 and this happens to be 4. So, this is because when you write all the elements modulo 8 we can write only the odd elements once you have even element that will have a non-trivial GCD with 8. So, the GCD of 2, 8 the GCD of 6, 8 are equal to 2 which are bigger than 1. The GCD of 4, 8 is 4 which is bigger than 1 and of course, the GCD of 8 with itself is 8 which is bigger than 1. So, here we are left with only 4 numbers from 1 to 8 which are co-prime to 8. This is how the values of all these elements can be computed. And as we have observed when you have phi of P to be P minus 1 we can actually write down the values for most of these numbers. For instance, the value of 2, phi of 2 is 2 minus 1, phi of 3 is 3 minus 1, phi of 5 is 5 minus 1 and phi of 7 is 7 minus 1. These could always be, these could of course, be written without even have to worry about it. These other quantities phi of 4 and phi of 8 these are prime powers and then this is something which is still something complicated which is that it is a product of 2 different primes. So, to be able to compute the values of this Euler phi function what we are going to do is to define 2 is to have a result which allows you to compute the phi values for a prime power which will explain all the terms here in this table except the term 5, 6 the Euler phi function at 6 which is equal to 2. So, that is a very nice result. The result simply says that whenever P is a prime and you want to compute the Euler phi function on P power E for any E here there is no restriction on E any power E then phi of P power E is simply P power E minus P power E minus 1. So, this explains all the values on the previous slide except the value phi of 6. This is because if I wanted to find phi of 4 which is phi of 2 square this would be by our previous formula phi of 2 square minus 2 power 1 which is 4 minus 2 and therefore it is equal to 2. Similarly, phi of 8 which is phi 2 cube is 2 cube minus 2 square which gives me that it should be 4. This should tell you that if you wanted to compute the next 5 value which we did not but if you wanted to compute this this would be phi of 3 square which would be 3 square minus 3 and therefore this will be equal to 6. Indeed, if you were to look at the elements then you will have to remove 3, you will remove 6 and these are the elements modulo 9 which are all co-prime to 9. So, these are 6 in number. This is how the 5 values can be computed for all prime powers. Of course, every number is not a prime power. So, we will also later see a result which will allow us to compute general phi values. So, for the moment we go ahead with the proof of this very nice result that whenever we have p to be a prime then phi p power e is p power e minus p power e minus 1 and the proof is just the counting proof. We will write first of all we observe that a comma p power e is equal to 1 if and only if a comma p is equal to 1. So, if you have a natural number and it has GCD equal to 1 with respect to a prime power then clearly its GCD with p has to be 1 because p divides that prime power. If the GCD of a and p is not 1 then it would be bigger than 1 and then it will have to be p because p has no other divisors other than 1 and p and if p divides a then p will divide a as well as p power e and therefore the GCD of a and p power e cannot be 1. So, whenever the GCD of a and p power e is 1 the GCD of a comma p has to be 1 and if GCD of a comma p is 1 the GCD of a and p power e also has to be 1 because p is the only prime that divides p power e. So, when we are counting elements modulo p power e so we will start with 1, 2, 3 and write down all the elements up to p power e and among these we will have to find elements which are not co-prime to p power e and remove them we simply have to find elements which are not co-prime to p and remove them that is simple that is how simple it is. So, we start by writing the elements modulo p power e so we have 1, 2, 3 so on up to p. Then, we start writing the elements in the next row p plus 1, p plus 2, p plus 3 dot dot dot and then the next multiple of p will be 2 p after that we have 2 p plus 1, 2 p plus 2, 2 p plus 3, 3 p and we can just continue this way the last one before p power e would be where you will have this to be p power e minus p and the last one would be the number p power e. At each stage we are adding p we add p and get 2 p we add p and get 3 p so that here we will add p and get the number p power e and these are the only numbers which are not co-prime to p because to have some a power p not equal to 1 this is equivalent to p dividing the number and we have counted exactly the multiples of p going from 1 to p power e. How many multiples have we found? Let us count this as 1 this is 2 this is 3 and so on the total number of rows here is p power e upon p these many rows we have. So, phi p power e is p power e minus the number of elements 1 up to p power e with the property that p divides a and this number as we have seen is the number of rows in the previous slide which is nothing but p power e minus 1 and therefore, we get that phi p power e is equal to p power e minus p power e minus 1 a very simple proof. So, this is the proof that allows us to compute the phi value for any prime power. Now, to go for a general n what we have is that a general n will be product of prime powers. So, if we had a way to go from product of different prime powers product of from prime powers to their product then we would be able to compute the phi value for all such numbers. So, here is the next lemma which says that whenever a comma b is 1 then phi a b is the product phi a phi b. So, once you have this lemma this will tell you that you can compute the phi value for all numbers you will simply write n as product of distinct prime powers. For each prime power we know how to compute the phi value and to find the phi value of the number n you simply have to take the product of the phi p power e whenever p power e is the exact divisor of n for the prime p. So, even this proof is not difficult. So, one would prove this in the following way. Note first of all that some alpha is co-prime with a b if and only if alpha is co-prime to a and alpha is co-prime to b. This is the first major thing that we need to observe. How does one think about proving this? Suppose we have so this is again I have been telling you that we have whenever we have if and only if, if means that if this holds and this holds then we should get this. This is the meaning of if alpha comma a b is 1 if alpha comma a is 1 and alpha comma b is 1. So, how does one prove this? If you have that alpha comma a is equal to 1 and alpha comma b is also equal to 1 and suppose now that alpha comma a b is not equal to 1. So, we are assuming the contradictory. We are assuming the contrary we are assuming that alpha comma a b is bigger than 1 but alpha comma a equal to alpha comma b equal to 1. So, take the GCD d of alpha and a b and take a prime divisor of that since that number is bigger than 1 it should have a prime factor. If that p is the prime factor which divides alpha and also the product a b then you know what we are going to do we will take p that has to divide either a or b. p being a prime when it divides a b it will have to divide either a or b. If p divides a then alpha comma a will have a prime factor. The GCD alpha comma a will have p in it if p divides b then the GCD of alpha comma b will have p in it. So, whenever alpha comma a and alpha comma b are equal to 1 alpha comma a b will also have to be equal to 1. So, f condition is done and now to get the only f condition we go in the reverse way if you have that alpha comma a or alpha comma b any of these two is bigger than 1 then alpha comma a b has to be bigger than 1 because once again if let us say alpha comma a is bigger than 1 take a prime p dividing it that prime will have to divide both alpha and a b because it divides alpha and it divides a. So, when you have a prime dividing alpha and a b the GCD alpha a b cannot be 1 it will have to be bigger than 1. Think about this proof but it is an simple enough proof. So, when you are looking at elements which are coprime to the product a b you have to have those elements to be coprime to both a and b. This is number 1 second property that we observe is the following that if you have alpha congruent to beta modulo the number a then the GCD of alpha comma a is equal to the GCD of beta comma a and similarly when you have alpha congruent to beta modulo b then the GCD of alpha comma b is equal to the GCD of beta comma b. So, these are the two things which can be seen quite simply and therefore we will not see the proof of these things but we will just assume these both statements which says that if you have in particular it will say that if you have some number which is coprime to a by adding multiples of a to it you will still get a number which is coprime to a and the same thing will be true for the number b. So, now we want to compute the number of elements which are coprime to a b in terms of the numbers which are coprime to a and the numbers which are coprime to b. So, the proof would go again by writing all these elements as multiples of a 3 a and so on the last thing here would be a b and you are just adding a every time. So, the last but one thing would be a into b minus 1 these are this is how we would have all these a b terms these all these are all a b terms. So, you are actually looking at g a b and here we are now going to find elements which are coprime to a b. So, in this row we have to remove elements which are not coprime to a b and for that what we do is that we remove elements which are not coprime to a. So, here remove numbers which are not coprime to a. Suppose that there is an i here which is not coprime to a then all these elements in the column of i will have the property that these are going to be i plus a multiple of a. All these elements are i plus a multiple of a and therefore all these will have to be removed. So, all these going to be removed because all of these are not coprime to a and therefore they are not coprime to a b. So, when we remove a particular number i from here we are removing a particular column and thus in the table thus we have kept only phi a columns the table only phi a columns are kept. Further each column the table lists all elements of z b modulo b. Let us think about this statement for 5 seconds. We are saying that we are only going to look at the columns of the table. So, the columns remember they start with some element which is from 1 to a and then you keep adding a to those elements but a is coprime to b therefore when you look at mod b a is an invertible element. Therefore, when you start with any element module any element from 1 to a and then you keep adding a to them you are going to get all other elements in z b. First of all you have b elements because there are b rows and so you have say some j then j plus a j plus 2 a all the way up to j plus 3 a j plus a into b minus 1 and no 2 of these can be equal because j plus alpha a equal to j plus beta a modulo b we will tell you that alpha a is beta a modulo b but a is invertible modulo b being coprime to b. So, it tells you that alpha is beta so the b elements that you have obtained they are all distant modulo b. So, in this table each column if you for instance look at 2 the column corresponding to 2 you are going to get all b elements modulo b when you reduce them modulo b. And therefore each column looks like the elements of z b in a different order and hence to obtain elements which are coprime to b so we are looking to obtain elements which are coprime to a b we need to remove from each column the elements which are not coprime to b. We will have to remove the elements which are not coprime to b from each column. Earlier what we had done was that we have removed elements which are not coprime to a we observed that if there was any element from 1 to a b which was not coprime to a then modulo a it will correspond to some element from 1 to a with the property that that element is not coprime to a. This is the content of those 2 remarks that we have observed at the beginning of the proof. And similarly now from each of the remaining columns we will have to remove elements which are not coprime to b so the elements which are left in each column now is equal to phi b these are the elements which are coprime to b. So to summarize we have phi a columns in each column we have only phi b elements because we have removed all the elements which are not coprime to b. So we are left with only the elements which are coprime to b and that number is phi b and thus we get that phi a b is phi a into phi b. Just to give you an idea of this proof let me work this proof out in the very special case where we have a equal to 3 and b equal to 4. So we are looking at 12 and then we would look at 1, 2, 3 or let me put 4 next to 3 so that we have some space 5, 6, 7, 8, 9, 10, 11 and 12. And from these now for the numbers 1, 2, 3, 4 to remove numbers which are not coprime with 4 we have to remove 2 and 4 and then automatically 6, 10, 8 and 12 get removed. So we have exactly 2 columns left which is equal to the number 5, 4 remember 5, 4 is 2. And now from each of these columns we will go modulo 3 and we will see which are not coprime with 3, 9 is not coprime with 3 and here 3 is not coprime with 3. So there are 2 columns which is equal to 5 of 4 and each of these 2 columns we are exactly going to have only 2 elements which is 5 of 3. So this is how the general proof works. There is not much that I can say after this. So please think about this proof and if you have any problem in understanding this proof please write back to me and I will try to respond to all such queries. I hope to see you in the next lecture. Thank you.