NumberTheory Complete PDF
NumberTheory Complete PDF
NumberTheory Complete PDF
Konrad Pilch
April 7, 2016
1 Divisibility
Number Theory concerns itself mostly with the study of the natural numbers (N) and the integers (Z). As a
consequence, it deals a lot with prime numbers and sometimes with rational numbers (Q). Recall:
Definition. The natural numbers are the numbers N = {1, 2, 3, . . . }. The integers are the numbers Z =
{. . . , −2, −1, 0, 1, 2, . . . }. The rational numbers are Q = { ba | a, b ∈ Z, b 6= 0}.
There is significant debate about whether the naturals include 0 or not. It’s probably easier to consider the
naturals to be just the positive integers. If you want to specify the non-negative integers you may write N0
or Z≥0 .
Notation. If an integer a divides an integer b we write a|b.
Definition. A prime number is a positive integer p 6= 1 such that if p divides ab then p divides a or p divides
b. Mathematically, we write this as
p| ab =⇒ p| a or p|b
Remark. Note, when you get to university and learn about more advanced number theory, negatives of
primes will also be included as primes, but we do not worry about that here. Also, note, that this is a different
definition than you may have expected! What about the definition that says "p only has two factors: 1 and
p"? That is the definition for a number that is irreducible. As you can imagine, this ends up being the same
thing as prime numbers when you work with integers. Feel free to use that definition, if it suits you better.
Take a step back for a moment and think about the definition of a prime number that I used. Can we include
rational numbers? Are there any rational primes? The answer to both questions is an emphatic no. The
answer at first may be a bit disappointing and baffling, but it all follows from the fact that only certain
groups of numbers have a concept of divisibility. We have divisibility in the integers, because of an amazing
result called the Fundamental Theorem of Arithmetic.
1
There is a method that allows you to calculate the gcd of two integers very quickly if you do not know their
prime factorisation. It is called the Euclidean Algorithm and it works as follows:
Euclidean Algorithm. Take two integers: let’s say 45 and 159. Take the larger and calculate how many
multiples of the smaller fit into it and write the remainder as follows:
159 = 3 × 45 + 24.
Now, repeat the same with the last two integers (the smaller integer and remainder).
45 = 1 × 24 + 21
24 = 1 × 21 + 3
21 = 7 × 3 + 0
The last remainder above the zero is the gcd! So, gcd(45, 159) = 3.
Corollary 1.1. The gcd of two integers can be written as a linear combination of the two integers.
This corollary is really important. You may never use the Euclidean algorithm unless you are coding an
algorithm on a computer. However, what it does for us, mathematicians, is it tells us that the gcd can actually
be written in terms of the original two integers. I shall do this using the result of the algorithm above.
gcd(45, 159) = 3 = 24 − 1 × 21
= 24 − 1 × (45 − 1 × 24)
= 2 × 24 − 1 × 45
= 2 × (159 − 3 × 45) − 1 × 45
= 2 × 159 − 7 × 45
Each of the above lines comes from rearranging one of the lines in the Euclidean algorithm.
Definition. Two integers a and b are relatively prime (or coprime) if their gcd is 1.
Corollary 1.2. For any two integers a and b whose gcd is 1, there exist integers s and t such that as + bt = 1.
2
2. If d| f and e| f , then
• lcm(d, e)| f where lcm is the least common multiple.
• p|k or p|l.
This is incredible powerful and this can be seen in the following problem.
2n−1
Problem 1. For what integer n is n +7 an integer?
2n−1
Proof. If n +7 is an integer, then
n + 7|2n − 1.
Using Theorem 1.4, we have that
n + 7|2( n + 7).
Employing the same theorem again, this time with subtraction we have
n + 7|2(n + 7) − (2n − 1)
Notice, that negative solutions are of course allowed if the question does not specify otherwise!
k
∏ p i i = p1 1 p2 2 · · · p k k ,
α α α α
n=
i =1
then
• τ (n) = ∏ik=1 (αi + 1) = (α1 + 1)(α2 + 1) · · · (αk + 1), and
• σ (n) = ∏ik=1 1 + pi + · · · + pi i = 1 + p1 + · · · + p1 1 · · · 1 + pk + · · · + pk k
α α α
3
1.5 Introduction to Diophantine Equations
A huge chunk of number theory problems are Diophantine equations (named after an Ancient Greek math-
ematician Diophantus).
Definition. Diophantine equations are polynomial equations in one or more variables where the only desired
solutions are integers.
The polynomial part essentially means you only have powers of variables with addition, subtraction and
multiplication. I provide two simple examples.
Problem 2. Solve 2x + 5y = 1 in integers.
Proof. Note that there are solutions to this since (2, 5) = 1. In fact, notice that rearranging yields
2x = 1 − 5y
In order for the right hand side to be even like the left hand side, it is clear that y must be odd. So, set
y = 2t + 1. Substituting yields
2x = 1 − 5(2t + 1) = −4 − 10t
And so, x = −2 − 5t. In fact, ( x, y) = (−5t − 2, 2t + 1) is the set of all solutions. Yes, it is true there are an
infinite number of solutions for all possible integer values of t!
x n + yn = zn
where n > 1.
Proof. This went unsolved for over 300 years and the person who solved it, Andrew Wiles, used really
powerful mathematics to solve it. There are integer solutions only when n = 2 and then ( x, y, z) = (k( a2 −
b2 ), 2kab, k( a2 + b2 )) for a, b, k ∈ N. You shall prove the n = 2 case in section 4.
4
Problems
1.6 Easy
1. Use the definition of prime at the beginning of the section to show that 4 and 6 are not prime. Why is
any number that has more than two positive factors not prime?
2. Do there exist integers a and b such that a + b = 544 and whose greatest common divisor is 11?
3. Find a rule for divisibility by 8 and 16.
9. Confirm that the formula given for σ(n) is correct simply by expanding out the brackets. [Note: the
formula is
k k
σ ( ∏ pi i ) = ∏ 1 + pi + · · · + pi i ]
α α
i =1 i =1
11. Show that n! + 1 and (n + 1)! + 1 are relatively prime for all naturals n.
1.7 Hard
1. Prove the formula τ (n) = ∏ik=1 (αi + 1) when n = ∏ik=1 pi i .
α
2. Let n be of the form 12k + 2. Suppose that 6k + 1 and 4k + 1 are both prime. Prove that τ (n) = τ (n + 1).
3. (Even Perfect Numbers) If n is even, then σ (n) = 2n iff n = 2k−1 (2k − 1) with 2k − 1 prime.
4. Find the gcd of 250 + 1 and 220 + 1. Show further that (2m + 1, 2n + 1) > 1 if m and n are both odd.
5. Find a formula for the lcm of a and b in terms of a, b and gcd( a, b).
6. If a, b, m are integers such that ( a, b) = 1 and a|m and b|m, show that ab|m.
7. Find the smallest integer n for which
10x + 11y = n
has exactly 9 solutions in positive integers x, y.
8. Prove that if n > 1 and an − 1 is prime, then a = 2 and n is prime.
5
2 Congruence
Modulo Arithmetic is a whole new world. It works almost exactly like normal equations, but you do not
have to worry about things like size or infinity. Essentially, when working with modulo (or mod for short),
you focus on the remainder upon division. So, if you want to see if something is divisible by 5, work in mod
5 and show that everything is zero!!
The best analogy for modulo arithmetic (to get prepared for the mathematical technicalities) is clock arith-
metic: as soon as you hit 12 o’clock, it’s like 0 o’clock and then you go to 1, then 2 and so on and the cycle
repeats once you hit 12. There is a concept of 13 o’clock, but it’s the same as 1 o’clock! That is how I want
you to think around mods.
As you can see, we can add, subtract, multiply, expand and factorise as freely as you wish. However, we
could only divide by 4 because n was relatively prime to 4. In general if you want to divide both sides of a
modulo equation, then you have to divide the mod too (but only if you can). For example:
60x ≡ 480 (mod 70)
⇒ 30x ≡ 240 (mod 35)
⇒ 15x ≡ 120 (mod 35)
⇒ 5x ≡ 40 (mod 35)
⇒ x≡8 (mod 7)
⇒ x≡1 (mod 7)
This is like the “never divide by zero” rule. So, even though we were working mod 70 originally, this reduced
down to mod 7 simply because we were dividing by numbers that had factors in common with the mod. So,
when we divided by 2 in the first line, the mod had to be divided by 2. But when we did that in the second
line, the mod stayed as 35, since (2, 35) = 1. In line we divide by 3 and so again the mod stays as 35, but
when dividing by 5, we have to reduce the mod too. The last line comes from the fact that 8 ≡ 1 (mod 7).
And so, the solution is all x ≡ 1 (mod 7), which are numbers like . . . , −13, −6, 1, 8, 15, . . .
6
• Be careful with indices:
There are many counter examples, consider 25 = 32 6≡ 25 = 52 (mod 3). If you want to fiddle with
large indices in a modulo equation, then you should probably use Fermat’s Little Theorem or Euler’s
Theorem (see later).
• Be careful when square rooting if n is composite:
a2 ≡ b2 6=⇒ a ≡ ±b (mod n)
There are many counter examples, like mod 8: we have 12 ≡ 32 ≡ 52 ≡ 72 ≡ 1 (mod 8).
2.2 Modulo p
Prime numbers are way more interesting than composite numbers, In fact, the main reason why prime
numbers are so popular is because everything works out nicely in (mod p). Here are a few of these extra
handy tricks: Remember that the following tools ONLY work if p is prime.
abcd ≡ 0 ⇐⇒ a ≡ 0 , b ≡ 0 , c ≡ 0 or d ≡ 0
As an example, suppose 5x ≡ 0 (mod 7), then since 5 6≡ 0 (mod 7), it follows that x ≡ 0 (mod 7).
• The “normal” division Law:
ab ≡ ac ⇐⇒ b ≡ c (unless a ≡ 0)
As an example, suppose 2x ≡ 4 (mod 7), then x ≡ 2 (mod 7).
• The Inverse Law: For any x 6≡ 0, there exists an x −1 such that
x −1 x ≡ 1 (mod p)
As an example, in mod 7, 1−1 = 1, 2−1 = 4, 3−1 = 5, 4−1 = 2, 5−1 = 3 and 6−1 = 6. Check these! [eg.
2 × 4 = 8 ≡ 1]
• Generators: There exists g 6≡ 0 such that {1, g, g2 , g3 , . . . , g p−2 } is a rearrangement of {1, 2, 3, . . . , p − 1}
(mod p).
As an example, in mod 7, there are 2 generators: 3 and 5, because the set {1, 31 , 32 , 33 , 34 , 35 } =
{1, 3, 2, 6, 4, 5} covers the entire set {1, 2, 3, 4, 5, 6}. The same occurs for 5.
• Quadratic Residue Law:
a2 ≡ b2 ⇐⇒ a ≡ ±b (mod p)
As an example, suppose x2 ≡ 4 (mod 7), then x ≡ ±2 (mod 7). Remember −2 ≡ 5 (mod 7).
7
Chinese Remainder Theorem. If you know what x is in (mod a1 ), (mod a2 ), (mod a3 ), . . . , (mod ak ), then
you must know what x is (mod a1 a2 a3 · · · ak ), as long as { a1 , a2 , a3 , . . . ak } are pairwise relatively prime.
More concretely if
x ≡ r1 (mod a1 )
x ≡ r2 (mod a2 )
x ≡ r3 (mod a3 )
···
x ≡ rk (mod ak )
then the Chinese Remainder Theorem guarantees that there exists a unique solution for x in (mod a1 a2 a3 · · · ak ).
Let’s see this in action.
Problem 5. Find all integers n such that n leaves a remainder of 2 when divided by 3, a remainder of 2 when
divided by 4 and a remainder of 1 when divided by 5.
Proof. We have
n≡2 (mod 3)
n≡2 (mod 4)
n ≡ 1 (mod 5)
Since 3, 4 and 5 are pairwise coprime (this means (3, 4) = 1 and (3, 5) = 1 and (4, 5) = 1), we can apply the
Chinese remainder theorem. Thus, there is a unique solution for n (mod 3 × 4 × 5). So, there is a unique
solution for n (mod 60). There are many ways to find what this unique value is and I suggest you attempt
this yourselves.
The answer, nonetheless, is n ≡ 26 (mod 60).
Remark. Don’t be confused by what it means to have a unique solution (mod 60). It means that there are an
infinite number of solutions, and they all leave a remainder of 26 when divided by 60. They are, for example,
. . . , −34, 26, 86, . . . Please double check that these numbers satisfy the conditions in the problem.
(mod 5)
(mod 4)
(mod 3) x x2
x x2
x x2 0 0
0 0
0 0 1 1
1 1
1 1 2 4
2 0
2 1 3 4
3 1
4 1
8
Notice, how I filled out the table for numbers {0, 1, 2, . . . , n − 1}. The reason is that as soon as you hit n again,
it’s back to zero (like clock arithmetic), so the value for n2 in the table will be the same as 02 . Similarly, for 12
and (n + 1)2 and so on.
Problem 6. Find any solutions for x2 + y2 = 765483 in integers.
Proof. Consider the left hand side modulo 4. Each square (x2 or y2 ) is either 0 or 1 if we consult the appro-
priate table. So, the left hand side is ≡ 0, 1 or 2 (mod 4). On the other hand, the right hand side 765483 ≡ 3
(mod 4), so the two sides can never be equal and there are no solutions!
9
How did I get these numbers? They come from Euler’s Theorem below. The corresponding result for prime
numbers is called Fermat’s Little Theorem.
x p −1 ≡ 1 (mod p)
The second form is more common and more useful, since the first version has to take into account what
happens to numbers ≡ 0 (mod p), which is easy anyway.
Problem 7. What is the remainder when you divide 655758 by 7?
Proof. Since 655 ≡ 4 (mod 7), we really are trying to work out the remainder when 4758 is divided by 7. But
since (4, 7) = 1, we can apply Fermat’s little theorem to get that 46 ≡ 1 (mod 7). We now have enough
information to solve the problem.
k
∏ ( p i − 1) p i i
α −1 α −1
φ(n) = = ( p1 − 1) · · · ( pk − 1) p1α1 −1 · · · pk k .
i =1
We shall prove this is in one of the problems for this section. We are now ready to see Euler’s theorem.
Euler’s Theorem. For integers a and n such that ( a, n) = 1, it follows that
10
Problems
2.8 Easy
1. If p is a prime and a2 ≡ b2 (mod p), prove that a ≡ ±b.
2. Verify that 2−1 ≡ 3−1 + 6−1 (mod 7).
3. Prove that there is no triangular number which is one less than a multiple of 11.
7. What are the last two digits (units and tens digits) of 123456 ?
8. Show that no prime number of the form 3n − 1 can be expressed as x2 + 3y2 for any x or y.
9. Find the remainder when 1919 is divided by 5.
2.9 Medium
1. Determine all integers n, m such that m2 = n! + 3.
2. Determine all integers n such that n4 − 3n3 − n2 + 4n + 1 is a multiple of 7.
3. Let d be any positive integer not equal to 2, 5, or 13. Show that one can find distinct a, b in the set
{2, 5, 13, d} such that ab − 1 is not a perfect square.
4. Find all integer solutions to the equation x2 = 65y − 1.
5. The integers a, b and c are the sides of a right angled triangle. Prove that abc is a multiple of 60.
x p −3 + x p −4 + · · · x 2 + x + 1 ≡ p − 1 (mod p)
7. Let n be a positive integer and let a1 , a2 , a3 , . . . , ak (k ≥ 2) be distinct integers in the set {1, 2, . . . , n} such
that n divides ai ( ai+1 − 1) for i = 1, 2, . . . , k − 1. Prove that n does not divide ak ( a1 − 1).
2.10 Hard
k
α
1. (Euler Phi Function) We shall prove the formula for φ(n). As usual, assume n = ∏ pi i .
i =1
(a) First, simplify the problem and assume n = ab where ( a, b) = 1. Prove φ( ab) = φ( a)φ(b). [Hint:
it’s really important to use the fact that a and b are coprime.]
(b) Using (a), show that
k
∏ φ ( p i i ).
α
φ(n) =
i =1
11
(c) Now, compute φ( pα ) where p is prime.
(d) Put all the preceding parts together to find the formula for φ(n).
2. Let a, b and c be positive integers, no two of which have a common divisor greater than 1. Show that
2abc − ab − bc − ca is the largest integer which cannot be expressed in the form xbc + yca + zab, where
x, y and z are non-negative integers.
3. For any positive integer n, prove that
98n − 68n − 31n
is always one less than a multiple of 2010.
5. Determine all positive integers relatively prime to all the terms of the infinite sequence
a n = 2n + 3n + 6n − 1 , n ≥ 1.
12
3 Bounding Arguments
We have talked in great detail about one of the unique properties of integers: divisibility. First, in the Divisi-
bility section we discussed when a number divides another. Then, in the Congruences section, we discussed
when a number does not divide a number (and hence leaves a remainder). Now, it’s time to use the other
major property of integers: they are discrete.
The discreteness of integers essentially means that there is a gap between each consecutive integer.
Discrete Inequality. If m and n are both integers and m > n, then m ≥ n + 1.
It’s such a simple fact, and yet it gives us powerful tools as well. The following subsections expand on this,
even if the connection to discreteness is not evident (see if you can work it out!)
3.1 Factorisation
Before, we start on any techniques associated to bounding here is a key fact about positive integers:
Theorem 3.1. If a and b are positive integers, and a|b, then a ≤ b.
This immediately suggests trying to factorise complicated expressions wherever possible. Very often, one
will have an expression with variables on one side and integers on the other, so it gives one an idea of what
the variable factors are likely to be. We begin with a very important problem, since many problems reduce
to something similar.
Problem 8. Solve in integers a, b, the equation
1 1 1
+ = .
a b 2
Proof. Multiplying the whole equation by 2ab yields 2b + 2a = ab, which rearranges to
ab − 2a − 2b = 0.
This is the important form I was referring to. Factorising this is easy, if you add an integer to make it work.
Specifically, if we rewrite this as
ab − 2a − 2b + 4 = 4
the left hand side is simply ( a − 2)(b − 2), so we have that a − 2 and b − 2 are factors of 4, which we can
easily see are −4, −2, −1, 1, 2, 4. This gives the solutions ( a, b) = (−2, 1),
(0,), (1, −2), (3, 6), (4, 4), (6, 3),
0
where we remove the (0, 0) because it wouldn’t allow the fractions of the problem.
13
Problem 9. Solve in integers a, b, the equation
1 1 1
+ = .
a b 2
Proof. Since the problem is symmetric in a, b, WLOG a ≤ b.
If a is negative, then let a = − A, where A is a positive integer. Then
1 1 1
= +
b 2 A
which implies 1b > 12 . So, b is both positive and b < 2. So, clearly b = 1 and substituting back gives a = −2.
Since a cannot be zero, we are left with a, b both positive. Also, since a ≤ b we have 1a ≥ 1b and it follows that
1 1 1 2
= + ≤ .
2 a b a
Multiplying by 2a gives a ≤ 4. We have a great bound. So, we now substitute in a = 1, 2, 3, 4. We find that
the only solutions are a = 3, b = 6 and a = 4, b = 4.
Removing the WLOG and combining the negative and positive case gives us the same solutions: ( a, b) =
(−2, 1), (1, −2), (3, 6), (4, 4), (6, 3).
Of course there are others but these are the most likely to equal the expression from the problem.
Proof. We need to be systematic. First, suppose n = 0, then n(n + 3) = 0 which is a square.
Second, suppose n is a positive integer. Then n ≥ 1, so
so, if n(n + 3) 6= (n + 1)2 , then it is strictly between two consecutive squares and therefore not a square. This
would contradict what we want and so, n(n + 3) = (n + 1)2 . Expanding and simplifying gives n = 1.
Lastly, suppose n is negative. With the negative value, it’s a bit harder to pin down where the square will
lie. But, notice that if −3 < n ≤ −1, then n(n + 3) is actually negative (and hence not a square), since the
bracketed term is positive while n is negative. So, we are clearly working with n ≤ −3. It’s easier to work
with positive integers, so let n = − N and so, N ≥ 3 and we are trying to make − N (− N + 3) = N 2 − 3N a
square. Since, N ≥ 3, notice that N 2 − 6N + 9 ≤ N 2 − 3N. Also, N 2 − 3N < N 2 − 2N + 1, so together we
have
( N − 3)2 = N 2 − 6N + 9 ≤ N 2 − 3N < N 2 − 2N + 1 = ( N − 1)2 .
So, N 2 − 3N = ( N − 3)2 or N 2 − 3N = ( N − 2)2 . Expanding both possibilities and simplifying yields N = 3
and N = 4 respectively.
Thus, all the solutions for n in the problem are n = −4, −3, 0 and 1.
14
3.4 Polynomial Division
In the first handout on divisibility, we talked about divisibility of integers. The same idea works for poly-
nomials, which are evaluated at integer values. The idea is to have a higher degree polynomial dividing a
smaller degree polynomial. This is unlikely to be true for many integers, so the idea is to work out after what
number the higher degree expression becomes too big to divide the other expression. Then just try all the
remaining values.
Problem 11. Find all positive integers a, b such that a|b + 1 and b| a + 1.
Polynomial division is really going to help us out here. In each of the division statements in the problem, we
have a degree 1 term dividing a degree 1 term, but there is no easy simplification, since we don’t know any
relation between a and b. The 1s are really going to help us out. The trick is multiplying the two expressions
together.
Proof. Multiplying the two division statements together yields ab| ab + a + b + 1. Since ab| ab, this gives us
ab| a + b + 1.
Your intuition should immediately tell you that the left hand side looks to big. Since the statement is com-
pletely symmetric in a and b, WLOG a ≤ b and we get
ab ≤ a + b + 1 ≤ 2b + 1 ≤ 3b.
So a ≤ 3. Try a = 1. From the statements in the problem, we get b|2, so b = 1 or b = 2 and both work!.
Try a = 2. From the statements in the problem, we get 2|b + 1 and b|3. So, from the second of these we get
b = 3 (since b ≥ a) and this satisfies the first, so it’s a valid solution.
Try a = 3. We get 3|b + 1 and b|4. Since b ≥ a, b = 4, but this does not satisfy a|b + 1, so there is no solution
here.
So, all the solutions are ( a, b) = (1, 1), (1, 2), (2, 1), (2, 3), (3, 2) (after we remove the WLOG).
(1 + x )r > 1 + rx.
15
Remark. This is also called Bernoulli’s Inequality. It’s very useful when you want to explain that higher
degree powers grow way faster than linear functions.
Remark. Clearly, this inequality is actually an equality for r = 0, 1. Also, note if r is even, then it’s true for all
reals x. The inequality also generalises to all real numbers r > 1 and interestingly is reversed for r ∈ (0, 1).
For an example of this being used, see the next example problem in the Greatest Common Divisor subsection
below.
Proof. First, WLOG m ≥ n. Next, call d = gcd(m, n). Then let m = ad and n = bd, and hence, it follows that
( a, b) = 1 and a ≥ b. Substituting yields ( ad)n = (bd)m . Since m ≥ n, it follows that
an = bm dm−n .
The key here is that, therefore, bm | an , so any prime that divides b must also divide a, but ( a, b) = 1, so there
are no primes that divide b. So, b = 1. [Note, this actually means n|m, since n = d.]
We now, have
an = n an−n .
n
Since n an−n = n a−1 , both sides are powers of n, so we take the nth root of both sides. Thus,
a = n a −1 .
It is really intuitive that the right hand side is almost always way bigger than the left hand side. We shall use
Bernoulli’s inequality to reduce the amount of cases we need to check significantly.
• a = 1. Then 1 = n0 , which works. This corresponds to the obvious solution m = n.
It is now sufficient to show that when a ≥ 3 and n ≥ 2, we have 2 − a − n + an ≥ a. This is true since
subtracting a from both sides and factorising yields ( a − 1)(n − 2) ≥ 0 which is obviously true from
the fact that a ≥ 3 and n ≥ 2. So, n a−1 > a and there are no solutions in this case.
So, all the solutions are (m, n) = (2, 4), (4, 2), (k, k ) for all k ∈ N.
16
Problems
3.7 Easy
1. Find all integers m, n such that mn + 4 = m + n.
2. Find all integers m, n such that mn + a = bm + cn for fixed integers a, b, c. [Hint: try to factorise the
three higher degree terms.]
3. Prove that for all non-negative integers 2n ≥ n2 .
4. Find all positive integers m such that m3 > m!
5. Find all integers a, b such that
1 2 3
+ = .
a b 5
6. Find all integers m, n such that m2 + 4n and n2 + 4m are both squares.
7. Find all integers m, n such that 1 + m + m2 + m3 = 2n .
8. Show that in every primitive Pythagorean triple (all three numbers don’t have common factor), exactly
one of the numbers is even, exactly one of the numbers is divisible by 3 and exactly one of the numbers
is divisible by 5.
9. Find all positive integers x such that x2 + 2 is divisible by 2x + 3.
10. Find all k such that k2 + k + 1|k3 + 2k + 2.
11. Solve in primes: p(q − r ) = q + r.
3.8 Hard
1. If a, b, c are all positive integers, is it possible for a2 + b + c, b2 + c + a and c2 + a + b to all be perfect
squares?
2. Suppose a, b, c are distinct positive integers greater than 1. Solve
17
4 Number Theory Theorems
In the previous three number theory handouts, you will have learnt a rather expansive amount about divis-
ibility, remainders (modulo) and about bounding techniques. Of course, there are many other less common
techniques that you will need to learn the hard way: by finding them yourself by solving problems.
The problems at the end of this set of notes are general number theory problems for you to practice what
you have learnt so far.
In this hand out, I provide some very key results in elementary number theory that it would be prudent to
know.
18
Lemma 4.3. If there is at least one solution to the Pell’s equation x2 − ay2 = 1 and to the generalised Pell’s equation
x2 − ay2 = b for fixed a and b, then by the well-ordering principle, a fundamental solution exists for both. Call them
( x1 , y1 ) and ( x10 , y10 ) respectively. Then all the other positive integer solutions are given by
√ √ √
xn + ayn = ( x1 + ay1 )n−1 ( x10 + ay10 ).
Remark. If a solution does not exist for the generalised Pell’s equation, try using a quadratic residue argument
to prove it.
x 2 + y2 = z2 .
This is in fact, very famous on its own as the case n = 2 of Fermat’s Last Theorem, which turns out to only
have solutions in this particular case. Look this up!
Definition. A triple of non-zero integers ( x, y, z) satisfying the equation x2 + y2 = z2 is called a Pythagorean
triple. Moreover, it is called a primitive Pythagorean triple if there is no prime that simultaneously divides x, y
and z.
Turns out that Pythagoras’ theorem has been solved in integers. In fact, you will solve it in the problems
attached.
Theorem 4.4. All primitive integer solutions to x2 + y2 = z2 are given by
Be careful, the Legendre symbol looks just like a fraction. Unless something is specified to be the Legendre
symbol, it is just a fraction. Then the following is the classical statement of quadratic reciprocity:
Quadratic Reciprocity Theorem. For odd primes, p, q we have
p q p −1 q −1
= (−1) 2 × 2 .
q p
Moreover,
−1 p2 −1
p −1 2
= (−1) 2 = (−1) 8
p p
where all the lefthand sides are Legendre symbols.
We shall not prove this, but there are more than 200 proofs in existence, so I would strongly suggest having
a look at the literature out there.
19
4.4 Primes as sums of squares
A very interesting fact that is a very specific corollary of the quadratic reciprocity is the following amazing
theorem:
Theorem 4.5. A prime p can be written as the sum of two squares iff p = 2 or p ≡ 1 (mod 4).
20
Problems
4.5 Medium (not easy)
1. (Pell’s Equation) Consider a Pell’s equation x2 − ay2 = 1 for fixed a. Suppose there exists a solution in
positive integers x, y.
• By using the well-ordering principle, explain why there is a fundamental solution ( x1 , y1 ).
• Prove that the fundamental solution ( x1 , y1 ) is unique.
√ √ 2 √ √ 2
• Show that if x2 + ay2 = x1 + ay1 , then x2 − ay2 = x1 − ay1 . [Hint: expand both
equations]
√ √ n √ √ n
• Use the same working to show that if xn + ayn = x1 + ay1 , then xn − ayn = x1 − ay1 .
• Hence, show that xn2 − ay2n = 1. [Hint: difference of squares]
• Hence, explain why ( xn , yn ) are all solutions to x2 − ay2 = 1.
Remark. These are actually all the solutions because of the Dirichlet unit theorem (super hard!).
• Show that an alternate way of writing down xn and yn is
xn = xn−1 x1 + ayn−1 y1 , y n = y n −1 x 1 + x n −1 y 1 .
√ n √ n −1 √
[Hint: use x1 + ay1 = x1 + ay1 x1 + ay1 .]
• Find all the positive integer solutions to x2 − 2y2 = 1.
• Find all the integer solutions to x2 − 2y2 = 1.
2. (Pythagorean Triples) We will find all solutions to x2 + y2 = z2 in positive integers x, y, z.
• Prove that if a Pythagorean triple is not primitive, then dividing by the common factor of x, y and
z gives a primitive Pythagorean triple.
Remark. So, it is sufficient to find all primitive Pythagorean triples.
• Show that if ( x, y, z) is a primitive Pythagorean triple, then
x 2 y 2
+ =1
z z
and the fractions are in simplest form.
Remark. So, finding a solution of X 2 + Y 2 = 1 for rational X, Y (simplified) will give us a Pythagorean
triple.
• Draw a unit circle in the X-Y plane. What is the equation of this circle?
• Draw a straight line from (−1, 0) with slope t. What is the equation of this line?
• We now put 0 < t < 1. Where is the line going to intersect the circle other than at (−1, 0)?
• To find the intersection point of the line with the circle, substitute the equation of the line into the
equation of the circle.
• Solve the quadratic for X. [One solution should be −1 as we know (−1, 0) is an intersection point
of the line and circle. The other solution should simplify nicely and be in terms of t]
• Use that to find the corresponding solution for Y.
• We want X and Y to be rational. Show that X and Y are rational iff t is rational.
2 b2
• Setting t = ba with a, b ∈ N and ( a, b) = 1, show that X = aa2 −+ b2
and Y = a22ab
+ b2
and hence,
( x, y, z) = ( a2 − b2 , 2ab, a2 + b2 ).
3. Heron’s formula says that the area of a triangle with side lengths a, b, c is
q
Area = s(s − a)(s − b)(s − c)
where s = 12 ( a + b + c). Find all triangles that have consecutive integer sidelengths and whose area is
an integer. [Hint: you should get a Pell’s equation.]
21
4.6 Hard
1. (Primes as sums of squares) Let p be a prime. We will show that p = x2 + y2 where x, y ∈ N iff p = 2
or p ≡ 1 (mod 4).
• Suppose p = 2, find integers x and y such that p = x2 + y2 .
• Show that if p ≡ 3 (mod 4), it can never be expressed as the sum of two perfect squares.
• Suppose p ≡ 1 (mod 4). Show that there exists an integer in the set {1, 2, . . . , p − 2, p − 1} whose
square is one less than a multiple of p. [Try to do this without using quadratic reciprocity.]
• Hence, show that for every number from the set {1, 2, . . . , p − 2, p − 1}, there is a different number
in the same set, such that the sum of their squares is a multiple of p.
• Show that at least one of these sums of squares is actually equal to p.
2. Find all positive integers a, b, m, n such that am bn = ( a + b)2 + 1.
3. Let p > 2 be prime and n, x be positive integers. Suppose x − 1 has exactly a factors of p in its prime
factorisation, and n has exactly b factors of p where a ≥ 1 and b ≥ 0. Prove that x n − 1 has exactly a + b
factors of p in it.
4. Find all positive integers k that can be written as
x+1 y+1
k= +
y x
22