 This is the third part of a talk on p-addict numbers. The first two parts of the talk should be, you should be able to find them by looking at the links in the video description. It was first given as a talk for the Berkeley Math Circle which organizes math talks and summer camps for high school students. And again, there should be a link to it in the video description if you want to find out more. So this talk is going to be on p-addict gamma function. This is definitely going to be a bit of a challenge because the p-addict gamma function is normally only given in rather advanced graduate mathematics courses. So well, we'll see what we can do with it. So it's sort of generalization of the factorial function. So you remember there is a factorial function which takes n to one times two all the way up to times n. So for instance, its first few values for n equals naught one, two, three, four, five are going to be one, one, two, six, 24, 120. So it grows rather rapidly. And we have the following problem. Can we define n factorial for n real or p-addict? Well, let's first discuss it for n real just as a sort of warm up. So this was done by Euler. And Euler came up with his rather famous gamma function which is defined as gamma of x is integral from zero to infinity of e to the minus t, t to the x minus one dt. And by integrating by parts, you see that gamma of x plus one is equal to x times gamma of x. And it's also fairly easy to check that gamma of one is equal to one. And from this we say that gamma of two is equal to one times gamma one which is equal to one, gamma three is equal to two times gamma two equals two, gamma four equals three times gamma three equals six. And if you look at these numbers one, one, two, six you see we're getting one, one, two, six. They're just the factorial function. So in general, gamma of n plus one is equal to n factorial. And everybody gets really annoyed at this n plus one. So we sort of wish that Euler had defined gamma of x so that gamma of n was equal to n factorial. This would make life much easier but we're kind of stuck with this. So this is what the usual gamma function is. It's really the factorial function except the notation has got a bit screwed up as it usually does in mathematics. So the question is can we do something like this for a p-addict numbers? So we would like to have the factorial of a p-addict number as another p-addict number. Well, let's start with something a bit easier. Let's say can we define n factorial for n modulo p where p is going to be a prime. So in other words, we should be able to take n to be an integer mod p and n factorial should be another integer mod p. So we can think of these as being the numbers naught, one, two, up to p minus one with p equals naught and so on. Well, let's try it out. Let's try taking p equals five and see what happens. So here's n and here's n factorial modulo five. So n goes naught, one, two, three, four, five, six, seven, eight. And n factorial mod five, well, it starts off one, one, two and then we get six which is one mod five and then we get 24 which is four mod five and then we get 120 which is zero mod five and then we run into problems because everything beyond that is zero and this is just a total flop, it has failed and there are two reasons it has failed. The first problem is all these zeros and what we end up with is a function that's zero nearly everywhere which is not terribly exciting but there's an even worse problem because you see here, we've got say one is the same as six is the same as six, modulo five. So if this is a function from the integers mod five to the integers mod five then one factorial should be six factorial mod five and it isn't. So one is not congruent to six factorial mod five. So it just doesn't work. So what do we do? Well, let's see what we can do to fix these problems. Let's first fix the problem that it's mostly zero. Well, the problem here is we have factors, whenever we have factors five, 10, 15 and so on in n factorial, these are all zero mod five. So how can we deal with that? Well, we can just miss out these factors. So let's define a new function n factorial sub five which is going to be one times two times all the way up to times n with the fact, we miss out factors divisible by five which seems kind of a very crude way of doing it but let's see what happens. So for example, eight with this funny five factorial is going to be one times two times three times four times six times seven times eight where we have, you notice there is no five here. Well, let's work out this function and see what happens. So we can take n equals zero, one, two, three, four, five, six, seven, eight, nine, 10, 11, 12, 13, 14, 15 and here's n with this funny five factorial. We're going to work it out mod five and see what we get. Well, the first few values are the same. We get one, one, two, one, four and then we don't get zero here because we miss out the factor of five. We just get four again and then we get a third, four, three, four, one, one, one, one, one, two, one, four and so on. And now let's see if this is well-defined modulo five. So here we have one and six of congruent mod five. So these two ought to be congruent mod five and let's just check that. So we want one is congruent to, this doesn't seem to be working. One is not congruent to four, mod five. So we seem to have failed again. Well, at least we've got rid of all the zeros. So what can we do? Well, let's look a bit more closely, see what's going on. So here we've got one, one, two, one, four but over here we've got another one, one, two, one, four. So they should be repeating mod five but they're not quite. Instead they're repeating mod 10. So we want N plus five with this funny factorial should be equal to N five factorial. And this fails, but we get something a little bit weaker. We get N plus 10 factorial five seems to be equal to N factorial five. So what's going on? Well, let's look a little bit more closely. What we see is that if we add five to N we get N plus five with this funny factorial is equal to minus N with this funny factorial. You see we've got one, one, two, one, four and here we've got minus one, minus one, minus two, minus one, minus four. So we get this, which is almost what we want except we've got this sine error. Sine errors like this are sort of quite common in mathematics. You almost get the idea that whoever invented mathematics kind of was only a rather second rate mathematician and kept making mistakes by introducing sine errors all over the place. But this means we can now define a function mod five that's almost a factorial. So let's define the function F of N which is this funny five factorial and let's multiply it by minus one to the N. So this will get rid of the sine. So what goes on here? This thing changes sine if we change N to N plus five. And this factor here changes sine under N goes to N plus five. So these sine errors now cancel out and we find F of N plus five equals F of N. So F is a well-defined function from integers mod five to integers mod five. And it's sort of almost a factorial. I mean, we've had to twiddle factorial a bit to get it to work by missing out the multiples of five and by putting in some extra sine sines. And now in order to define p-addict factorials what we need to do is to define a function for the integers mod five to itself, which we've done but we also want a function from the integers mod 25 to the integers mod 25 and from the integers modulo 125 to the integers modulo 125 and so on. So we've done this. What about these? Well, we managed to define the factorials mod five using the fact that one times two times three times four is minus one modulo five means the difference is divisible by five. Well, what about five squared? Suppose we take all the numbers one times two times three times four times, now we miss out five, six times all the way up to nine times 11 up to 14 times 16 up to 19 times 21 up to 24. And if we multiply all these together we find this is minus one mod 25. And if we do the same we take all the numbers up to one 24 not divisible by five. Then this also turns out to be minus one modulo 125. So we can define factorials modulo 25 and modulo 125 in the same way. And what we're using for this is something called Wilson's theorem. So Wilson's theorem says that if we take all the numbers one times two up to times P minus one and multiply them together this is congruent to minus one mod P. And there's a stronger version of it which says that if we take all the numbers one up to P to the N minus one that are not divisible by P then this is usually congruent to minus one mod P to the N except there's an exception to this. And if you looked at the first couple of parts of this talk you know what the exception is when P equals two because the prime two always always always goes wrong for some reason. And using this we can now define factorials modulo any odd prime power. Well this uses Wilson's theorem. So let's try and see why is Wilson's theorem true and why does it go horribly wrong when the prime is two? Well let's take a look at P equals seven. So we're going to multiply together all the numbers from one to six and work out what they are mod seven. Well multiplying together all these numbers is a lot of work so mathematicians are kind of lazy so can we find a way to save effort? Well let's pair them off. We can pair off the numbers two and four because the product is congruent to one mod seven so we can just cross them both out. And what about three and five? Well we can cross these out because three times five is congruent to one mod seven. And we can't cross out six and we can't cross out one because they just pair off with themselves. Six times six is one mod seven and one times one is one mod seven. So what we find is the numbers pair off, they pair off as pairs AB with AB is congruent to one mod seven except when A times A is congruent to one mod seven because the numbers one and six just pair off with themselves. So the product of all numbers from one to six mod seven is just the same as the product of all numbers with A squared equals one mod seven and the same works for all primes. We find that one times two times all the way up to P minus one is just equal to one times P minus one because all the others pair off. And this is just minus one modulo P. So what happens if we try prime powers? Well, the same thing seems to happen. So let's try a couple of examples. So let's try three squared. Here we have one times two times four times five times seven times eight where we miss off three and six because they're divisible by three. But again, these pair off, we get two and five pair off and we get four and seven pair off. So the product is just one times eight which is congruent to minus one mod three squared. That's fine, it seems to be working. Let's try two cubed. We have the numbers one times three times five times seven. And three pairs off with three. Five pairs off with five, seven pairs off with seven, one pairs off with one. So something has gone wrong. The numbers other than one and seven are not pairing off. What we find is we have four numbers A with A squared is congruent to one modulo two cubed. So what we get is not one times seven but one times seven times three times five which is congruent to one modulo two cubed, not minus one. So why does this work for odd primes but not for even primes? Well, let's find the numbers A mod P to the N with A squared is congruent to one mod P to the N. This means that P to the N divides A squared minus one which is equal to A minus one times A plus one. And there are three cases where this can happen. First of all, we could have P to the N divides A minus one or we could have P to the N divides A plus one. And if P to the N doesn't divide either of these factors then most P to the N minus one divides one of them so at least P divides the other. So the third case is P divides A minus one and A plus one. Well, this case gives us A is one modulo P to the N minus one and this case gives us A is congruent to minus one. So these are the cases we know about and want. Well, what about this case? Well, if P divides A minus one and A plus one then this gives us P divides the difference which is two. So the only prime that can go wrong is the prime two and we've seen that the prime two does indeed go wrong. So this shows that we can define factorials for numbers modulo P to the N and using that we can now define factorials for periodic numbers just by sort of gluing all these together because you remember a periodic number is just got by taking a number modulo P and P squared and P cubed and some that are compatible. Okay, so I'll finish just by giving a few books where you can find out more about periodic numbers and what they're used for. The first is this book by Boreevich and Shafarovich. This is actually, I think this is the book where I first learned what periodic numbers were. So here, part three of chapter one defines periodic integers and Boreevich and Shafarovich also give some applications of periodic numbers like they show you how to use them to solve diaphanetine equations of degree two and so on. A slightly more advanced book is this one by Seher called a course in arithmetic and you shouldn't be put off by the title because it's translated from the French and in French arithmetic actually means number theory. It doesn't mean how to do addition. And again, he's got a section on periodic numbers which is a little bit more advanced than the description in Boreevich and Shafarovich. If you're feeling really ambitious, you can not only define analogs of factorials, you can also define analogs of things like the Riemann zeta function for periodic numbers. So the Riemann zeta function is the most notorious function in mathematics because of the Riemann hypothesis and there's a periodic analog for it. And if you want to find out about that, there's this rather nice book by Neil Koblitz and telling you more about periodic analysis and it tells you what periodic zeta functions are. Okay, I think that's all.