 This talk will be about p-addict numbers. So it was a talk given to the Berkeley Mathematics Circle, which runs lectures and summer camps for high school students interested in mathematics. If you want to know more about the Berkeley Mathematics Circle, there should be a link in the description below the video. So I've broken this talk into several smaller videos, each of which should have a link to the next video in the talk. And there should also be a link to a handout for this talk in the description of the video if I set things up correctly. So let me start motivating p-addict numbers by talking about the following problem. Let's find an integer n so that the last 10 digits of n squared are the last 10 digits of n. Okay, at first sight, this looks like a kind of stupid problem because it depends on the fact that you're writing n in base 10, and pretty much any mathematics problem that depends on the base you're working is probably somewhat silly. But actually this particular problem turns out to have more to it than most such problems. So let's have a look. So first of all, we've got six squared equals 36. So that ends in the, there's one digit that's the same. Then if we go further, we find 76 squared ends in 5776. And now we notice that last two digits are the same. And you can carry on like this and you get numbers that look like 1787109376 or squared is some rubbish followed by 1787109376. There's a systematic way of producing numbers like this where you just start with the number five. So five squared is equal to 25 and that ends in a five and you just keep squaring it. So 25 squared is 625 and 625 squared is 390625 and so on. So you go from five to 25 to 625 to 390625. And you notice that the digits are gradually becoming the same. So all these are the same, all these are the same, all these are the same and so on. And if you carry on like this, then you eventually get to a number ending in something like 8212890625. And you sort of ask what happens if you continue forever? So we just keep squaring five indefinitely and what it does is it sort of converges to an infinitely long string of numbers, whatever you mean by convergence. So in other words, if we take this number here and call it N, whatever we mean by number, then N squared is equal to N. Got a couple of question marks there because it doesn't seem to make much sense. Well, obviously this can't possibly be an ordinary integer because ordinary integers only have finite length. It's something called a 10-addict integer. So what is a 10-addict integer? Well, it's just given by an infinitely long integer. In other words, you have a decimal point here and you have an infinitely long string of numbers that goes on forever. And this isn't really quite as strange as you might think because if you look at a real number, so let's take a random real number such as pi. This is 3.1415926535 and so on. And this goes infinitely long string of digits going off to the right but only a finite number to the left. So here we're doing something different. We're allowing an infinitely long string of numbers going off to the left instead of the right. And we can ask, do these make sense? And I want to show you this talk and in fact they do make sense. And the first question is what can you do with them? Well, there's a general theme about 10-addict and P-addict numbers that anything you can do with the real numbers probably has some sort of analog for P-addict and 10-addict numbers. So let's start with something easy. What about addition? So suppose we take two 10-addict numbers. So I'm going to have a long string of digits and then I take four, one, two, eight, seven, six. And let's take another one, eight, nine, five, three, four, seven and let's try and add them up. Well, that's quite easy because we can have six and seven is 13. So we carry one, then we get seven, four is 11 which is 12 because you've got to carry, we carry one again, eight plus three is 11. So we get 12, carry one, two and five is eight and then we get one, nine is zero, carry one, three. So you see it actually works. We can just use the usual rules of addition and it just works, we get the sum of them. And the reason why it works is the last three digits say of a sum of two numbers only depends on the last three digits of the two numbers we're adding. You know, we can figure out what the last three digits are by ignoring everything to the left of these three digits and the same for the next four digits and so on. So addition is well-defined. So we can do addition. So tick there. What about multiplication? Well, let's do an example and see what happens. So let's take a number four, three, two, one point something and let's suppose there are lots of digits to the left that we don't know about and multiply by eight, seven, six, five. And again, there are going to be lots of digits to the left of that that we don't really care about. And let's try and work out what their product is. Well, I don't know if long division is still taught the sort of long multiplication is still taught these days but one way of doing it is you take eight, seven, six, five and multiply it by one. So it goes down here and we have a long string going there. Then you have to multiply it by 20. So we get two times five is zero, carry one. Two times six is 12, which is 13. We carry one, two times seven is 14, 15. And so we get that. And then you take three times this number here and again, it gets shifted. So we get three times five is 15, carry one, three times six is 18, carry one. And so then we get four times this number which gives us a zero here. So we get something like this. Now you can see that this makes perfectly good sense because we can now add these up and we get five here and the six there and we get seven plus three which is 10, we get 15 there and then we carry one and we get three there. So if I've made no mistakes, the last four digits of the product of these is three, five, six, five. And you can obviously continue that for as long as your patient's holds out. So multiplication also makes sense. So the next operation to think about is subtraction. And here we've seen who have a problem. So for ordinary integers, if we just use positive integers like seven and 15 and three and so on, then we run into a bit of a problem with subtraction because if we take three minus 15, then we get a negative number. And notice that to write down this negative number, we need to put a minus sign in front of it. And we haven't said anything about minus signs for 10 added numbers. So suppose you've got a 10 addict number, something eight, seven, two, one or whatever. Does that mean we should put a sign in front of a 10 addict number? And it turns out you don't need to, so let's cross it out. And let's see why. Well, what we can do is consult a 10 addict pocket calculator and I have one here. So this is a very primitive 10 addict calculator. You should really imagine it going off the left and infinite number of places. Let me just magnify it a bit so you can see it a bit better. So I'm going to cover up this bit and you pretend that the noughts go off all the way to the left. And this 10 addict calculation only do one operation. It can add one to a number. So here we've got zero. We press that and we get one, two, three, four, five, six, seven, eight, nine. Then we get nine, we carry one and get 10. So let's see what happens if we say stop with 9, 9, 8, 0 and keep on adding one to it. So when we get to 9, 9, 8, 9, we add one, we get 9, 9, 0. Now let's keep on adding one and we get to 9, 9, 9, 9. And what happens when we add one to this 10 addict number? We get zero. So old cars from several decades ago used to have these mechanical odometers which would behave like this. And when they got to 9,999 miles and you went an extra mile, they'd tell you you had gone zero miles. So this suggests that we actually have minus one already. So suppose we take the 10 addict number with an enormous sequence of nines and we add one to it. So what's gonna happen when we add one? Well, you saw what happens. Nine and one is zero, carry one, nine and one is zero, carry one, nine and one is zero, carry one, nine and one is zero, carry one and so on. So we get naught. So if you add one to this number, we get zero. So this number is actually equal to minus one. So we don't need a negative sign in front of 10 addict numbers because we can just put, we can get negative numbers by being a little bit clever. So the question is, how do you find the negative of an arbitrary 10 addict number? So suppose I've got a 10 addict number, say 10987654321. So call this n, what is minus n? Well, what you do, you can get minus n in two steps. First of all, we take the nines complement. This means you take every digit and you replace it by nine minus the digits. So this becomes 87654321 zero. And then I'm going to add one to it and I get 97654321098. And this is going to be minus n. And let's see why this is true. Well, taking the nines complement is just subtracting n from this ridiculously long way of writing out the number minus one. We're just taking 9999 and subtracting n from it and you get this. So this is equal to this funny 9999 minus n which is equal to minus one minus n. Now I've added one to it. So if you add one to minus one minus n, this gives us minus one minus n plus one, which is minus n. So we can take the negative of any 10 addict number without having to put the sign in front of it. So in this way, 10 addict numbers are actually better than real numbers. They're a bit simpler because we don't need the sign. This is actually used in computer arithmetic. So how do computers store numbers? Well, they've actually got two different ways of storing numbers depending on whether numbers are real numbers or integers. And I'm just going to talk about how they store integers. So they store integers in binary. So I'm going to pretend that a word on this computer just does three bits to save time. So the first few numbers are nought, nought, nought, nought, nought, nought, nought, nought, nought, nought, so one, nought, nought, nought, nought, nought, nought, nought, nought, nought, nought, nought, nought, nought. And you might think these correspond to the number zero, one, two, three, four, five, six, and seven on a computer. But in fact, they don't, at least, well, they sometimes do, but usually they don't. The reason is that computers do not really work quite work in binary. What computers work in is they think of these things as being two addict integers, which are like 10 addict integers, only you work in base two. And what the computer does is it thinks this digit on the left continues infinitely often to the right. So when you show these numbers to the computer, it really thinks they look like this. Okay, well, that's not very exciting so far. We've just added a bunch of noughts, but then it thinks that the one continues there and so on. So it thinks these numbers are really given by these pediatric integers. And if you work out what these pediatric integers are, well, this is nought one, two, three, but this, as we saw, is minus one, and that's minus two, and that's minus three, and that's minus four. So that's how computers generally represent signed integers. And they work out the negative of an integer in much the same way that we found the negative of a 10 addict number. So let's work out what minus three is and pretend we were a rather stupid computer. So what we do is we write three in binary, which looks like that. And then we take the ones complement. So we change every nought to a one and every one to a nought. So we've got a long sequence of ones, and then we get two zeros there. And then we add one to it. So we get one, zero, one, one, one, one. And this is the integer minus three in... You see, it's not quite in binary. It's really in the two addict notation rather than binary notation. And by the way, you may have noticed there's a slight problem with this number four. So let's calculate what happens if you take minus, minus four. Well, you take the number one, one, one, one, one, zero, zero. You take the ones complement, which is zero, zero, zero, zero, one, one, and then you add one to it and we get zero, zero, one, one, one, one, one, which is minus four. So if you ask a computer what minus, minus four is and it's got three bits in its word, it will tell you the answer is minus four, which is actually wrong, sort of. So usually computers don't have three words, three bits in a word. They usually have something like 64 bits in a word. So for 64 bits, what would go wrong is if you take minus two to the 63 and take minus that it will tell you that that's minus two to the 63. So computer arithmetic has this rather curious, I'm not sure if it's exactly a bug. I think it's really a feature, but whatever. Now, the next thing we want to ask is we've got these operations plus, minus, and times. Do these obey the usual rules of arithmetic? Well, what are the usual rules of arithmetic? Well, there are things like A plus B equals B plus A, A plus B plus C equals A plus B plus C and a whole bunch of other similar rules which I won't bother writing out because they're not terribly interesting to watch. So the question is, do these hold for 10 addict integers? So we've defined addition and multiplication and subtraction. We want to know if these behave in the way we expect and the answer is yes, mostly. There are one or two minor exceptions as we'll see a little bit later. And to see this, we recall what the integers mod 10 are. So you remember modular tenor arithmetic just means you throw out powers of 10. So you say five plus six equals one because this is equal to 11 and you can throw out the factor of 10 and you can say seven times eight equals six because 56 is equal to six if you throw out multiples of 10. So this just means ignore multiples of 10 and you know, if you've been to a number theory lecture that the integers modulo 10 also satisfy the usual rules of arithmetic. And now let's take a random 10 addict number like eight, three, two, nine, one or something like that. And you notice this gives us an integer mod 10. So we can take this number mod 10 and it's just one mod 10. We can also take it modulo 100. And it's obvious what it is modulo 100. It's just 91 modulo 100. And we can take it modulo 1000 and we get 291. And I think you're getting the idea we can just sort of continue taking it modulo any power of 10. So we've got a number mod 10 and a number modulo 100 and a number modulo 1000. And you notice these numbers are compatible because we can go from 91 to one just by taking the last digits and we can go from 291 to 91 because there's the 91 going to there and so on. And similarly, here we would get a three, two, nine, one and so on. So a 10-addict integer can be thought of as a collection of compatible integers. So a 10-addict integer is given by an integer mod 10, an integer modulo 100, an integer modulo 1000 and so on that are compatible. So by that I mean your integer modulo 10 and your integer modulo 100 and your integer modulo 1000 after the same ones as the integer modulo one and the same 10s as the integer modulo 100 and so on. And you can multiply 10-addict integers. So all these operations plus minus times can be carried out mod 10, modulo 100 and so on. So to multiply two 10-addict integers, for example, we multiply them mod 10 to get the mod 10 part of it then we multiply the modulo 100 to get the modulo 100 part of it and so on. And since arithmetic modulo 10 or 100 and so on obey the usual rules of arithmetic, this means that the 10-addict numbers also obey the usual rules of arithmetic. What we say is the 10-addict numbers, 10-addict integers form a ring. So a ring is just a mathematical term for something that has addition and subtraction and multiplication, I guess it also has zero and one and obeys the usual rules, where I'm being a little bit vague about what the usual rules are because I'm feeling too lazy to write them out. So we've done addition, subtraction and multiplication. What about division? Can we divide 10-addict integers? Well, not always. So let's try dividing seven, eight, three, some 10-addict integer like that. Let's try dividing it by two. Well, this fails because if we've got any 10-addict integer, it ends in some digit N. And if we multiply it by two, this is going to end in the digit two N, which is even. And you see this is an odd digit here. So it can't be two times a 10-digit number. So we cannot always divide by two. But you see, you can divide by two if the last digit happens to be even, but not in general. Similarly, we cannot always divide by five because five times anything will have a last digit divisible by five. What about three? Well, this isn't so clear because if we multiply the last digit by three, it can be anything modulo 10. Well, let's take a look at this number minus one, which was something, something, something, nine, nine, nine, nine, nine. Can we divide this by three? Well, it's pretty obvious how to divide it by three. So if we divide it by three, we get a whole string of threes because we can just divide each digit nine by three. So this is equal to minus one, which is this number divided by three. So can we find one over three? Well, all we have to do is to take minus this. So you remember how we took minus a periodic number. First, we take nine's complement, which is a lot of sixes. And then we add one and we get seven, six, six, six, six, and so on. So this number here is the 10-addict number one-third. We've managed to divide by three. And if you don't believe me, let's try multiplying it by three. So let's take three times this. Well, three times seven is 21. Gives us a one, carry two. Three times six is 18, plus two is 20. Carry two, three times six is 18, plus two is 20, carry two, and so on. So we do indeed get the 10-addict integer one if we multiply this by three. So, well, we've done. What about, let's try doing seven and see what happens. Well, let's try it first for real numbers. What happens if we take one over seven for a real number? Well, this gives us 0.142857142857142857 and it just keeps on repeating forever. If you notice it's got this sequence, 1-4-2-8-5-7 and the same thing occurs there and the same thing occurs there. What happens if you get two over seven? Well, this is 2-8-5-7-1-4, 2-8-5-7-1-4 and what you notice is this is a sort of cyclic permutation of this number in some sense. Here we've got 1-4-2-8-5-7, 1-4-2-8-5-7 and so on. And the same thing happens if you try three over seven. Here we get 0.4-2-8-5-7, 1-4-2-8-5-7, and so on. And again, we've got this number 1-4-2-8-5-7 repeating endlessly and you can do the same for four sevenths, five sevenths and six sevenths, which you can do as an exercise. I'm feeling too lazy to. So now let's try this for the 10 addicts. So let's try and guess what is one over seven for the 10 addicts. Well, if we've got a 1-4-2-8-5-7 repeated for the reals, how about we try it for the 10 addicts? So let's try this number 1-4-2-8-5-7, 1-4-2-8-5-7 and so on. So I want to repeat an infinite number of these. And let's multiply it by seven and see what we get. Well, seven sevens is 49, carry four seven threes is 35, yep it's 39 and we carry on like this and we find we get a whole lot of nines. Which is not one, this is minus one. So this number here is minus one over seven. By the way, the reason you're getting a lot of nines here is it depends on the fact that 1-4-2-8-5-7 times seven is 999999. And this fact underlies the real decimal expansion and also underlies the 10 addict expansion for one over seven. Well, all we have to do to get one over seventh is to take minus this number here. So let's take minus this number first. We take nine's complement which gives 8-5-7-1-4-2-8-5-7-1-4-2. And then we have to add one to it. So if we add one, we get 8-5-7-1-4-2-8-5-7-1-4-3. So the last digit is a little bit funny because it's not quite periodic. You see, this number here is sort of periodic except for the last digit. So this is one over seven as a 10 addict integer. And if you want, you can try and figure out what two over seven and three over seven are and see what patterns you get. Now it turns out you can do the same thing for any integer, not divisible by two or five, and you find it's got a 10 addict expansion that's almost periodic except for the few digits at one end. You remember the same thing is true for inverses of reals, modulo 10. For example, one over six is 0.166666. It's almost periodic except for this one at the beginning. And one seventh is periodic except for this three at the end. So we can divide by any integer. In fact, we can divide by any P addict integer whose units digit is one, three, seven, or nine. Well, why these ones? Well, these have inverses, modulo 10. So the inverse is one, seven, three, nine. So you notice that three times seven is one modulo 10. And to do that, we can find the inverse. So we can divide using long division. I guess long division probably isn't taught anymore because it's useless and tedious and calculators can do it much better. But there is a method for doing long division of real numbers and pretty much the same algorithm works for doing long division of 10 addict numbers. Sorry, that should be a 10 addict. I'm not quite doing P addict yet. We can do long division of 10 addict numbers provided we can divide the units digit. I'm not going to give examples of this because it's really tedious to do and really tedious to watch. But anyway, we do have a perfectly good notion of division of 10 addict numbers provided the last digits one, three, seven, or nine. Now let's move on to square roots. Well, at this point, we run into a bit of a problem because you know that any number has at most two square roots and it's quite easy to prove this. Well, the problem is a 10 addict number can have four square roots. So there seems to be something funny going on because numbers are only supposed to have at most two square roots. Well, there's a bit of a problem which is due to the fact that we can have A, B equals zero, but A is not zero and B is not zero. So when I said it satisfied all the usual rules of arithmetic, that wasn't quite true because it doesn't quite satisfy this rule. And we've seen some examples of this. You remember, we found an example of a 10 addict number such that n squared equals n, but n is not equal to zero or one. And now if we take two n minus one squared, this is equal to four n squared minus four n plus one which is equal to one because n squared is equal to n. So there are numbers not equal to nought or one whose square is one and we can, in fact, you can write them down quite easily by calculating two n minus one and one of them turns out to be three, five, seven, four, one, eight, seven, five, one. So if you take this number and square it, you discover it's zero, zero, zero, zero, zero, zero, one. And you can also take minus this number 10 addictly. So one has at least four square roots. In fact, it's got exactly four square roots. It's got one squared is one minus one squared is one and we've got this funny number squared is also one. And the reason for this problem can be traced back to the fact that if you look mod 10, we have two times five is equal to zero mod 10, but two is not equal to zero and five is not equal to zero. So instead of doing square roots for the 10 addicts, which has a lot of rather tiresome complications, I first want to get rid of this problem. Now you notice the problem here is that 10 is not prime. Now, instead of working to base 10, we can work with base P for P prime and these give things called the P addict numbers where P is prime. Okay, and this will be the topic of the next part of this lecture. So I'm going to stop this lecture because I've come to the end of my attention span and there should be a link to the next part of the lecture.