 This lecture is part of the Berkeley Math 115 course on undergraduate number theory and is a continuation of the previous lecture where I'll be giving a survey of some of the things that we might be covering later in the course. So the first thing I'm going to talk about today is congruences. So to motivate this, suppose we have the following question. Is 1, 2, 3, 4, 5, 6, 7 a square of an integer? And it wouldn't be too difficult to do this by bit of calculation. But in fact, you can see it's actually obvious that it's not a square. The reason it's obvious that it's not a square is the last digit is 7. And if you've got a square number, then the last digit has to be the square of 0 squared, 1 squared, 2 squared and so on, or up to 9 squared, which is 0, 1, 4, 9, 6, 5, 6, 9, 4, 1. So the last digit has to be one of these numbers here. And since 7 doesn't appear, we can immediately see without any real calculation that this number is not a square. And so what this is, is a special case of looking at things modulo 10, where in general we say an a is congruent to b modulo some number n. So this just means a minus b is divisible by m. So this notation was introduced by Gauss and turns out to be very useful. So here we're saying that 1, 2, 3, 4, 5, 6, 7 is obviously congruent to 7 modulo 10, but x squared is not congruent to 7 modulo 10 for any x. So you can look at more complicated versions of this. For example, we can ask is 1, 0, 0, 0, 0, 0, 3 of form x squared plus y squared for some integers x and y. Again, you could do this just by trial and error, although it'd be a bit more tiresome because there are about a thousand different numbers x you have to check. However, there's a rather easy way to see this isn't possible because we notice that x squared is congruent to 0 or 1 modulo 4. So if you've got any square, you can check that its remainder is always 0 or 1. So x squared plus y squared must be congruent to 0 or 1 plus 0 or 1 mod 4, which is congruent to 0, 1 or 2 mod 4. However, 1, 0, 3 is not congruent to 0, 1 or 2 mod 4. So we can see very easily that you can't solve this equation. One of the basic theorems about congruence is Fermat's theorem. This is not Fermat's last theorem, it's Fermat's little theorem, which says that if you've got a number x, then x, the p, is always congruent to x modulo p whenever p is a prime. So for example, we see that 2t11 is congruent to 2 modulo 11 and 2t11 is 2048. So this says that 2048 minus 2 is divisible by 11. There's another version of this theorem you sometimes see, which is just says that x to p minus 1 is congruent to 1 modulo p whenever x is not divisible by p. So these two forms are essentially the same theorem, but sometimes one is useful and sometimes the other is useful. So this only works for p being a prime and you can ask, is there some sort of analog of this for numbers p that are not prime and Euler found a rather nice analog of this. He says that x to the phi of m is congruent to 1 modulo m whenever x and m are co-prime. Well, what's this number phi of m? Well, phi of m is the number of integers 1 up to m minus 1 that are co-prime to m, in other words, that have no common factors. So for example, if we take m equals 12, the numbers from 1 to 11 that have no common factors with m are 1, 5, 7 and 11. There are four of these, so phi of 12 equals 4. So we find that x to the 4 is always congruent to 1 modulo 12 whenever x is co-prime to 12. So these Fermat's theorem and Euler's theorem are some of the most basic useful theorems in number theory used all the time. So let me give one application of Fermat's theorem. Suppose you want to test if n is prime. Suppose n is very large. Maybe it's got a hundred digits or something. Well, we can apply Fermat's theorem. Again, what we do is we work out 2 to the n and modulo n and see and ask, is it congruent to 2 modulo n? So it turns out there's a fast way of checking this even if n has hundreds of digits that we'll talk about later. So if not, n is not prime. So we can quite often check that very large numbers aren't prime without finding any factors of them. If so, well n might be prime. It's probably not prime, but we can't really be sure. You might then try and see if 3 to the n is congruent to 3 modulo n and so on. You can try several other checks like this. So this is something known as a probabilistic prime number test that it will sometimes tell you that n is definitely not prime and it will sometimes tell you that n is probably prime, but we're not really sure about it. So congruences are useful because if you're trying to solve a Di-Fantine equation, say fxyz equals 0, then fxyz is congruent to 0 modulo n, rather obviously. So if we can solve a polynomial in the integers, we can solve it modulo m for all numbers m. So we can quite often very quickly check that a Di-Fantine equation has no solutions by checking it's got no solutions modulo m for some n. We can ask, is the converse of this true? Well, there's something called the Hasse principle which says roughly if a function has a solution modulo m for all m, if the Hasse principle holds, then this says that it then has an integer solution and sometimes the Hasse principle holds and sometimes it doesn't. So for linear equations, the Hasse principle tends to hold. For equations that have a degree greater than 1, it gets kind of complicated. I mean, there are some cases when it holds and some cases when it doesn't. So in particular, we can look at quadratic equations and the very basic one is to ask, can we solve x squared equals a modulo some number which we usually take to be prime for various reasons that we will see. So we can ask, is a a square modulo a prime? If so, we say a is a quadratic residue. So quadratic means a square and residue means you're reducing modulo p for some p. So for instance, if p is equal to 7, then let's try and find out which numbers are squares modulo 7. Well, we just look at 0 squared is 0, 1 squared is 1, 2 squared is 4, 3 squared is 9, which is congruent to 2, 4 squared equals 16, which is congruent to 2 again, 5 squared equals 25, which is congruent to 4, and 6 squared equals 36, which is congruent to 1. So the squares 0, 1, 2 and 4. And there's a useful piece of notation for this, which is the Legendre symbol, which is denoted by a p. And this is defined to be plus 1 if a is a square mod p, and a is a coprime to p, and it would be minus 1 if not. And again, a p is 1, and it's 0 if a is divisible by p. This seems to be a really rather funny sort of definition, but it turns out to be very useful. And one of the key points we'll see later is that it's actually rather fast to calculate this number, even if a and p are very large. We don't have to check all numbers to see if a is a square. We will find methods to find this. And one of the basic things we'll be proving is the law of quadratic reciprocity. So Euler calculated a large number of these quadratic residue symbols, and he noticed a funny relation between pq and qp, where p and q are odd primes. I mean, what he did, he just sort of calculated a table of these for p primes up to about 100 or something. And there's no obvious reason why these two should have anything to do with each other. So the first one is 1 if x squared equals p plus qy has a solution, and the other one is 1 if x squared equals q plus py has a solution. And if you've got a solution of this, there doesn't seem to be any obvious reason why there might or might not be a solution of this equation here. So what Euler discovered empirically is that p and q is equal to qp if q or p is congruent to 1 modulo 4. And pq is not equal to qp if q and p are both congruent to 3 modulo 4. That's for p not equal to q, I guess. So this is really kind of amazing because what it means is these two apparently unrelated equations are somehow very closely linked to each other. So this is a sign that there's some very subtle hidden structure going on. And a lot of number theory consists of this sort of search for hidden structure. You want to find some sort of amazing coincidences that don't seem to have any other obvious explanation. If you find these, it's often a sign that there's some sort of magical hidden structure lying underneath the surface. So for example, we can ask is 3 a quadratic residue of 71? In other words, can you solve the equation x squared is congruent to 3 mod 71? Well, it wouldn't be too difficult to check this by just checking a few cases. But you notice this is asking whether 3 71 is equal to 1. And by the quadratic reciprocity law, this is the same as asking is 71 3 equal to 1. And this is very easy to work out because both of these are 3 modulo 4. So this number here is going to be the opposite of this number here. And 71 2s 3 is minus 1 because 71 is congruent to 2 modulo 3, which is not a square. So we can very quickly figure out whether numbers are squares or not using the law of quadratic reciprocity without doing a lot of slightly tedious calculation. Next I want to discuss another branch of number theory called additive number theory. So additive number theory sort of asks about what happens when you try adding things together. For instance, there's a very famous one due to Goldbach, which says is every even number greater than or equal to 4 a sum of 2 primes? So most of them are, for instance, we can have 12 is equal to 5 plus 7 and 14 is equal to 7 plus 7 and 16 is equal to 5 plus 11 and so on. So this certainly seems to be true. And this seems to be an extraordinarily difficult question to answer. So Hardy, Littlewood and Vinogradov managed to show a weak version of it. They managed to show every sufficiently large odd numbers as a sum of 3 primes. The best result we have on this is due to Chen, who showed that every even number can be written as the sum of a prime plus a product of two other primes. So the product of two primes is a little bit weaker than actually being a prime, but so far we haven't actually get any closer. A very similar problem is the twin prime conjecture, which says can we find infinitely many primes such that p and p plus 2 are both primes? And again, there was some amazing progress on this recently by Zhang, who managed to show that there's an infinite number of primes such that p plus something at most a few million is prime. And people have later got this down to p plus something at most a few hundred, but we still seem to be a long way off too. Another similar one is can can you find arithmetic progressions of primes? Well, you can certainly find some, for instance, we can find 5, 11, 17, 23 and 29. So each of these differ by six. So here we've got an arithmetic progression of length 5 and you can't extend it any further because if you add 6 to this again, you get 35, which is no longer prime. And a question is, can you find arbitrarily long arithmetic progressions of primes? And this was again, answered a few years ago by Green and Theo. And all of these questions are sort of about adding or subtracting primes. So here you can see you're adding primes, here you're subtracting them and here you're taking differences of primes. And all questions about adding and subtracting primes tend to be very difficult. In fact, there's one point of view that says they're not only difficult, but they're kind of stupid. I mean, the physicist Landau said, you know, why are these mathematicians adding prime numbers? Prime numbers meant to be multiplied, not added. Well, the problem with that is that it's not entirely clear that you shouldn't be adding prime numbers. You could say the same thing about squares. Adding squares sounds stupid, but there turns out to be a lot of deep and very interesting structure about adding squares. For instance, we can ask whether a prime is a sum of two squares and we will see later on in the course that that's actually a rather deep question. So it's difficult to tell in advance whether a question is sort of sensible or not. By the way, when we talk about arithmetic progressions, there's another theorem about arithmetic progressions and primes due to Dirichlet, which says suppose you take an arithmetic progression of all numbers a plus n times b. For instance, we might take all numbers of the form 1 plus 10n, so we're asking for all numbers with final digit 1. And what Dirichlet managed to prove is that in any arithmetic progression there are infinitely many primes, unless it's obvious there are not. Obviously, we must take a and b to be co-prime. And we will be showing several special cases of Dirichlet's theorem later on in the course. So Dirichlet's theorem is a special case of the following more general theorem. Suppose you take a polynomial a0 plus a1n plus a2n squared and so on and ask, does this polynomial represent infinitely many primes? So Dirichlet's theorem is the special case of polynomials of degree 1. And the answer is sometimes no. For instance, if we take a polynomial n times n plus 1, which is n squared plus n, obviously this can't represent infinitely many different primes because, except for a few special values of n, it factorizes as n times n plus 1. So we should say the polynomial can't factorize. Even if you say that there are problems. For instance, suppose I take the polynomial n squared plus n plus 4. This polynomial doesn't factorize. However, we notice that n squared plus n is always even for any integer n. So this polynomial is always even. So it obviously can't represent an infinite number of primes. So you can ask, suppose you've got a polynomial and suppose it doesn't factorize and suppose its values aren't always divisible by something bigger than 1. Then does it represent an infinite number of primes? And the simplest example of this is the polynomial n squared plus 1. So are there infinitely many primes of the form n squared plus 1? Well, there are quite a few. We have 2 squared plus 1 equals 5. 4 squared plus 1 equals 17. 6 squared plus 1 equals 37. 8 squared plus 1 is 65, which is not prime. So they're not always prime. And nobody actually knows the answer to this. Well, actually we do know the answer. I mean, it's extremely likely that there are infinitely many primes of the form n squared plus 1. But we don't know how to prove this. Dirichlet's proof of his theorem depends very much on the polynomial being of degree 1 and simply doesn't work for polynomials of high degrees. So here's a very simple question about primes that nobody knows how to answer. If you're feeling bored, you can also do recreational number theory. And there's no precise definition of this, but let me just give you a few examples of it. One famous example is the problem of perfect numbers. So a number is called perfect if it's the sum of all its proper divisors. So for instance, 6 has proper divisors 1 and 2 and 3, so 6 is perfect. If you take the number 28, its proper divisors are 1 plus 2 plus 4 plus 7 plus 14, which sums up to 28. So these are the first two perfect numbers. And people used to think perfect numbers were really important. There's a famous section in St Augustine who wrote this book called The City of God, which was some sort of religious text. And in the middle of this book, he rather amazingly starts talking about perfect numbers. So here he's saying, well, the world is created in six days because 6 is a perfect number. And he sort of says, well, the fact this number is perfect is something to do with the fact that the creation was perfect and so on. And if you go down a bit, he actually correctly defines a perfect number. You see, it's made up of its own parts. That means divisors. So you know, 6 is the sum of 1, 2 and 3. And he spends the next few lines discussing perfect numbers in detail, which is kind of a bizarre thing to find in a religious book. I should say that modern cosmology has rejected this idea that the world was created in six days or that it has anything to do with 6 being a perfect number. But, you know, they all said some other theories. I mean, another guy said, you know, the moon rotates in 28 days because 28 is a perfect number and so on. It's very difficult to understand how people could have made such apparently silly statements. My theory is that they were actually making a subtle joke and everybody even at the time knew that these were rather silly and, you know, it was just, you know, just considerably an amusing thing to say. As well as perfect numbers, you can look at things like amicable numbers. So here's a pair of amicable numbers, 220 and 284. So if you take the sum of the proper divisors of 220, you get 284. If you take the sum of the proper divisors of 284, you get 220. And what is the point of doing this? Well, frankly, there doesn't seem to be much point in doing this. That's why it's called recreational number theory. There just doesn't seem to be much structure underlying this. You could try treating this as some sort of discrete dynamical system. If you take any number n, you could map it to the sum of the proper divisors of n. And you can think of this as being a function from the integer to itself and ask what it does. For instance, if you look at the first few numbers, 2 goes to 1, 3 goes to 1, 4 goes to 1 plus 2, which is 3, 5 goes to 1, 6 goes to itself because it's perfect. And if you go up to 220, it goes to 284 and 284 goes to 220. And if you've got a dynamical system, you can ask, does it have finite orbits? So for instance, perfect numbers are orbits of size 1 and amicable numbers are orbits of size 2 and so on. The trouble is discrete dynamical systems seem to be incredibly difficult to understand and study. So here's another notorious one. Suppose you just map n to 3n plus 1 if n is odd and n goes to n over 2 if n is even. So for instance, if you look at 1, 2, 3, 4, 5 and so on, 2 goes to 1, 4 goes to 2, 1 goes to 4, 3 goes to 10 and 5 goes to 16 and so on. And there's a notorious open problem in mathematics which says if you stop with any integer n and keep on repeating this, do you eventually end up with this cycle 1, 2, 4? So this is about almost the simplest non-trivial example of a discrete dynamical system and we still can't answer, does it have any orbits other than this? So other examples of recreational number theory, you can have a lot of problems about sums of digits of numbers. For instance, if you look at the number 370, this is equal to the sum of the cubes of its digits and you can try and classify numbers with a similar property. And the problem with all these questions is they just don't seem to lead to any interesting unexpected structure. I mean you can solve this one by trial and error and you have these numbers that are sums of powers of their digits but you can't do anything with them. Next, I just mentioned algebraic number theory. So an example of an algebraic number is the number of the form n plus ni where i is the square root of minus 1. So these are all complex numbers and these are called the Gaussian integers and they turn out to behave in a very similar way to ordinary integers. We will show later that, for example, Gaussian integers have unique factorization into primes, up to units and order, except that primes doesn't mean 2, 3, 5 and 7 because, for example, if you take what you think is a prime 5, it actually factorizes as 2 plus i times 2 minus i. That's because if you multiply this out, you get 2 squared plus 1 squared, which is equal to 5. And Gaussian integers turn out to be really good at dealing with sums of 2 squares because n plus ni times n minus ni is equal to n squared plus n squared. So, for example, we can have 65 can be written as a sum of 2 squares in 2 different ways. And this corresponds to the fact that it's got 2 factorizations as Gaussian integers. So here it's 8 plus i times 8 minus i and it's also equal to 7 plus 4i times 7 minus 4i. And these aren't the only factorizations. You can in fact factorize these even further as 2 plus i 2 minus i times 3 plus 2i 3 minus 2i. So there we've got a factorization of 65 into primes and the different factorizations correspond to different ways of writing 65 as a sum of 2 squares. So there's a very famous theorem by Fermat which says that if p is a prime and p is equivalent to 1 mod 4, then p can be written as a sum of 2 squares. She's very surprising. Adding up 2 squares seems to be as dumb as adding up 2 primes. There's no reason to do so at first sight, but turns out there's this very beautiful theorem that if a prime is 1 mod 4, then you can always write it in essentially unique ways as sum of 2 squares. If p is 3 mod 4, then as we saw earlier, you can't write it as a sum of 2 squares. So a prime is the sum of 2 squares if and only if it's 2 or it's 1 mod 4. So finally I just mentioned combinatorial number theory. So combinatorics is about counting things. There are lots of things you can count that have a very strongly number theoretic flavor. For instance, we can count the number of partitions of n. So a partition of n is a way of writing n as smaller positive integers. So let's, for example, work out the number of partitions of 5. So I want to write 5 as a sum of positive integers. So I can write it as 5 or as 4 plus 1 or as 3 plus 2 or as 3 plus 1 plus 1 is 2 plus 1 or 2 plus 1 plus 1 plus 1 or 1 plus 1 plus 1 plus 1. So altogether there are 1, 2, 3, 4, 5, 6, 7 ways of writing 5 like this. So p of 5 is equal to 7. And if you look at a table of p of n, it looks like this. So here's n is 0, 1, 2, 3, 4, 6, 7 and so on. So the partitions go 1, 1, 2, 3, 5, 7, 11. This is very exciting because you see partitions of a number turn out to be just the sequence of primes. Well, no, not really because when you go to 7, the number of partitions of 7 is 15. So this rather nice conjecture fails. Anyway, there are lots of hidden number theoretic properties of partitions. For example, the number of partitions of 5n plus 4 turns out to be divisible by 5. And there's no obvious reason for this. If you sit down and try and prove it, you probably won't be able to. The reason for this is actually rather deep. So Euler had this rather nice formula for the number of partitions. Suppose you take the power series whose elements are partitions. So we take sum of pn times q to the n. So this is going to be 1 plus q plus 2q squared plus 3q cubed plus 5q to the 4 and so on. And Euler discovered that there was this rather nice factorization for it. It's equal to 1 over 1 minus q times 1 over 1 minus q squared times 1 over 1 minus q cubed, 1 minus q to the 4 and so on. So this is actually quite easy to prove. You can almost have this as an exercise. So that's the end of the first electron number theory. The next lecture will be discussing divisibility and congruences.