Divisibility and Congruence
Divisibility and Congruence
Divisibility and Congruence
Mike Clapper
28th/29th March 2021
Divisibility
Some simple things to remember when tackling questions involving divisibility:
a If a is a digit, then 0 ≤ a ≤ 9.
b If a, b and n are integers, and ab|n, then a|n and b|n. More explicitly, the prime factors
of a can only be chosen from amongst the prime factors of n.
c If a and b are integers and a|b then a|b ± a (Follows from Euclidean algorithm).
d Odd ± odd = even, odd ± even = odd (parity).
e If x, y are coprime integers, then there are infinitely many integer solutions of ax + by = 1
(Bezout’s identity).
f If n is an integer, n and n2 + 1 are coprime.
g The product of 3 consecutive integers divides by 6.
Exercises
1. Jimmy wants to buy some toy cars. There are two types which cost $5 and $8 but he
has to spend every dollar he has been given, which is $111. What is the largest number
of cars he can buy?
2. How many 3-digit numbers are 13 times the sum of their digits?
3. A 3-digit number is added to its reversal and the resulting sum is divisible by 30. How
many such 3-digit numbers are there?
4. Find all positive integers n such that n + 2|5n + 22.
5. You can buy dog food in 700g or 1200g cans. If a serve of dog food is exactly 100g, what
is the largest number of serves you cannot buy as a whole number of cans.
n2 + 4n + 11
6. Find all integers n such that is an integer.
n+3
7. x and y are integers that satisfy both xy = 2048 and xy − xy = 7.875. Find x.
8. A rectangular box has a square base and no top. Its surface area is 429 cm2 and its
dimensions are all whole numbers. Find the dimensions of the box with the largest
volume.
Diophantine Equations
A Diophantine equation is an equation for which we are looking for integer solutions. The
name comes from the 3rd century Greek mathematician Diophantus, sometimes referred to
as ‘the father of algebra’. Much of number theory has been about developing techniques
for solving such equations or for showing that no solutions exist. Perhaps the most famous
Diophantine equation is
xn + y n = z n
Pierre Fermat conjectured in 1637 that this equation had no solutions in integers for n ≥ 2
but this was not proved until 1994 by Andrew Wiles.
Exercises
9. Find all integers m and n such that mn + 2n − m = 12.
10. Which scores in AFL have the property that: Goals times behinds equals score.
11. Let a1 + 1b = 20
1
where a and b are positive integers. Find the largest value of a + b.
12. A high school marching band can be arranged in a rectangular formation with exactly
3 boys in each row and exactly 5 girls in each column. What possible sizes could the
marching band be?
Congruences
We say that a ≡ b (mod m) if a and b have the same remainder on division by m. In
words, this is expressed as a is congruent to b modulo m. Note that we use the equivalence
sign rather than the normal equals sign when expressing congruence relationships. Modulo
arithmetic is a fundamental tool in number theory. To see why it is so useful, you must first
convince yourself of the truth of the following, where a, b, c and d are integers and m and n
are positive integers greater than 1:
What this means is that we can use these rules to simplify problems involving addition,
subtraction and multiplication of integers. Note that division is a little more complicated.
Exercises
13. What is the final digit of 3103 ?
14. Show that 32n+1 + 52n+1 is divisible by 8 for all n ≥ 0.
15. Prove that an integer is divisible by 11 if and only if the alternating sum of its digits is
divisible by 11. (By alternating sum, we mean the sum of the evenly placed digits minus
the sum of the oddly placed digits - eg the alternating sum of 12345 = 1+3+5−2−4 = 3)
16. Prove that, for any positive integer n, 43n − 23n divides by 7.
17. Find the remainder when 10001000 is divided by 7.
Least residues
If we are working in a particular modulo system (say mod m), the numbers 0, 1, 2, . . . ,
m − 1 provide a system of possible remainders (mod m) such that any number is equivalent
to exactly one of them. This set of numbers is known as the least residues modulo m. It is
interesting and rewarding to look at the powers of each number in a least residue system.
For example, working modulo 7:
21 ≡ 2, 22 ≡ 4, 23 ≡ 1
31 ≡ 3, 32 ≡ 2, 33 ≡ 6, 34 ≡ 4, 35 ≡ 5, 36 ≡ 1
41 ≡ 4, 42 ≡ 2, 43 ≡ 1
51 ≡ 5, 52 ≡ 4, 53 ≡ 6, 54 ≡ 2, 55 ≡ 3, 56 ≡ 1
61 ≡ 6, 62 ≡ 1
Try doing the same for the least residue systems modulo 5 and modulo 11. You should
notice some interesting patterns which are very helpful. If we work in a modulo system for
a prime p, every number coprime to p eventually gives a power equal to 1. Furthermore, if
the prime is p, the longest it can take to get there is p − 1. For instance, modulo 7, we note
that both 36 and 56 are equal to 1. In fact the powers of 3 (and the powers of 5) generate
all the possible least residues modulo 7.
Things are a little more complicated when we are not working with a prime divisor. For
instance, modulo 10:
21 ≡ 2, 22 ≡ 4, 23 ≡ 8, 24 ≡ 6, 25 ≡ 2, . . .
31 ≡ 3, 32 ≡ 9, 33 ≡ 7, 34 ≡ 1
41 ≡ 4, 42 ≡ 6, 43 ≡ 4, . . .
51 ≡ 5, 52 ≡ 5, . . .
61 ≡ 6, 62 ≡ 6, . . .
71 ≡ 7, 72 ≡ 9, 73 ≡ 3, 74 ≡ 1
81 ≡ 8, 82 ≡ 4, 83 ≡ 2, 84 ≡ 6, 85 ≡ 8, . . .
91 ≡ 9, 92 ≡ 1
Now only 1, 3, 7 and 9 have powers equal to 1. These are the residues which are coprime to
10. You can check that similar things occur in other composite modulo systems.
Fermat’s little theorem
This leads us to a very important theorem in number theory, known as Fermat’s little
theorem, which states:
If p is a prime and (a, p) = 1 then
ap−1 ≡ 1 (mod p)
Euler–Fermat theorem
Now, we can introduce the generalisation of Fermat’s little theorem, known as the Euler–
Fermat theorem, which states:
If a is any integer coprime to m, then
Exercises
20. Find the last 2 digits of 3123 .
21. Find the last three digits of 217802 .
Residues of powers
It can often be useful to look at the residues of various powers (mod n). If the number of
residues is small, we can gain an insight into whether or not sums or differences of powers
can have a certain form.
Exercises
22. If n is an integer, what values can n2 take:
a mod 3
b mod 4
c mod 5
23. Find all solutions in positive integers to the equation n! + 10 = m2 .
24. Prove that it is not possible to write 407 as the sum of three squares.
25. a Show that all cubes of integers are either 0, 1 or -1 (mod 7).
b Conclude that there are no integer solutions to the equation
a3 + b3 = 7n + 3
.
26. If a right-angled triangle has integer sides, a, b and c, show that 60|abc.
Assorted Number Theory - Junior
Mike Clapper
7th/8th December 2020
1. Show that if a and b are relatively prime, then a + b and ab are also relatively prime.
2. Prove that an integer is divisible by 3 if and only if the sum of its digits is divisible by 3.
3. Do there exist twin primes p and q such that pq + 100 is also prime?
4. Show that any number which can be expressed in the form n5 − n3 , where n is an integer,
divides by 24.
5. Show that if n is a cube, then (n − 1)n(n + 1) is divisible by 504.
6. A number n consists of 7 different digits and is divisible by each of them.
a Which digits cannot be in n?
b Does such a number exist?
7. Show that for all integers n, n3 − 9n + 27 is not a multiple of 81.
8. Prove that, for any positive integer n, 32n+1 + 2n+2 divides by 7.
9. Show that the equation a2 + b2 − 8n = 15 has no solutions in integers.
10. The well-known Fibonacci sequence is defined by