 This lecture is part of Berkeley Math 115, an introductory undergraduate course on number theory, and this one's going to be a little bit unusual because I'm going to be discussing some number theoretical features of pocket calculators. So the first pocket calculator I want to look at is this Casio FX300ES+. I bought this fairly recently, not as a number theoretical calculator, but as a sort of burner calculator, so it was cheap less than $10 one, and it's got a solar panel, so just in case a zombie apocalypse arrives. And the reason I picked out this one is it has this rather interesting button. This button here says GCD and this one says LCM, and you probably can't see it because whoever designed this calculator thought it'd be a clever idea to use bluish purple lettering on a purplish blue background, so maybe if I magnify it you can barely see it says GCD there. It stands for greatest common divisor and least common multiple. For example, if I want to take the least common multiple of say 12 comma commas there, 12 and 8, it gives that as 24. So that's a nice number theoretical feature. Another one I noticed is this button says FACT, and I originally assumed this meant factorial, but the factorial is actually up here, and FACT turns out to mean factorize. For example, if I enter 999999 and factorize it, it tells me the prime factorization of this number. For instance, in lectures earlier we mentioned Fermat's conjecture about whether Fermat numbers were all prime, so these were numbers of the form 1 plus 2 to the 2 to the n, and the one Fermat got stuck on was 1 plus 2 to the power of 2 to 5, which as we can see is equal to that number there, and if we factorize it it tells us that one of the factors is 641, which is the factor found by Euler. So if Fermat and Euler had had this calculator they would have saved themselves a good deal of time and trouble. I should say I found by experimenting that their factorization routine isn't actually all that perfect. For instance, if I take 1099999 and square it and try and factor this, so it ought to be detecting the factor of 1099999, but instead it just gives up. What it appears to be doing is just checking all numbers up to 1000 to see if there are factors and then giving up after that. So it's not perfect, but if I haven't saved this thing only cost $10 it's, you know, 10th of the price of a more advanced calculator, so we shouldn't complain. The next calculator I have is this Swiss Micros DM42. So Swiss Micros are a small Swiss computer company that makes clones of old HP calculators. So this is a clone of the HP42 and people stopped making HP42s about 30 years ago and you may wonder why on earth would anybody make a clone of a 30 year old calculator. If you're wondering that, go to eBay and try and buy a second hand HP42 calculator and you will find they're going for two to three hundred dollars, which is two or three times as much as a top-end modern graphing calculator. That's how good the HP42 was. It's a really, really well designed calculator. I found I can just use most of the keys on it without, you know, looking up on a manual, very intuitive and easy to use. Anyway, the DM42 actually has one rather interesting enhancement of the HP42. It doesn't actually have any particular functions devoted to number theory. However, if you do complex multiplication number theory, you may have come across the fact that e to the pi root 163 is very nearly an integer. So let's try and check this on this calculator. So we take 163. We take its square root. We multiply it by pi. Let me multiply them together. Now we exponentiate it to e to the x and you get this number. You see I was checking before making this video that this worked. And now we want to check that this is very close to an integer. Well, this is obviously useless because calculators tend to work to about 12 significant figures. And since this number is about 10 to the 17, a calculator is not going to be able to tell you whether it's an integer or not. The precision has broken down too much. However, that's an ordinary calculator. This calculator, we can ask it to show all the digits it's working with. And you see here we have 262537412640768743 point followed by this wonderful string of 12 nines and followed by a few more digits. So that's right. This calculator is working to about 34 significant figures of precision when it does really arithmetic. It's pretty impressive. We can also do things. For ordinary calculators, if you try and work out a hundred factorial, it would give you an error message. This one, let's try a thousand factorial. So the factorial is under probability. So there it gives a thousand factorial is about four times 10 to the 2567. So it allows the exponent in numbers to go up to several thousand. The other really wonderful thing about this calculator is you can sort of get it for free. Well, you can't get the calculator itself for free, but you can get an app for it written by Thomas Bocken. If you search for free 42 on Google, it will give you places where you can download an app for mechantoshes or PCs or whatever. So Thomas Bocken has very kindly made this available for free. So the final calculator I want to talk about is this top end graphing calculator. Well, it was a top end graphing calculator about 20 years ago when I bought it. It's the HP 50G and I want to show you a few of the number theoretical functions it can do. It has actually, it has far too many to show. It does things like the Euler-Totient function. It can do modular arithmetic. So if you remember, we had a primality test where you could test whether A to the n minus 1 was congruent to 1 mod n to see if n is prime and it can do that very efficiently. But some of the features that I was a little bit surprised by, if you, first of all, it's got a next prime button. So if I want to know what is the next prime after a million, then I can just go to the integer and one of these is the next prime button. So I press that says next prime. It tells you the next prime after a million is a million and three, which is very useful if you're trying to think of a few large primes. It's also got a more powerful factorization routine. So let's try squaring this and then we'll try factoring it. So there's the factor button. So we factor this number, which you notice is more than 10 to the 12. So it's working to more than 12 significant figures precision. And there you see after a few seconds, it's actually found the factor a million and three. So how far up can this go? Well, if the factor is more than about 10 to the eight, it will still keep going, but it gets very, very slow. So it can factor numbers up to about 10 to the 15. But after that, you have to start being rather patient. There's another slightly remarkable thing it can do. Suppose I take the number 999999 and try and factor it. This doesn't give anything too surprising. So let's factor that. So as expected, it gives the same factors that the Casio found. But now let's try 999999 and now I'm going to multiply that by i and I'm going to factor that. And then we get this rather odd Easter egg. If I factor this, well, we have i times three cubed times seven times 11 is expected. Then it is plus two i times three minus two i. So what's going on there? Well, it's factored this number in the Gaussian integers. You know, 13 is equal to three plus two i times three minus two i. So some board engineer at Hewlett-Packard actually programmed a factorization algorithm for Gaussian integers in this calculate. And as far as I can tell, it's not actually documented anywhere. I just stumbled across this by accident. So it definitely gets extra number theory bonus points for this weird feature. It only seems to do Gaussian integers. I tried it on other quadratic fields and it doesn't seem to know about factoring an arbitrary quadratic fields unfortunately. It's also very high precision. For instance, how high precision? Well, suppose I try doing a thousand factorials. So let's go to the probability where they keep the factorial function. Let's do three factorial. Now we'll have to wait a bit for a reason I'll explain in a moment. Incidentally, you see one of the disadvantages of this calculator is there's too many functions. Whenever you want to find a function, you've got to go scrambling through several menus. And honestly, it's got so many functions. I can't actually remember what half the buttons on this calculator do. One of the big advantages of the DM42 is you can actually remember what all the buttons on it does. Whereas these ones, you have to sort of carry manual around. Okay, there it's come up with a thousand factorial. Now, how precise is this? Well, let's view it. And now we can go, if you see it's going on for quite a long time. And in fact, I'm going to give up because it's actually working a several thousand digits precision. And it would take, you know, minutes to get to the end of this number. If you don't believe me that it's working a several thousand digits precision, let's clear that. And let's go and work out 10 to the power of a thousand. Suppose the Y to the X key there it is. So there's 10 to the thousand. And I'm going to subtract one from it. And it gives me a string of nines. And you can see if it was working to anything less than a thousand digit precision, it wouldn't know that this would start with a lot of nines. It would just give me 10000 and so on. So this calculator really is doing integer arithmetic to thousands of digits precision, which I can't imagine anybody other than a number theorist actually needing this. So there's three calculators for number theory. I must admit that if you actually want to do serious number theory on a calculator, what you would probably do is download one of the packages like GP or SAGE that are specially designed for doing number theory calculations on a computer. If you want to download one of these, just search for these on Google and it will give you a place to download them. So both of these programs can do arbitrary precision arithmetic in a far more built-in functions than even the HP calculator.