Uploaded by Иван Чистов

(XYZ) Titu Andreescu, Gabriel Dospinescu, Oleg Mushkarov - Number Theory Concepts and Problems-XYZ Press (2017)

advertisement
NUMBER THEORY:
CONCEPTS AND PROBLEMS
NUMBER THEORY:
CONCEPTS AND PROBLEMS
Titu Andreescu
Gabriel Dospinescu
Oleg Mushkarov
Library of Congress Control Number: 2017940046
ISBN-10: 0-9885622-0—0
ISBN-13: 978-0-9885622—0—2
© 2017 XYZ Press, LLC
All rights reserved. This work may not be translated or copied in whole or in
part without the written permission of the publisher (XYZ Press, LLC, 3425
Neiman Rd., Plano, TX 75025, USA) and the authors except for brief excerpts
in connection with reviews or scholarly analysis. Use in connection with any
form of information storage and retrieval, electronic adaptation, computer
software, or by similar or dissimilar methodology now known or hereafter
developed is forbidden. The use in this publication of tradenames, trademarks,
service marks and similar terms, even if they are not identified as such, is not
to be taken as an expression of opinion as to whether or not they are subject
to proprietary rights.
9 8 7 6 5 4 3 2 1
www.awesomemath.org
Cover design by Iury Ulzutuev
FORWARD
PREDA MIHAILESCU
Exercises are in mathematics like a vitalizer: they strengthen and train the
elasticity of the mind, teach a variety of successful methods for approaching
specific problems, and enrich the professional culture with interesting questions
and results. For a good treatment of a theory, examples and exercises are the
art of presenting concrete applications, reflecting the strength and potential
of the theoretical results. A strong theory explained only by simple exercise
often may reduce the motivation of the reader.
At the other end, there is a wide reserve of problems and exercises of
elementary looking nature, but requiring vivid mind and familiarity with a
good bag of tricks, problems of styles which were much developed by the interest that mathematical competition attracted worldwide in the last 50 years.
These problems can only loosely be ordered into applications of individual
theories of mathematics, their flavor and interest relaying in the way they
combine different areas of knowledge with astute techniques of solving. Often,
not always, the problems addressed have some deeper interest of their own
and can very well be encountered as intermediate steps in the development of
mathematical theories. From this perspective, a good culture of problems can
be to a mathematician as helpful, as the familiarity with classical situations
in chess matches, to a professional chess player: they develop the aptitude to
recognize, formulate and solve individual problems that may play a crucial
role in theories and proofs of deeper significance.
The book at hand is a powerful collection of competition problems with
number theoretical flavor. They are generally grouped according to common
aspects, related to topics like Diaisibility, GOD and LCM, decomposition of
polynomials, Congruences and p-adz'c valuations, etc. And these aspects can
be found in the problems discussed in the respective chapter — beware though
to expect much connection to the typical questions one would find in an introductory textbook to number theory, at the chapters with the same name.
The problems here are innovative findings and questions, and the connection
is more often given by the methods used for the solution, than by the very
nature of the problem.
ii
Forward
Some problems have a simple combinatorial charm of their own, without
requiring much more than good observation — for instance (p. 512, N 25),
Find all m, n,p e Q>o such that all of the numbers m + i, n + i, p + Fl;
are integers. Others appear even weird at a first glance, like (p. 656, N 8):
For coprime positive integers p, q, prove that:
-1
E(_1)lk/pJ+Lk/q1=
19:0
.
.
0 If m ls even ,
1 if pq is odd
’
or (N 36, p. 543), requiring to show that infinitely many primes are coprime
to the terms of the polynomially recursive sequence given by a1 = 1 and
an.” = (a3, + 1)2 — a%. When one then does the homework, one notices that
several useful and non trivial notions about floors are required for solving the
problem.
The book also contains some basic propositions, which are in big part
classical theorems, but also more specialized results, that can be applied for
solving further problems. Thus, beyond the spontaneous charm of some of the
exercises, most problems are involved and require a good combination of solid
understanding of the theoretical basics, with a good experience in problem
solving.
Working through the book one learns a lot. Do you want to know more
on how large the difference between the product of k consecutive integers and
their LCM can become? A series of results will provide an answer — and you
will then certainly find also a set of variations of this theme. For primes p,
the Fermat quotient ¢(2) = ”+34 mod p has a well known development in
terms of harmonic sums. But if you want to know higher terms in its p-adic
development, you can find them in the chapter on p-adic values. Together with
a series of less known, classical congruences of higher order of Wolfenstone,
Morley, Ljunggren et. al., this leads to a series of interesting questions and
problems.
Not all problems are atomic training subjects; at the contrary, by a good
choice of the problems, the authors may group elementary results that lead to
remarkable understanding of some flmdamental number theoretical functions,
like 71', a, 7', ¢ — the prime distribution flmction, the number of divisors and their
sum, and the Euler totient, respectively. Here also, if you want for instance to
Forward
iii
understand how it happens that the fibers of the inverse ¢_1(X) of the Euler
totient may become indefinitely large, several exercises lead to the understanding of this phenomenon. It will not surprise that among the authors or solvers
of the problems presented, one encounters numerous famous mathematicians,
from classical to contemporaneous, ranging from Gauss, Lagrange, Euler and
Legendre, through V. Lebesgue, Lucas, but also Hurwitz and, unsurprisingly,
Erdc’is and Schinzel: the borders between research mathematics and advanced
problem solving are fluid.
This very short and selective overview of the book should have already
suggested that the book can be read with various attitudes and expectations,
and there is always much to profit from it. The reader may traverse entire
chapters of the book and get familiar with the specifics of the posed problems,
but should definitely invest the time for trying to solve at least two or three
problems alone, each time when working again with this book. In spite of the
well structured construction of the book, one can easily jump to chapters or
sections of interest — they are to a large extent self-consistent. And if not, good
references help to find the necessary facts which were discussed at previous
places of the book.
Altogether — while students eager to acquire experience helping to reach
outstanding performance in mathematical competitions will profit most from
this book, it is certainly a good companion both for professional mathematicians and for any adult with an active interest in mathematics Each one of
them will find it a leisure to read and work over and over again through the
problems of this book.
Preda Mihailescu
Gottingen, May 2017
Mathematisches Institut der Universitat Gottingen
E—mail: preda©uni—math.gwdg.de
Contents
Forward ..................................
i
1
Introduction
1
2
Divisibility
2.1 Basic properties ...........................
2.1.1 Divisibility and congruences ................
2.1.2 Divisibility and order relation ...............
2.2 Induction and binomial coefficients ................
2.2.1 Proving divisibility by induction .............
2.2.2 Arithmetic of binomial coefficients ............
2.2.3 Derivatives and finite differences .............
2.2.4 The binomial formula ...................
2.3 Euclidean division .........................
2.3.1 The Euclidean division ...................
2.3.2 Combinatorial arguments and complete residue systems
2.4 Problems for practice ........................
3
3
3
10
22
22
26
34
38
43
43
47
56
3
GOD and LCM
3.1 Bézout’s theorem and Gauss’ lemma ...............
3.1.1 Bézout’s theorem and the Euclidean algorithm .....
3.1.2 Relatively prime numbers .................
3.1.3 Inverse modulo n and Gauss’ lemma ...........
3.2 Applications to diophantine equations and approximations . . .
3.2.1 Linear diophantine equations ...............
63
63
63
68
72
80
80
vi
Contents
3.3
3.4
4
3.2.2 Pythagorean triples .................... 83
3.2.3 The rational root theorem ................. 92
3.2.4 Farey fractions and Pell’s equation ............ 96
Least common multiple ...................... 113
Problems for practice ........................ 121
The fundamental theorem of arithmetic
Composite numbers
4.2
The fundamental theorem of arithmetic ............. 134
4.2.1 The theorem and its first consequences .......... 134
4.2.2
4.2.3
4.3
5
129
4.1
........................ 129
The smallest and largest prime divisor .......... 144
Combinatorial number theory ............... 149
Infinitude of primes .........................
4.3.1 Looking for primes in classical sequences .........
4.3.2 Euclid’s argument .....................
4.3.3 Euler’s and Bonse’s inequalities ..............
154
155
160
171
4.4
Arithmetic functions ........................ 178
4.5
4.4.1 Classical arithmetic functions ...............
4.4.2 Multiplicative functions ..................
4.4.3 Euler’s phi function ....................
4.4.4 The Mobius function and its applications ........
4.4.5 Application to squarefree numbers ............
Problems for practice ........................
178
184
194
206
210
216
Congruences involving prime numbers
225
5.1 Fermat’s little theorem ....................... 225
5.2
5.3
5.1.1
Fermat’s little theorem and (pseudo-)primality ..... 225
5.1.2
Some concrete examples .................. 230
5.1.3
Application to primes of the form 4k + 3 and 3k + 2 . . 238
Wilson’s theorem ..........................
5.2.1 Wilson’s theorem as criterion of primality ........
5.2.2 Application to sums of two squares ............
Lagrange’s theorem and applications ...............
5.3.1 The number of solutions of polynomial congruences . . .
5.3.2
The congruence a:”’5
(mod p)
244
244
252
259
259
............. 266
Contents
5.4
5.3.3 The Chevalley—Warm'ng theorem ............. 272
Quadratic residues and quadratic reciprocity .......... 278
5.4.1
5.5
vii
Quadratic residues and Legendre’s symbol ........ 278
5.4.2 Points on spheres mod p and Gauss sums ........ 286
5.4.3 The quadratic reciprocity law ............... 297
Congruences involving rational numbers and
binomial coefficients ........................ 304
5.6
5.5.1
Binomial coefficients modulo primes: Lucas’ theorem . . 304
5.5.2
Congruences involving rational numbers ......... 310
5.5.3 Higher congruences: Fleck, Morley, Wolstenholme,... . . 316
5.5.4 Hensel’s lemma ....................... 324
Problems for practice ........................ 330
6 p-adic valuations and the distribution of primes
6.1 The yoga of p-adic valuations ...................
6.1.1 The local-global principle .................
6.1.2 The strong triangle inequality ...............
6.1.3 Lifting the exponent lemma ................
6.2 Legendre’s formula .........................
6.2.1 The p-adic valuation of n!: the exact formula ......
6.2.2 The p-adic valuation of n!: inequalities ..........
6.2.3 Kummer’s theorem .....................
6.3 Estimates for binomial coefficients and
the distribution of prime numbers .................
6.3.1 Central binomial coefficients and Erdfis’ inequality . . .
6.3.2
6.4
7
Estimating 7r(n)
373
373
...................... 376
6.3.3 Bertrand’s postulate .................... 380
Problems for practice ........................ 386
Congruences for composite moduli
7.1 The Chinese remainder theorem ..................
7.1.1 Proof of the theorem and first examples .........
7.1.2 The local-global principle .................
7.1.3 Covering systems of congruences .............
7.2
341
341
341
347
353
360
360
363
369
393
393
393
400
408
Euler’s theorem ........................... 417
viii
Contents
7.3
7.2.1
7.2.2
Order
7.3.1
7.3.2
7.4
8
Reduced residue systems and Euler’s theorem ......
Practicing Euler’s theorem ................
modulo n ...........................
Elementary properties and examples ...........
417
421
427
427
Practicing the notion of order modulo n ......... 440
7.3.3 Primitive roots modulo 'n, ................. 448
Problems for practice ........................ 460
Solutions to practice problems
467
8.1
8.2
8.3
Divisibility ............................. 467
GOD and LCM ........................... 496
The fundamental theorem of arithmetic ............. 523
8.4
8.5
Congruences involving prime numbers .............. 568
p-adic valuations and the distribution of primes ......... 620
8.6
Congruences for composite moduli ................ 652
Bibliography
683
Other Books from XYZ Press
685
Chapter 1
Introduction
Based on lectures given by the authors at the AwesomeMath Summer
Program over several years, this book is a slightly non-standard introduction to
elementary number theory. Nevertheless, it still develops theoretical concepts
from scratch with full proofs. The book insists on exemplifying these results
through interesting and rather challenging problems. In particular, the reader
will not find many advanced concepts in this book, but will encounter quite a
lot of intriguing results that can be proven using “basic” number theory yet
nonetheless test one’s problem-solving aptitude.
The book is divided into six large chapters, each focusing on a fundamental
concept or result. Each chapter is itself divided into sections that reinforce
a specific topic through a large series of examples arranged (subjectively) in
increasing order of difficulty. In particular, the first two chapters are largely
elementary but fundamental for appreciating the rest of the book. The topics
explored in these two chapters are classical: divisibility, congruences, Euclidean division, greatest common divisor, and least common multiple. With
the theoretical concepts being fairly elementary, the focus is more on concrete
problems and interesting applications, for instance, Diophantine equations, fi—
nite differences, and problems with a combinatorial flavor. The third chapter
is devoted to the fundamental theorem of arithmetic and its numerous applications. After proving basic properties of prime numbers and the uniqueness of
prime factorization, the authors emphasize their utility and vast scope among
2
Chapter 1. Introduction
arithmetic functions. There are many non-standard and sometimes surprising
results in this chapter.
The fourth and fifth chapters, devoted to congruences involving prime numbers and to the distribution of prime numbers, are in some sense the heart
of the book. Each of the classical congruences (Fermat, Wilson, Lagrange,
and Lucas) is studied in depth in the fourth chapter, along with numerous examples of their use, for instance, quadratic residues, the number of solutions
to polynomial congruences, and congruences involving binomial coefl'lcients or
higher congruences. In the fifth chapter, p—adic valuations are used to study
the distribution of prime numbers. This has the advantage of being fairly elementary, while still producing beautiful and nontrivial results. The key results
of this chapter are Legendre’s theorem and the arithmetic of binomial coeffi—
cients, leading to strong results concerning the distribution of prime numbers.
Finally, the sixth chapter discusses congruences for composite moduli, introducing further essential concepts and results: the Chinese remainder theorem,
Euler’s theorem, and their applications to primitive roots modulo integers.
The main focus is again providing many examples of these concepts’ applica
tions (in particular, the reader will find a whole section devoted to systems of
congruences). Each chapter contains a long list of practice problems, whose
solutions are presented at the end of the book.
Experience has shown that it is easier to make students appreciate the
beauty and power of a result when it is enhanced by pertinent and challenging
examples. We strove to achieve this, a possible explanation for the book’s
length, although the theoretical material is rather classical and standard.
We would like to thank our students at the AwesomeMath Summer Program on whom we tested a large part of this material and who supplied many
of the solutions presented here. We are also indebted to Richard Stong for
a very careful reading of the book, for pointing out many inaccuracies, and
for supplying a great deal of solutions (many of which were simpler and more
elegant than ours!).
Titu Andreescu
Gabriel Dospinescu
Oleg Mushkarov
Chapter 2
Divisibility
This first chapter is fairly elementary and discusses basic properties of
divisibility, congruences and the Euclidean division. These will be constantly
used later on in the book and represent the foundations of arithmetic, on
which we will build more advanced results later on. We tried to insist more on
relatively nonstandard examples or applications, some of which are relatively
nontrivial (such as the topic of finite differences and their applications to
congruences) .
2. 1
Basic properties
In this section we introduce the notion of divisibility and study some of its
basic properties.
2.1.1
Divisibility and congruences
We start by defining the divisibility relation.
Definition 2.1. Let a, b be integers. We say that a divides b and write a | b
if there is an integer c such that b = ac.
There are many equivalent ways of saying that a divides b: we can also say
that b is divisible by a, that a is a divisor of b or that b is a multiple of a. All
4
Chapter 2. Divisibility
these formulations are used in practice. Note that if a aé 0, then saying that a
divides b is equivalent to saying that the rational number % is an integer. The
previous definition takes into account the possibility that a = 0, in which case
a divides b if and only if b = O. In other words, any integer is a divisor of 0,
and 0 is the only multiple of 0.
If 2 divides an integer n, we say that n is even. Otherwise, we say that
n is odd. Thus the even integers are ..., —2, 0,2,4, 6, ..., while the odd ones
are
— 3,—1,1,3,5,
Note that if n is odd, then n — 1 is even, in other
words any integer n is either of the form 2k or 2k + 1 for some integer k. In
particular, we obtain that the product of two consecutive integers is always
even. We deduce for instance that if a is an odd integer, say a = 2k: + 1, then
a2 — 1 =4k(k+1)
is a multiple of 8. In particular any perfect square (i.e. number of the form
$2 with a: an integer) is either a multiple of 4 or of the form 8k + 1 for some
integer k.
The following result summarizes the basic properties of the divisibility
relation.
Proposition 2.2. The divisibility relation has the following properties:
1. (reflexivity) a divides a for all integers a.
2. (transitivity) If a | b and b | c, then a | c.
3. Ifa,b1, ...,bn are integers anda | b,- forl S i S n, thena | b101+...+bncn
for all integers c1, ..., ca.
4. Ifalbandalbic, thenalc.
5. Ifnla—bandnla’—b’, thennlaa’—bb’.
Proof. All of these properties follow straight from the definition. We only
prove properties 3) and 5) here, leaving the others to the reader. For property
3), write b,- = am,- for some integers 50,. Then
b1c1 +
+ bncn = axlcl +
+ axncn = a(a:1c1 +
+ canon)
2.1.
Basic properties
5
is a multiple of a. For property 5), write a — b = km and a’ — b’ = k’n for some
integers k, 16’. Then
aa’ — bb’ = (b + kn)(b' + k’n) — bb’ = n(bk’ + b'k + nkk'),
thus n | aa’ — bb’.
El
We introduce next a key notation and definition, that of congruences:
Definition 2.3. Let a, b,n be integers. We say that a and b are congruent
modulo n and write
aEb
(mod n)
ifn|a—b.
Most parts of the following theorem are simple reinterpretations of proposition 2.2. They are of constant use in practice.
Theorem 2.4. For all integers a, b, c, d,n we have
a) (reflexivity) a E a (mod n).
b) (symmetry) Ifa E b (mod n) then b E a (mod n).
c) (transitivity) If a E b (mod n) and b E c (mod n), then a E 0 (mod n).
d) Ifa E c (mod n) andbEd (mod n), then a+bE c+d (mod n) and
ab E cd (mod n).
e) If a E b (mod n), then ac E be (mod nc).
(mod nc) and c 5A 0, then a E b (mod n).
Conversely, if ac E bc
Proof. a), b), c), d) are either clear or consequences of proposition 2.2. Property e) is immediate and left to the reader.
III
Remark 2.5. We cannot cancel congruences without taking care.
In other
words, it is not true that if ab E ac (mod n), then b E 0 (mod n) or a E 0
(mod n). For instance 2 - 2 E 2-0 (mod 4), but 2 is not congruent to 0 modulo
4. We Will see later on that we can "cancel a' in a congruence ab E ac (mod n)
provided n and a share no common divisor except :l:1.
Let us illustrate the previous theorem with some concrete problems (where
no congruence is mentioned!).
6
Chapter 2. Divisibz'lz'ty
Example 2.6. Find the last digit of 91003 — 7902 + 3801.
Proof. We have 91003 E (—1)1003 E —1 E 9 mod 10. In addition,
7902 E 49451 E (—1)451 E —1
mod 10.
Finally,
3801 E 3 - (34)200 a 3 . 1200 a 3 mod 10.
Hence
91003 — 79°2 + 3801 a (—1) — (—1)+ 3 a 3 mod 10,
so the last digit is 3.
III
Example 2.7. Prove that for any n E N the number an = 11"+2 + 122’"+1 is
divisible by 133.
Proof. We have 122 = 144 E 11 (mod 133), hence
an E 11n+2+12.144n a 11n+2+12-11“ a 11n(121+12) a 0 (mod 133). :1
Example 2.8. (Kvant, M 274) Find the least number of the form:
(i) [11’c - 5‘l,
(ii) l36’“ - 5’l,
(iii) |53k — 37l|,
where k and l are positive integers.
Proof. (i) The last digit of In" — 5l| is either 6 or 4, thus the least number of
the form |11k — 5l| must be at least 4. Since |112 — 53| = 4, we deduce that
the answer is 4.
(ii) We have 11 = |36 — 52| and we will show that this is the least number
of the form |36’“ — 5l|. Suppose that for some k,l we have |36,“ — 5l| g 10.
Since 36" — 5l E 6 — 5 = 1 (mod 10), we deduce that 36" — 5l = 1 or 36" — 5l =
—9. The first equality is impossible since it would imply that 0 — 1 E 1
(mod 4), impossible. The second equality is also impossible since it would
yield 0 — (—1)1 E 0 (mod 3), again impossible. This finishes the proof.
2.1.
Basic properties
7
(iii) Note first that the given numbers are divisible by 4 since 53’“ and
37l are congruent to 1 modulo 4. We will show that the desired number is
16 = I53 — 37]. Note that
53’6 E (—1)’c (mod 9),
37l E 1 (mod 9).
Hence N = |53k — 37l| E 0, :|:2 (mod 9) which shows that N as 4, 8, 12.
III
The following fundamental theorem is of constant use.
Theorem 2.9. a) If a,b are integers, then a — b | ak — b’“ for all k 2 1.
b) More generally, if d, n are positive integers such that d | n, then ad —bd |
a" — b" for all integers a, b. Moreover, if % is odd, then ad + b"l | a“ + b” for
all integers a, b (in particular a + b | a” + b” for all integers a, b if n is odd).
Proof. a) This follows directly from the identity
ak — bk = (a — b)(a,“—1 + ak_2b +
+ abk"2 + bk‘l).
b) Let n = led for some positive integer h. Then setting .1: = ad, y = b‘1 we
are reduced to showing that a: — y | x,“ — 3;" (which follows from part a)) and
:1: + y | x’“ + y’“ when k is odd, which follows from
x+y=x—(-y)Izk-(-y)’°=m’“+y’“.
D
Remark 2.10. 1) We will see later on that under rather weak hypotheses, the
divisibility am — bm | a" — b” implies m | n.
2) The identity
on — b” = (a — b)(a ‘1 + an_2b +
+ abn"2 + bn‘l)
is absolutely fundamental in arithmetic and the reader should become very
familiar with it, since it will be used constantly in this book. Indeed, in many
cases the results of theorem 2.9 are strong enough, but in some circumstances
a finer analysis of the term a '1 + (In—2b +
+ b"“1 is crucial.
The following result is a simple translation of the previous theorem in
terms of congruences:
8
Chapter 2. Divisibility
Corollary 2.11. Let a, b,n be integers, let k be a positive integer and let (1 I k
a positive divisor of k.
a) Ifa E b (mod n), then a,“ E bk (mod n).
b) If ad E bd (mod n), then ak E bk (mod n).
c) If ad E —bd (mod n) and g is odd, then a,“ E —bk (mod n).
Example 2.12. Using that 641 = 27 - 5 + 1, prove that 641 | 232 + 1.
Proof. We have 27 - 5 E —1 (mod 641), thus 228 - 54 E 1 (mod 641). Since
641 = 54 + 24 we have 54 a —24 (mod 641), thus 228 - 54 a —232 (mod 641)
and so —232 E 1 (mod 641), which is exactly what we need.
III
Ewample 2.13. a) Prove that if n is a positive integer, then 9 divides the
difference between n and the sum of its decimal digits.
b) Let n be a positive integer and let 5’1 (respectively 5’2) be the sum of
the digits of n at the odd (respectively even) positions (the last digit of n has
position 0). Prove that n E 52 — 51 (mod 11).
Proof. a) Write
n = m = 049-101“ + ak_110k_1 +
+ cm
for some decimal digits 41],, ...,a0 with ak 76 0. Then
n — (a0 + a1 +
+ ak) = ak(10k — 1) + ak_1(10’“‘1 — 1) +
+ a1(10 — 1)
is a multiple of 9, since each term in the sum is a multiple of 9 thanks to
theorem 2.9.
b) The proof is identical to that of part a), the key point being the con—
gruence 10"; E (—1)" (mod 11) for all i.
E]
Example 2.14. (Kvant M 676) Prove that for every positive integer n the sum
of the digits of 1981" is not less than 19.
Proof. Write S(x) for the sum of the decimal digits of :17. Since 9 | x — S(11:) for
all a: and since 9 | 1981" — 1 (as 9 | 1980), it follows that 9 | 5(1981”) — 1 and
so 5(1981”) is one of the numbers 1,10,19,
Since 1981" ends in 1 (because
2.1.
Basic properties
9
10 | 1981" — 1) it follows that 8(1981") > 1. Suppose that 5(1981”) = 10,
thus 8(1981" — 1) = 9. Denote by 81 (respectively 32) the sum of the digits
of 1981” — 1 at the odd (respectively even) positions. Then 0 S 5'1, 5'2 3 9.
On the other hand 1981” — 1 is divisible by 1980, thus it is divisible by 11.
Hence 8'1 — $2 is divisible by 11 (by the previous example) and we conclude
that 5'1 = 52. But 8'1 + 82 = 9, a contradictionThus 8(1981") Z 19 for all
n.
E]
Example 2.15. Let E; = 22" + 1 be the nth Fermat number. Prove that
Fn|2F" — 2 for all n 2 1.
Proof. It suffices to show that E, | 2E“l — 1. Note that
Fn | (22" — 1x22" + 1) = 22"“ — 1.
If a | b then 2“ — 1 | 2" — 1 by theorem 2.9. It suflices therefore to show that
2"+1 | E, — 1, or equivalently n + 1 S 2”. This is clear.
III
An immediate consequence of the previous theorem is the following very
useful:
Proposition 2.16. If f is a polynomial with integer coefl‘icients, then for all
integers a, b
a — b | f(a) - f(b)Thus, if a E b (mod n) for some integer n, then f (a) E f (b) (mod n).
Proof. Write
f(X) = 60 + c1X +
+ c"
for some integers c0, ..., on and some n 2 0. Then
f(a) — f(b) = 01(a - b) + 02(0,2 - b2) +
+ cn(a" — b")
and each term in the sum is a multiple of n by theorem 2.9.
follows.
The result
E]
Example 2.17. Let f be a polynomial with integer coeflicients and let a be
a positive integer such that f (a) 7E 0. Prove that there are infinitely many
positive integers b such that f (a) | f (b).
10
Chapter 2. Divisibz’lz'ty
Proof. We take b = a + kl f (a)| with k a positive integer. Then
NE) | k|f(a)| = b - a1| f(b)- flu)
and so f(a) | f (b). Since k is arbitrary, the result follows.
2.1.2
III
Divisibility and order relation
Another key property of the divisibility relation that we want to emphasize
in this section is its relationship with the usual order on the set of integers:
the next proposition roughly says that a divisor of a number cannot exceed
that number. One has to be a little bit careful when making such a statement
(note that 1 is a divisor of —2, but it is certainly not less than —2), so we
formalize this as follows:
Proposition 2.18. Ifa divides b and b 75 0, then |a| S |b|.
Proof. Write b = ac, then c 75 0 (since b 75 0), hence |b| = [a] . |c| Z |a|.
III
Remark 2.19. The hypothesis b 9E 0 is crucial in the previous proposition. The
number 0 plays a very special role: it is the only integer having infinitely many
divisors. More precisely, 0 is divisible by all integers, since if a is any integer,
then 0 = a - 0. On the other hand, if n e Z has infinitely many divisors, then
necessarily n = 0: otherwise, by the previous proposition any divisor d of n
satisfies (1 E {—Inl, ...0, 1, ..., Inl}, hence n has only finitely many divisors. The
next example is a nice illustration of this important observation.
Example 2.20. (Russia 1964) Let a, b be integers and let n be a positive integer
such that k — b | k” — a for infinitely many integers k. Prove that a = b”.
Proof. For any integer k we have k—blk"—b”, so ifk—blkn—a, then
k—b|(k"—b")—(k”—a)=a—b".
Using the hypothesis of the problem, we deduce that a— b” has infinitely many
divisors and so a — b” = 0. The result follows.
El
One of the consequences of the previous proposition is the following prop-
erty of the divisibility relation.
2.1.
Basic properties
11
Corollary 2.21. If a,b are integers such. that a | b and b | a, then |a| = |b|,
tie. a = :l:b.
Proof. Everything is clear if a = 0 or b = 0. Otherwise, the previous proposi-
tion gives [al 3 |b| and |b| S |a|, thus |a| = |b|.
III
Example 2.22. Find all integers n such that a — b | a2 + b2 — nab for all distinct
integers a, b.
Proof. The identity a2+b2—nab = (a—b)2+(2—n)ab shows that a—b|(2—n)ab
for all a 75 b E Z Taking b = 1 and a = k + 1, with k a positive integer, we
deduce that k | (2—n)(k+1)=(2—n)k+2—n and so It | 2—n. Hence 2—n
has infinitely many divisors and n = 2. Conversely, n = 2 is a solution of the
problem.
El
Example 2.23. (Putnam 2007) Let f be a nonconstant polynomial with positive
integer coeflicients. Prove that if n is a positive integer, then f (n) divides
f(f(n) + 1) if and only ifn = 1.
Proof. We have f(f(n) + 1) .=_ f(1) (mod f(n)). If n = 1, then this implies
that f(f(n) + 1) is divisible by f(n). Otherwise, O < f(1) < f(n) since f is
nonconstant and has positive coefficients, so f(f (n) + 1) cannot be divisible
by f (77.)
III
Example 2.24. a) Prove that for any positive integer n there are distinct positive integers cc and y such that a: +j divides y + j for j = 1,2,3, . . . ,n.
b) Suppose that so, y are positive integers such that m + j divides y + j for
all positive integers j. Prove that a: = y.
Proof. a) We have cc+j I y+j ifandonly ifx+j | (y+j)—(x+j) =y—x.
Thus it is enough to ensure that y — a: is a multiple of (:1: + 1)(:L' + 2)...(a: + n),
for instance y = so + (:1: + 1)(a;.+ 2)...(a: + n).
b) Arguing as in a), we see that y — ac must be a multiple of a: + j for all
positive integers j. Remark 2.19 yields y = :1: and we are done.
[I
Example 2.25. Let f be a polynomial with integer coeflicients, of degree n > 1.
What is the maximal number of consecutive integers belonging to the sequence
f(1), f(2),f(3), ...?
12
Chapter 2. Divisibility
Proof. For the polynomial f(X) = X + (X — 1)(X —— 2)...(X — n) we have
f(1) = 1, f (2) = 2, ..., f(n) = n, thus we have n consecutive numbers in the
sequence f(1), f(2),
We will prove that we cannot have more. Assume for
contradiction that we can find positive integers a1, ..., an+1 and an integer a:
such that f(a¢-) = at +2’ for 1 S 2' S n+ 1. Then f(a¢+1)— f(az-) = 1 is a
multiple of (Ll-+1 — (15, thus (1,-4.1 — az- equals 1 or —1 for all z'. Since a1, ..., an+1
are clearly pairwise distinct (since so are their images by f), we deduce that we
cannot have sign changes in the sequence a2 — a1, a3 — a2, ..., an+1 — an (indeed,
otherwise there would exist 2' such that cut-+1 — a; is the opposite of a¢+2 — 0.54.1,
which would force ai = 044.2). Thus the sequence (12 — a1, a3 — a2, ..., an+1 — an
must either consist only of 1’s or only of —1’s. We can thus find a sign 6 such
that (Lt-+1 — a.- = e for all 1'. But then ai = a1 + e - (i — 1) for all i, hence
f(a1 — 8 + e - i) = a: +z' for 1 S i S n + 1. We deduce that the polynomial
f(a1 — e + a - X) — a: — X has at least 71. + 1 distinct roots, which is impossible
since it has degree precisely n. This proves that the answer of the problem is
n.
El
Example 2.26. Let f be a polynomial with integer coefficients, of degree n 2 2.
Prove that the equation f (f (50)) = a: has at most n integral solutions.
Proof. Let 22,3; be distinct integers such that f (f (x)) = a: and f (f (y)) = y.
Then :3 — y = f(f(:c)) — f(f(y)) is a multiple of f(a:) — f(y), which in turn
is a multiple of m — y. Thus necessarily |f(a:) — f(y)| = la: — yl. Consider
now integers a1 <
< ad such that f(f(a,i)) = a; for 1 3 z' 3 d. Then
the previous observation yields | f (0.5) — f (aj)| = a,- — a; for i < j. We claim
that the sequence f(0.1), ..., f(0.4) is either increasing or decreasing. Indeed,
we have
lf(a-i+1) - f(a¢) + flat-+2) - f(ai+1)| = |f(ai+2) - flat)!
= ai+2 — a,- = |f(ai+1) — f(ai)l + |f(ai+2) - f(ai+1)|,
therefore f (0,714.1) - f (a,) and f(a,-+2) — f (ai+1) must have the same sign for
all i, proving the claim.
Assume that f ((11), ..., f (an) is increasing (the other case is similar). Then
necessarily f (at-+1) — f ((1.) = Liz-+1 — a,- for all '12, in other words there is some
2.1.
Basic properties
13
number 0 such that f(a.,-) — a, = c for 1 g i S d. Since f(X) — X — c has
degree n, it can have at most 72. distinct roots and so d S n, as desired.
El
Remark 2.27. A more general problem (in which f o f is replaced with f o f o
o f) was proposed at the IMO 2006.
Example 2.28. (Tournament of the Towns 2002) Let (11 < (12 <
be an infinite
increasing sequence of positive integers such that an divides a1 +a2 + + an_1
for n 2 2002. Prove that there is a positive integer no such that
an = a1 +
+ an_1
for all n 2 no.
Proof. By hypothesis, there is a sequence $62002,1L‘2003,
such that for all n 2 2002 we have
a1 + a2 +
of positive integers
+ an_1 = xnan.
Write the previous relation with n + 1 instead of n and subtract the two
resulting relations. We obtain
xn+1an+1 = xnan + an = an(xn + 1)
(1)
We deduce that
xn+1 =
an
(113", + 1) < (En + 1,
“n+1
since an < an“. Consequently, xn+1 S 53,, for n 2 2002. Since there is
no decreasing infinite sequence of positive integers, we deduce that there is
no 2 2002 such that for all n 2 no we have xn+1 = 51:”. Let k: = 931,0, then
55,, = k for n 2 no and relation (1) becomes
kan+1 = (k + 1)a,n
for n 2 no. In particular,
an = k(an+1 — an)
14
Chapter 2. Divisibility
is a multiple of k for n 2 no. Writing an = kbn, we also have bn = k(bn+1 — b")
and so k | bn for all n, that is k2 | an for all n 2 no. An immediate induction
then shows that kj | an for all j 2 1 and all n 2 no. In particular, kj S an0
for all j 2 1, which forces k = 1. But then
a1 +
+an_1 = kan = an
for n _>_ no and we are done.
III
A fundamental property that easily follows from the relationship between
divisibility and order relation as well as basic properties of odd and even
numbers is:
Theorem 2.29. Let n be a nonzero integer. There is a unique pair of integers
(a, b) with a 2 O, b odd and n = 2“ - b.
Proof. Let us start by proving uniqueness. Suppose that 2% = 2°d with
a, c 2 0 and b, d odd, and assume that a 7E c. Without loss of generality, we
may assume that a < c, then b = 20—“d is even, a contradiction. Thus a = c
and then b = d.
In order to prove the existence part, consider the set of powers of 2 which
divide n. This set is finite, since if 2“ divides n, then‘a < 2“ S |n|. Thus there
is a largest integer a such that 2“ | n. Write n = 2% for some integer b. If b
is even, then b = 2c for some integer c and then 2“+1 | n, contradicting the
maximality of a. Thus b is odd and the result is proved.
I]
Remark 2.30. 1) It follows easily from the previous theorem that if a,b are
integers such that ab is a power of 2, i.e. ab = 2” for some n 2 0 then |a| and
lbl (but not necessarily a and b) are also powers of 2.
2) From the uniqueness part of the theorem, it follows that if n = 2m
is even and an odd number d divides n, then d divides m. This is our first
example of a cancellation in congruences and we will use it frequently.
Yet another result that is fairly useful in practice is the following:
Theorem 2.31. If a is an odd integer, then for all n 2 0
2n+2 I a2” _ 1.
2.1.
Basic properties
15
Provf. We have
a2" — 1 = (a— 1)(a+1)(a2+1)(a4+1)...(a
211—1
+1).
Sincea is odd, (a—1)(a+1)=a2—1 iszamultiple of8, anda2 +1, 114 +1..
+1 are each multiples of 2. Hence a.2 — 1 IS a multiple of 23+(" 1)—
— 2"”,
as desired.
Of course, the statement can also be proved by induction on n: for n = 0
it is equivalent to 8 | a2 — 1, which we have already seen. Assuming that
(12" = 1 + k - 2“”, we have
a2n+1= (a2")2= (1+k 2n+2)2_
_ 1+k 2n+3+k222n+4=1+(k+k22n+1)2n+3
and the result follows.
III
We will use the previous two theorems throughout the book. The next
examples are a few illustrations of these results.
Example 2.32. Let n be an integer greater than 1. Prove that n is odd if and
only if n divides 1” + 2” +
+ (n — 1)".
Proof. If n is odd, then kn+ (11—19)” is a multiple of n for 1 S k S n— 1, hence
2(1n+2”+
+ (n— 1)“) is a multiple ofn and then n | 1"+2"+ ...+ (n— 1)".
Suppose that n is even and write n = 2am with a Z 1 and m odd. If k is odd,
then k” = 092“)” E 1 (mod 2“), while if k is even, then k" E 0 (mod 2“). We
deduce that
1” + 2” +
+ (n — 1)” E 2“_1m (mod 2“)
and so 2“ cannot divide 1" + 2” +
+ (n — 1)".
Example 2.33. Prove that if n > 1 then s = 1 + % + é; +
integer.
III
+ % is not an
Proof. Let a be the product of all odd integers less than or equal to n, and
let k be the largest integer such that 2’“ S n. We claim that 2k‘1as is not an
integer. If 1 S m S n With m aé 2", then m can be written in the form 2%
Where 0 S t S k — 1 and 1 g u g n is an odd integer. Hence m | 2k‘1a, so
2k‘1a - i is an integer. Hence 2k'1as = N + ‘5‘ for some integer N. But a is
odd, hence % is not an integer. It follows that s is not an integer.
III
16
Chapter 2. Divisibz'lity
Example 2.34. Is there a polynomial f (x, y) in two variables, with integer
coefficients and having the following properties:
a) The equation f (:13, y) = 0 has no integral solutions.
b) For each positive integer n there are integers 3:, y such that n | f (x, y)?
Proof. We will show that f (52,34) = (2a: — 1)(3y — 1) is such a polynomial. It
is clear that f(w,y) = O has no integral solutions, since it forces a: = % or
y = %. Now let n be a positive integer and write n = 2km with k 2 0 and m
odd. Note that 3 | 22k+1 + 1 = 2 - 4" + 1 (since 3 | 4’“ — 1), thus we can write
22’“+1 = 3y — 1 for some integer y. Setting a: = 153 (an integer, since m is
odd) we obtain
(21: — 1)(3y — 1): m-22k+1,
a multiple of n.
E!
Example 2.35. (Turkey TST 2016) Find all functions f : N —) N such that
for all m,n 2 1 we have f(mn) = f(m)f(n) and m+n | f(m) +f(n).
Proof. Clearly for any odd positive integer k: setting f (x) = x" yields a solution
of the problem. We will prove that these are all solutions. First of all, note
that f(1) = 1 since f(1) = f(l)2 and f(l) is positive. Next, we focus on f(2).
Write f(2) = 2k(2r + 1) for some 19,?“ 2 0. Assume that 7' > 0, then
1 + 2r | f(1)+ f(2r) = 1 + f(2)f(r) = 1 + 2k(2r + 1)f(r),
thus 1 + 21" | 1, impossible. Thus f(2) = 2’“. Since f (mm) = f(m) f (n) for all
m, n, we have f(2") = 2”,“ for all n _>_ 1. Since 6 | f(2) + f(4) = 2" + 4", we
deduce that k is odd. Finally, for any n 2 1 and any d 2 1 we have n + 2‘]l |
f(n) + f(2") = f (n) + 2’“ and, since k is odd, we also have n + 2d | n,“ + 2’”,
thus n + 2d | f (n) — nk. Fixing n and letting d vary we deduce that f (n) = nlc
for all 77. (since f (n) — nk has infinitely many divisors, namely all numbers
n + 2d with d 2 1), finishing the proof.
El
We end this section with a few more challenging examples, which combine
most of the time all the previous techniques. The first one is a famous IMO
problem, which became an absolute classic. The method of the proof (also
known as infinite descent) goes back to Fermat and crucially uses the ordering
2. 1.
Basic properties
17
of integers. In many cases we need to prove that certain diophantine equations
f (11:1, ..., em) = 0 have no solutions, or only 'trivial solutions" (those that one
can find "at a glance"). The idea is to start with a potential solution (or
a "nontrivial" solution) of the equation and produce a "smaller" one. If the
“smaller" solution created is not “trivial', one repeats the process. We obtain
this way a sequence of solutions, which become llsmallerll and 'smaller', forcing
therefore the process to stop. One can also argue (perhaps more directly) by
contradiction and consider a 'minimal' solution of the problem and then reach
a contradiction after having created a 'smaller' solution.
Let’s see how this works precisely in a simple example, before embarking
in the more challenging example below. Consider the equation 3:2 + y2 = 322.
We claim that the only solution in integers is the "trivial" one, namely a; =
y = z = 0. Indeed, consider a solution (x, y, 2) which is not trivial. Then 3
divides :32 + yz. Checking several cases, it is a simple matter to deduce that
x, 3; must both be multiples of 3. Then a: = 39:1,y = 3m and z2 = 3(1)? + 31%).
We deduce that z is a multiple of 3 (otherwise 22 E 1 (mod 3)), say 2 = 321
and then 27% + y? = 32%. Thus (x1,y1,zl) is also a solution of the equation,
and it is not trivial, since (2:, y, z) is not trivial. On the other hand
|x1|+|yll+IZI|=
M + lyl
+ lzl < I$l + lyl + lzl,
3
thus the solution (x1, y1, 21) is 'smaller'' than (x, y, z), in the sense that the sum
of the absolute values of $1,311, 21 is smaller than that of :13, y, 2. Considering a
nontrivial solution (x, y, z) with |:L'| + |y| + |z| minimal, this immediately yields
a contradiction.
Example 2.36. (IMO 1988) Let a, b be positive integers such that ab+ 1 divides
a2 + b2. Prove that $31,132 is a perfect square.
Proof. Assume that this fails for some a, b and pick a pair (a, b) for which this
fails and for which a + b has the smallest possible value. Write a2 + b2 =
C(ab + 1). By assumption 0 is not a perfect square. By symmetry in a and b,
we may assume that a. 2 b. The quadratic equation
xz—bcm+b2—c=0
18
Chapter 2. Divisibz'lity
has a solution equal to a by assumption. Let
a’=bc—a=
be the other solution.
b2—c
a
Note that a’ = bc — a is an integer and that a’ is
nonzero since c 7E b2 (as c is not a perfect square). We claim that a’ is
positive. Otherwise, we would have a’ S —1, thus b2 — c S —a and c 2 b2 + a.
But then
(12+b2 = c(ab+ 1) 2 (b2+a)(ab+ 1) = ab3+a2b+b2+a > a2b+b2 2 a2+b2,
a contradiction. Thus (a’, b) is another pair satisfying the assumptions of the
problem and for which the conclusion fails. By minimality of (a, b) we must
have a + b S a’ + b, thus a, S a’. This is however impossible, since (using that
a 2 b)
2
2
a’ = b _ c < b— S b.
a
a
Thus there are no pairs satisfying the assumptions of the problem and failing
to satisfy the conclusion.
III
Example 2.37. (IMO 2007) Let a,b be positive integers such that 4ab — 1 I
(4a2 — 1)2. Prove that a = b.
Proof. Since 4ab E 1 (mod 4ab — 1), we have 4a2b E a (mod 4ab — 1). Since
4ab — 1 l (4a2b — b)2, we deduce that 4ab — 1 | (a — b)2. We argue now as in
example 2.36, assuming that (a, b) is a pair satisfying 4ab — 1 | (a — b)2 and
a 75 b, and minimizing a + b. We may assume that a > b. Write (a — b)2 =
c(4ab — 1) and consider the other solution
a’=2b(1+2c)—a,=
b2+c
of the equation
(:1: — b)2 = c(4ba: — 1).
Clearly a’ is also a positive integer and (a’,b) satisfies 4a’b — 1 | (a’ — b)2
and (a’ — b)2 = c(4a’b — 1) (thus a’ 7E b). Using the minimality of (a, b) we
2.1.
Basic properties
19
deduce that a + b g a.’ + b, so a’ Z a and b2 + c 2 a2. However the equation
(a — b)2 = c(4ab — 1) yields 0 g (a — b)2, so we obtain
a2 —b2 S (a—b)2.
Since a > b, this yields a + b S a — b, plainly absurd. Therefore there are no
such pairs (a, b) with a 74 b and the result follows.
III
Remark 2.38. Here are a few very similar problems, all of which can be solved
by the same argument:
a) Positive integers a, b satisfy ab I a2 +b2 + 1. Prove that a2 + b2 + 1 = 3ab.
b) Let a,b be positive integers such that a2 + b2 is divisible by ab— 1. Prove
that {72132 = 5.
c) (AMM 11374) Let a, b, c, d be positive integers such that
abcd=a2+b2+c2+1.
Prove that d = 4.
d) (USA TST 2002) Find all ordered pairs of positive integers (m, n) such
that mn — 1 divides m2 + n2.
e) (USA TST 2009) Find all pairs of positive integers (m, n) such that
mn — 1 divides (n2 — n + 1)2.
f) (Hurwitz) The equation
so? + x3 +
+ as}; = kxlxz...a:n
has no solutions in positive integers if k > n.
Example 2.39. (Kvant) Let p and q be integers greater than 1. Assume that
p|q3—1 andq|p—1.Provethatp=q3/2+1 orp=q2+q+1.
Proof. Write p = qn + 1 for some positive integer n. Then an + 1 I q3 — 1, so
qn+1|q3n—n. But
q3n—n=q2-qn—n=q2(qn+1)-(q2+n),
hence qn + 1 | q2 + n. In particular qn + 1 S q2 + n, which can be written as
n(q—1)Sq2—1 andyieldsngq+1.
20
Chapter 2. Divisibz'lity
Next, wehaveqn+1|q32n —n2 and
(13712—nz=¢12nzq—n2 =(qn2-1)q+q—n2Since qn + 1 divides q272.2 — 1, it follows that qn + 1 | q — n2.
Now, we discuss three cases. If q = n2, then 13 = qn + 1 = q3/2 + 1 and we
are done. If q > n2, then the second paragraph yields qn + 1 S q — n2 < q,
certainly impossible. Finally, if q < 77.2, then the second paragraph yields
qn+ 1 S n2 — q, thus q(n+ 1) S n2 — 1 and q S n— 1. Combined with the first
paragraph, this gives q = n— 1 and thenp = qn+1 = q(q+1)+1 = q2+q+1.
The result follows.
El
Example 2.40. (Bulgaria) Let a, b and c be positive integers such that ab di-
vides c(c2 — c + 1) and a + b is divisible by c2 + 1. Prove that the sets {a, b}
and {c, c2 — c + 1} coincide.
Proof. Write c(c2 — c + 1) = mab and a + b = n(c2 + 1) for some positive
integers m, n. Without loss of generality, assume that b S a. Then
mab=c(c2—c+1)<c(c2+1)=$(a+b)s2a%,
hence b < %.
On the other hand we have a. E —b (mod 62 + 1), thus taking the equation
c(c2 — c + 1) = mab modulo c2 + 1 yields 1 E —mb2 (mod c2 + 1), that is
02 + 1 | mb2 + 1. Thus mb2 + 1— r(c2 + 1) for some positive integer r.
In particular mb2 > rcz, which combined with the inequality b < 2—c”yields
7"n < 4. This forces 12—
— 1 and rm < 4.
Suppose that m > 1, then necessarily 'r = 1.
Since 7" = 1, we have
mb2 = c2, in particular b | 02. Since b I mab = c(c2 — 0+ 1) and b | 02,
we obtain b | 0, thus 0 = kb for some integer k and k2 = m 6 {2,3}. This is
clearly impossible, thus m = 1. It follows that the numbers a, b and c, c2 — c+ 1
have the same sum and product. Thus they are roots of the same quadratic
polynomial and the result follows.
III
Remark 2.41. The solution would be slightly easier if we were willing to use
that fl and \/§ are irrational numbers, which would immediately rule out the
equation mb2 = 02 with 1 < m < 4.
2.1.
Basic properties
21
Example 2.42. '(Romania TST 2012) Let a1, ..., an be positive integers and let
a > 1 be a multiple of mag . . . an. Prove that a"+1 + a — 1 is not divisible by
(a+a1 — 1)(a+a2— 1)...(a+an—1).
Proof. Suppose that
an“ + a — 1 = k(a + a1 — l)...(a + an — 1)
(1)
for some positive integer k, and write a = mal...a.n for some positive integer
m. Note that a1, ...,an > 1, for if a1 = 1 (for example) then the right-hand
side of relation (1) is divisible by a, but the left-hand side is not.
Relation (1) coupled with the congruences a”+1 E 1 (mod a — 1) and
a+a¢—1Eai(moda—l)for1§ignyield
1 E kal...an
(mod (1 — 1),
hence
m E [w E k
(mod (1 — 1).
Note that m < a = mal...a,n and, since az- > 1 for 1 S i g n
a”+1 +a — 1 Z k(a + 1)",
which easily implies that k < (1 (since one easily checks that a(a + 1)” >
a”+1 + a — 1). Thus k, m are positive integers less than or equal to a — 1 and
k: E m (moda—l), which implies k =m. But m | a and k | an+1+a—1,
hence m | a"+1 + a — 1, which implies that m | 1 and finally k = m = 1. It
follows that
a"+1 < a"+1 + a — 1 = (a+ a1 — 1)...(a+ an — 1),
which can be rewritten as
a1-...-a.n=a<
a+a1—1
a+a~n—1
a
a
.
This is however impossible, since for 1 S i S n we have
a+ai—1
a
< 0.37,
this inequality being equivalent to (a — 1)(a,~ — 1) > 0.
The problem is solved.
III
22
Chapter 2. Divisibilz'ty
Example 2.43. (Schinzel) Prove that there exists a constant c > 0 with the
following property: if a positive integer a is even and not a multiple of 10,
then the sum of the digits of ak is greater than clog k for all k: 2 2.
Proof. Define a sequence (b70120 by b0 = 0 and bn+1 = 1 + [11,, log2(10)]. This
sequence is increasing and bn+1 g (1 + log2(10))bn for n 2 1, thus bn S c”
for all n 2 1, where c = 1 + log2(10). Suppose now that k 2 bn and write
a,“ = on + 10c1 + in base 10. For each 2 S j S n we have that 21’1" divides ak
and since 2b1' also divides cbj10b7’ + cbj_,_110bj'"1 + ..., it follows that 2bj divides
co + 10c1 + + Obj—1 10bi—1. Note that this last number is nonzero since co aé 0
by assumption. We deduce that 2bJ' 3 Co + 10c1 +
+ Obj—1 1015—1. Assuming
that cbj_1, ..., cbj_1 are all zero we deduce that 2bJ' < 10bj—1, contradicting the
definition of the sequence (bn)n20. Thus for each 2 S j S n there is at least
one nonzero digit between cbj_1,...,cbj_1. It follows that if k 2 bn, then the
sum of digits of ak is at least n — 1 2 71/2. Taking into account that b, < c”
for all n 2 1, the result follows.
2.2
III
Induction and binomial coefficients
The main topic of this section is the use of induction as a tool for proving divisibilities (or for solving constructive problems). Along the way, we
will study some basic properties of binomial coefficients, which will help us
establish a certain number of remarkable congruences. The study of binomial
coefficients will occur quite frequently in this book, since they have remarkable
arithmetic properties. Since we haven’t developed enough theory so far, the
results in this section are rather modest, but we will need them later on to
obtain rather nontrivial results.
2.2.1
Proving divisibility by induction
Before studying binomial coefficients, let us spend some time dealing with
examples of problems involving divisibility in which induction plays a key role.
Example 2.44. Prove that if n is a power of 3, then n | 2" + 1.
2.2.
Induction and binomial coefi‘icients
23
Proof. We need to prove that 3’“ divides 23k + 1 for all k 2 0. We prove this
by induction on k, the case k = 0 being clear. Assume that 3’“ | 23 + 1 and
write 23k = n - 3k — 1 for some integer n. Then
23’”1 = (23")3 = (n _ 3k _ D3
= n3 . 33k _ n2 . 32k+1 + n _ 3k+1 _ 1 E _1
(mod 3k+l),
as needed.
We can also prove this result directly, by factoring
23k—1 + 1)
1)(223 _ 23 + 1).”(22.3k—1 _
23k + 1 = (2 + 1)(22 _ 2 +
and observing that for i 2 0 we have 22'3i — 23" + 1 E 0 (mod 3). Hence each
of the factors 22 — 2 + 1, 22‘3 — 23 + 1,..., 223'“1 — 23k-1 + 1 is a multiple of 3.
The result follows.
III
Remark 2.45. We strongly suggest the reader to try to prove by induction
theorem 2.31, following the same method as the one explained in the previous
example.
Example 2.46. Let n be a positive integer. Find the largest integer k for which
2’6 | (n + 1)(n + 2)...(n + n).
Proof. Let on = (n + 1)(n + 2)...(n + n). The first few values of the sequence
(an)n21 are 2, 12 = 3-4, 120 = 8 - 15, etc. We conjecture that the largest k for
which 2’“ divides an is n. We will prove this by induction, the case n = 1 being
clear. In order to prove the inductive step, we will find a simple relationship
between an and an“. Namely,
an+1 = (n + 2)(n + 3)...(n + 1-+ n + 1) = (n + 2)...(n + n)(2n + 1) - 2(n + 1)
= 2(n + 1)(n + 2)...(n + n)(2n + 1) = 2a,, - (2n + 1).
Since 2n + 1 is odd, the highest power of 2 dividing 2a,, (2n+ 1) is one plus the
largest power of 2 dividing an, thus by induction this highest power is n + 1,
proving the inductive step. Hence the result of the problem is k = n.
El
24
Chapter 2. Divisibz'lz'ty
Remark 2.47. Iterating the relation
an+1 = 2a,,(2n + 1)
yields the interesting equality
(n+ 1)(n+2)...(n+n) =an = 2”-1-3-
- (2n— 1).
This can also be proved directly, by observing that
(n + 1)(n + 2)...(n + n) =
(272)! _ 1-3-...-(2n—1)-2-4-...-2n
n!
n!
=1-3-...-(2n—1)- 2'”n!- n! =2"-1-3-...-(2n—1).
Example 2.48. (IberoAmerican 2012) Let a, b, c, d be integers such that a — b+
c — d is an odd divisor of a2 — b2 + c2 — d2. Prove that a — b + c — d divides
a" — b” + c" — d" for all positive integers n.
Proof. By assumption a—b+c—d divides a2 —b2+c2 —d2, but a—b+c—d also
divides (a + c)2 — (b + d)2, thus it divides the difference of the two numbers,
which is 2(ac—bd). Since a—b+c—d is odd, it follows that a—b+c—d | ac—bd.
We will prove by induction that a — b + c — d divides a" — b" + c" — d" for
all positive integers n. The cases n = 1, 2 being clear, assume that n 2 3 and
that a—b+c—d|ak—bk+ck—dk fork<n. Let e=a—b+c—d. Since
a"‘1 + c"_1 E b"_1 + (In—1 (mod 6) and a+ c E b + d (mod 8), we have
(a + c)(a"_1 + c"_1) E (b + d)(b”_1 + (in-1)
(mod e).
Expanding and rearranging yields
a" — b“ + c" — d" E bd(b"_2 + (In—2) — ac(a"“2 + c"_2) E 0
(mod e),
the last congruence being a consequence of the congruences bd E ac (mod e)
and b"_2 + c ‘2 E a"_2 + c'"'“2 (mod e).
III
Example 2.49. Define a sequence (an)n21 by setting a1 = 2 and an+1 = 2“" +2
for n 2 1. Prove that an divides an“ for all n.
2.2.
Induction and binomial coefi‘icients
25
Proof. We will prove by induction that an divides an“ and that an — 1 divides
an+1 — 1 for all n 2 1. This is clear for n = 1, so assume that it holds for n — 1
(with n 2 2) and let us prove it for n. Proving that an I an+1 reduces (thanks
to the recurrence relation) to proving that 2“”11'1 + 1 | 2“"’1 + 1. For this, it
suffices to check that a—“E—l—l IS an odd integer. It 1s an integer by the inductive
hypothesis, and it is clearly odd, since an is even for all n. Proving that an —— 1
divides an+1 — 1 reduces to 2“”—1 + 1 | 2“" + 1 and it suffices again to check
that —:L1 is an odd integer. The fact that it is an integer follows from the
inductive hypothesis, while the fact that it is odd follows from an:
_ an_ 1 =
‘2
(mod 4) (which follows directly from the recurrence relation and the fact that
a1 = 2). This proves the inductive step.
III
Emample 2.50. (China 2004) Prove that every positive integer n, except a
finite number of them, can be represented as a sum of 2004 positive integers:
n = a1+a2+...+azoo4, where 1 3 a1 < a2 <
< 0,2004, and oi | (n+1 for
all 1 S i S 2003.
Proof. We will prove by induction on k the following statement: there exists
a positive integer nk such that all n 2 nk can be written n = a1 + a2 +
for an increasing sequence 1 S al <
< ak with al | a2 |
+ ak
| ak. Call such a
decomposition admissible.
The statement is trivial for k = 1 and for k = 2 we can take 712 = 3 (by
writing n = 1 + (n — 1) for n > 2). Suppose now that nk exists and choose
some large n (we will make this statement more precise later on). Write
n = 2’(2m + 1) for some nonnegative integers r and m. If n is large, then at
least one of 7‘ and m is large.
We start with the easy case: suppose that m is large, say m 2 mg. Then
we can find an admissible writing m = a1 + a2 + + ak for m and we obtain
an admissible writing for n
n = 2’ + 2r+1a1 + 2r+1a2 +
+ 2"”(1;c
Suppose now that r is large. It is enough to find an admissible decomposition for 2" (as then we can multiply all of its members by 2m + 1 to get an
admissible writing for n). Write 7‘ = 2q+r1 with 1'1 6 {0, 1} and q 2 0. By the
same argument, it suflices to find an admissible decomposition for 22‘? . Assume
26
Chapter 2. Divisibility
that 2‘1 2 nk and choose an admissible decomposition 2‘1 + 1 = a1 +
+ ak
for 2‘1 + 1. We obtain a new admissible decomposition of length k + 1 for 22‘1
22‘1 = 1 + (24 — 1)(2q + 1) = 1 + (2‘1 — 1m1 +
+ (24 — 1)ak.
It is now very easy to conclude: suppose that n 2 411%. Then either m 2 m
or 2‘1 2 mg. Indeed, otherwise
71 = 224+r1 (2m + 1) < 2 - nfi - 2n,c = 412:,
a contradiction. As we have explained above, this is enough to obtain an
admissible decomposition of length k + 1 for n, so we can take nk+1 = 4n:
and finish the inductive proof.
2.2.2
El
Arithmetic of binomial coefficients
We will use now induction to study binomial coefficients. Recall that if
n, k are nonnegative integers with n 2 k, we define
n
__
k
_k!(n—k)!’
n!
where n! is the product of the first n positive integers (with the convention
that 0! = 1).
A remarkable result is that (Z) is an integer (this is certainly not obvious
from the definition!). There are several proofs of this result. The most standard proof consists in using a simple combinatorial argument to show that (Z)
is the number of subsets with k elements of the set {1, 2, ..., n}. We leave it
to the reader to fill in the details of this combinatorial argument. Let us give
an inductive proof of the fact that (2) is an integer for all n 2 k 2 0. We use
strong induction on n + k, the cases n + k = 0 and n + k = 1 being clear. In
order to prove the inductive hypothesis, we may assume that k 2 1 and n > k
(otherwise it is clear that (Z) = 1). The key point is the classical identity
<z>=<nr>+<:: >,
2.2.
Induction and binomial coefficients
27
which can be checked without any difficulty using directly the definition of
(2). Using the inductive hypothesis the numbers ("'21) and (Ki) are integers,
which proves that (2) is an integer as well. We will use this idea to prove a
similar result, for which the combinatorial interpretation is not easy to find.
Example 2.51. Let q be an integer greater than 1. If n,k are nonnegative
integers, define the Gaussian binomial coefficient (mg by (pa = O for k > n
and, if k S n
(n) = (q“' — 1)(q ‘1 - 1)~-(q""°Jr1 - 1)
k
9
(4" - 1)(t1’°‘1 - 1)---(q — 1)
’
where by convention the right-hand side equals 1 when k = 0.
a) Prove that for all n, k 2 1 we have
(Z),=q"(”21),+(23i)qb) Prove that (mg is an integer for all n, k.
Proof. Let as” = q" - 1 for n 2 1.
a) If k > n, then both sides are equal to 0 by definition, so assume that
k S n. If k = n, then the equality reduces to
(13:61),
and holds since by definition (2% = 1 for all n. Finally, assume that k: S n — 1,
then the desired equality is equivalent to
xnxn—1---$n—k+1 =
xkxk_1...x1
kxn_1...a:n_k + xn_1...a:n_k+1 .
$k...x1
(L‘k_1...:1,'1
Dividing everything by ”4%, the last relation is equivalent to
fl _ qn—k
93k
+1
17k
or an, = qn_k + am. This can be checked by a direct computation.
b) This follows from part a) arguing by strong induction on n + k, in the
same way as we did for the binomial coefficients.
El
28
Chapter 2. Divisibz’lz'ty
Example 2.52. (Tournament of the Towns 2009) For each n 2 1 set
[n]! = 1 - 11 - 111 -
-V
111...1.
Prove that for all m, n 2 1 the number [n + m]! is divisible by [n]![m]!
Proof. Note that
[n]!_10— 1 102—1
9
.10"—1
9,
hence
[n+m]! _1'["+1m(10"—1)
[n]![m]! _
n+m
3:1(102' — 1) m”_1(10i — 1):
m
10'
The result follows then from the previous example.
El
Remark 2.53. The Gaussian binomial coefficients are generalizations of the
usual binomial coefficients, Which correspond to the case q = 1. Many for-
mulae involving binomial coeflicients have analogues for Gaussian binomial
coefficients. For instance, the analogue of the binomial formula (which will be
discussed later on in this section) is
fi(1+q)= q";
4—261) X'“.
k=0
k=0
q
Example 2.54. Prove that n + 1 divides (271‘) for all positive integers n.
Proof. We have the equality
(11+ 1) (2”: 1) = (2n + 1) (2:) = [2(n + 1) — 116:)
Taking it modulo n + 1 yields (2:) E 0 (mod n + 1).
III
2.2. Induction and binomial coefficients
29
Remark 2.55. The number
1
2n
0 = —
n
n+1 (n)
is called the nth Catalan number. These numbers have remarkable properties,
for instance one can prove (not without some efiort) that
'n
Cn+1 = Z CkCn—kk=0
The Catalan numbers also appear frequently in combinatorics, for instance On
is the number of different ways a convex polygon with n + 2 sides can be cut
into triangles by connecting vertices with straight lines (there are dozens of
combinatorial interpretations of Cnl).
Example 2.56. (Romania TST 1988) Prove that for all positive integers n, the
number H2111 kzk is a multiple of (n!)”+1.
Proof. We compute
n
1
(n!)n+1flk
2k
1
1
=ngn+1-(1-2-...-n-2-3-...-n...-n)
n!
n!
2
2
n!”—1
= W (n! ' i ' ”" (n — 1)!) = (1!2!...(n — 1)!)2
n!
n!
n
”—1 n
= 1!(n— 1)! ' 2!(n—2)!“" (n— 1)!1! = k=l
H (k)’
which is clearly an integer.
El
An important observation about (2) is that
(n) = n(n — 1)(n — 2)...(n — k + 1)
k
k!
is a polynomial expression (of degree k) in n. This shows that one can give a
meaning to (3:) even when n does not satisfy n 2 k and even when n is not
30
Chapter 2. Diuisz'bz'ltty
an integer. More precisely, for every real (or complex) number a: and every
nonnegative integer k we can define
a:
._ a:(a:—1)...(:z:—k+1)
k
'_
k!
-
Similarly, we can define a polynomial of degree k
X __ X(X—1)...(X—k+1)
k '_ T'
These generalized binomial coefficients still satisfy many of the usual properties
of binomial coefficients, in particular the formula
x
_
x—l
k
_
k
+
x—l
k—1
still holds. Moreover we have the fundamental
Theorem 2.57. For all a: 6 Z and all nonnegatz’ve integers k we have (2) E Z.
In other words, the product of k consecutive integers is always a multiple of
k!.
Proof. We have already proved this result when a; 2 0, so assume that a: < 0
and write x = —y with y > 0 and integer. Then
as _ 93(a: — 1)...(3: - k + 1) _ ——y(-y — 1)...(—y — k + 1)
k
k!
—
k!
= (_1)ky(y + 1)...(y + k — 1) = (4),, y + k — 1 .
k!
k
Since (“2—1) is an integer, the theorem is proved.
The previous theorem shows that the polynomial
(X) ._ X(X — 1)...(X — n + 1)
n
'_
n!
E]
2.2.
Induction and binomial coeflicients
31
takes integer values at integers. Note that (if) does not have integer coefli—
cients, unless it = 1 (its leading coefficient is i, which is not an integer if
n > 1). The following beautiful theorem describes all polynomials sending
integers to integers.
Theorem 2.58. Let f be a polynomial with rational coefiicients such that f (n)
is an integer for any integer n. Then we can find (unique) integers a0, a1, ..., ad
such that
d
f(X) = 2mm.
i=0
Proof. Let us first prove that for any polynomial with rational coefficients f
there are rational numbers a0, a1, ..., ad (where d = deg f) such that
d
X
2
f(X) = Zai( , ).
.
i=0
We prove this by induction on d = deg f, the case d = 0 being clear. Assuming
that the result holds for polynomials of degree not exceeding d — 1, consider a
polynomial f of degree d. Choose ad such that f(X) — ad (‘25) has degree not
exceeding d — 1 (namely, if a is the leading coefficient of f, choose ad = d!a).
By the inductive hypothesis we can write
...,_,.(§)-g.(§,
d—l
for some rational numbers on, ..., ad, and thus f has the required form.
Assume now that f (n) is an integer for all integers n. Then f (O) = a0 is
an integer, then f (1) = a0 +a1 is an integer, hence a1 is an integer. Assuming
that a0, ..., ak are integers, the relation
M) = 00(3) +al(]:) +
+ak—1<kf1) +a;c
shows that ak is an integer. Thus a0, ..., ad are actually all integers.
III
Chapter 2. Divisibz'lz'ty
Remark 2.59.
1. The hypothesis that f has rational coefficients can be
dropped: any polynomial with complex coefficients that sends integers
to integers must have rational coefficients (we leave this as an exercise
to the reader).
. The proof of the previous theorem only used that f(0), f (1), ..., f (deg f)
are integers. In particular, it follows that if a polynomial with rational
coeflicients takes integer values at deg f + 1 consecutive integer values,
then it takes integer values at all integers.
. As the proof shows, for any polynomial f with complex coefficients, of
degree n, we can find complex numbers do, ..., an such that
n
X
2a,.(k).
f(X) = k=0
Moreover, the numbers a0, ..., an are unique (this follows from the last
part of the proof of theorem 2.58). They are called the Mahler coefficients of f. We will see later on that much of the arithmetic properties
of polynomials are captured by these coefficients (just as much of the al—
gebraic or analytic properties of polynomials are captured by the usual
coefficients) .
Example 2.60. Let a0, a1, ..., an be integers. Prove that the polynomial
f(X) = k=0
2” at (Xk)
has integer coefficients if and only if k! | ak for 0 S k S n.
Proof. Let bk = %, so that
f(X) = b0 + M + b2X(X — 1) + + a(X — 1)...(X — n + 1).
This makes it clear that if k! I ah for all k, then f has integer coefl'icients.
Conversely, suppose that f has integer coefficients, then the coefficient of Xn
is an integer, which means that bn is an integer. But then
f(X)—a(X—1)...(X—n+1) = bo+b1X+...+bn_1X(X—1)...(X—(n—1)+1)
2.2. Induction and binomial coefi'icients
33
also has integer coefl'icients. Considering the coefficient of X”—1 we deduce
that bn_1 is an integer. Continuing like this yields bn, bn_1, ..., b0 6 Z, showing
that k! | ak for all k.
El
Example 2.61. Let f be a monic polynomial of degree n 2 1 with integer
coefficients. Prove that if an integer d divides f(0), f(l), ..., f(n), then d | n!.
Proof. Taking into account theorem 2.58 and the remark following it, we see
that '5 is a polynomial that sends integers to integers and so can be written
f(X) _ "
X
Tait)
for some integers a0, ..., an. Identifying the leading coefficients on both sides
we deduce that
l _ “_n
d _ n!
This immediately yields d I n!, as desired.
El
Example 2.62. (Putnam) Let a1, ...,an be pairwise distinct positive integers
such that a1a2...an | (k + a1)(k + a2)...(k + an) for all positive integers k.
Prove that a1, ...,an is a permutation of 1,2, ...,n.
Proof. Applying the result of the previous example to the monic polynomial
f(X) = (X + a1 + 1)...(X +an + 1)
and to d = a1a2...an, we deduce that a1a2...an | n!. We may assume that
a1 <
< an. Then a1 2 1, a2 2 2,..., an 2 n and since a1...an | n!, this forces
a1 = 1,..., an = n (if one of the inequalities above was strict, then we would
have a1...an > n!). The result follows.
L—J
34
Chapter 2. Divisibz'lz'ty
2.2.3
Derivatives and finite differences
We will now make a quite interesting parallel between the usual coefficients
and the Mahler coefficients of polynomials. By definition, for any polynomial
P of degree n we can find numbers (10, ..., an such that
n
P(X) = Z (1k
k=0
and a0, ..., an are unique (these are the coefiicients of P). The proof of theorem
2.58 (see the remark following theorem 2.58) also allows us to write uniquely
P(X) = in: bk (11:)
16:0
How can we characterize the numbers a;c and by, in terms of P? We need the
following
Definition 2.63. If P(X) = a0 + a1X +
complex coeflicients, we define
o the derivative of P as the polynomial
P’(X) = a1 + 2a2X +
+ 0,a is a polynomial with
+ nanX”_1.
In general, the kthderivative P0“) of P is defined by the recurrence Pa) = P’
and P(k‘H) = (P(k))’.
o the discrete derivative of P as the polynomial AP with
AP(X) = P(X + 1) — P(X).
Define AkP by the recurrence relation AlP = AP and
Ak‘HP = A(AkP) = A’“P(X + 1) — A"P(X).
Let us observe that if P is a nonzero polynomial, then P’ and AP have
degree (strictly) smaller than P. Iterating this observation yields
2.2.
Induction and binomial coefficients
35
Theorem 2.64. For any polynomial P of degree n we have
P(k)=0=AkP if k>n.
Let us observe that (Xk)’ = k‘l, therefore the polynomials
){k
P's: n
satisfy P,’c = Pk_1. Iterating this relation yields
PE) = PM if k 2 j, P“): 0 if k < j.
We deduce that for the polynomial
P(X): Zak= ZakklPk(X)
k=0
k=0
we have for all 0 S d g n
P(d)(X) _:n:ak%'Pk—d(X)_ iakcd
’ )Xk-d
k=d
k=d
and in particular
P(d)(0)
ad:
Osdgn.
d! ’
It also follows from the previous formula that if P has integer coefficients,
then all coeflicients of PM) are multiples of d! and so we obtain the interesting
divisibility
d!|P(d)(a) if a.
Let us study now the analogous situation for the discrete derivative. We
will see that all previous results have their discrete counterparts. Consider the
polynomials
X
SkCY)—-(k).
36
Chapter 2. Divisibility
The identity
(X21) = (if) + (1551)
is equivalent to
AS;c = Sk_1.
We deduce that
AjSk = SH if k zj,
N's,c = o if j > k.
Thus, for any polynomial
P(X>= Zinc:)=ibksk(X)
k—O
k=0
wehaveforaJIOSdSn
AdP(X) = f: bkAdSk(X) = i kk_d(X).
k=0
Ic=d
Recalling that Sj (X) = (f), we obtain the analogous formula
AdP(X)
=2:—
(":6)X(X — 1)...(X — (k — d+ 1)).
We are now ready to prove the
Theorem 2.65. If P is a polynomial with complex coefi‘icients of the form
P(X): X bk(X ),
k=0
then the coefficients b0, ..., bn are given by
bd = AdP(0)
for 0 S d S n. Moreover, if P has integer coefi‘icients, then
d! | AdP(a) if a e z.
2.2. Induction and binomial coefi‘icients
37
Proof. For the first part, it suffices to evaluate at X = 0 the identity
AdP(X)_ k=<k
"b_k
_
d!
dig—l d)X(X—1)-- (X- (k—d+1)).
For the second part, note that £72} are integers for d S k S n (see example
2.60). The result follows immediately by evaluating at X = a the previous
identity.
El
The following theorem gives a‘ beautiful formula for AnP.
Theorem 2.66. For any polynomial P and any n 2 1 we have
A"P(X)= Z(—1)"-k(’;)P(X+k).
k=0
Proof. We will prove this by induction on n, the case n = 1 being clear.
Assume that the result holds for n, then
An+1P(X) = A(A"P) (X) = A"P(X + 1) — A"P(X)
=Z(— 1)n-k(")P(X+k+1)—Z(— 1)n-k(")P(X+k)
k=0
k=0
—_;::l(_1)”+1 ’:(k n 1) P(X + k)— z(—1)""°(Z)P(X + k)
k=0
n+1
k=0
WM“ 1>+<k>>
Tl.
n
=5m) (n;W +k),
k=0
as desired.
An immediate but very useful consequence of theorems 2.64 and 2.66 is
El
38
Chapter 2. Divisibility
Corollary 2.67. For any polynomial P and any n > degP we have
2}- 1)“ kc:)P(X+k)=0.
k=0
Moreover, if P has integer coefiicz‘ents then for all n 2 O we have
n' | Z(-1)”"k(Z)P(k)
k=0
Proof. The first statement is the combination of theorems 2.64 and 2.66. The
second statement is equivalent (using theorem 2.66) to n! I A"P(0), which
follows from theorem 2.65.
2.2.4
III
The binomial formula
One of the fundamental tools used in establishing congruences is the
Theorem 2.68. (binomial formula) For all complex numbers a, b and all n 2
1wehave
n
n
( a+bn=
)
[Elk
nkbk
a—
.
Proof. We prove this by induction, the case n = 1 being clear. Assume that
the result holds for n, then
(a + b)"+1 = (a + b)(a + b)”: (a + b) 2 (Z) an‘kb"
k=0
-kbk+2(n) an—kbk+1
=2<Z)0;n+116:0
16:0
=§<Z)0,n+1—kbk+:::1kn(
_0
_
as desired.
n+1
Z
an+1—kbk ((73)+ ( n 3) 2
k
k—l
)an+1—kbk
—1
n+1
192:0
(73+ 1 )an+1—kbk,
k
III
2.2.
Induction and binomial coefficients
39
Explicitly, we obtain
(a + b)” = a“ + nan—1b + (727') a"‘_2b2 +
+ b”.
Note that if n 2 2, then all terms except the first two in the right-hand side
of the previous equality are multiples of b2. We deduce that
b2 | (a + b)" — a” — nan—1b,
which strengthens the divisibility b | (a + b)" — a”. Similarly, if n 2 3, we can
go one step further and obtain the divisibility
2
.
b3 | (a + b)" — a” — nan—1b — man—2?
We actually have the following fairly general congruence for polynomials with
integer coefficients:
Theorem 2.69. If P is a polynomial with integer coefficients, then for all
integers a, b and all N Z O we have
N (k)
P(a + b) a Z PTf“)? (mod bN+1).
k=0
In particular, for N = 1 this becomes
P(a + b) E P(a) + P’(a)b (mod b2).
Proof. Writing P as a linear combination with integer coeflicients of monomi—
als, we reduce the proof to the case when P is a monomial, say P(X) = Xd
for some d 2 0. Then
P(k)(a) = d(d — 1)...(d — k + Dad—k =
I
d‘
(d — k)!
ad—k
if k S d and P00 (a) = 0 for k > d. Thus the congruence is reduced to
min(N,d)
(a + b)Cl E
Z
d
(16>a‘l—kb’c
(mod bN+1).
k=0
This is a straightforward consequence of the binomial formula.
III
40
Chapter 2. Divisibil'ity
Example 2.70. Prove that 343 divides 2147 — 1.
Proof. We have 343 = 73 and 2147 — 1 = 849 — 1 = (7 + 1)49 — 1. We conclude
using the binomial formula.
III
Example 2.71. Let k be an even positive integer and define a sequence (xn)n
byx1=1andxn+1=kzn+1forn21.
a) Prove that mn_1 divides xn for all n 2 2.
b) Prove that 13% divides wn-1a:n+1 for all n 2 2.
Proof. a) We prove the desired result by induction on n, the statement being
clear for n = 2. Assume that a = xn_1 divides 96,, = k“ + 1, we need to prove
that k“ + 1 | kka+1 + 1. Write k“ + 1 = ab for some positive odd integer b.
Then
b—l
W“ + 1 = W + 1 = (ab — 1)" + 1 = Z(—1)k(:) (ab)b‘k,
k=0
the last equality being a consequence of the binomial formula and of the fact
that b is odd (thus (—1)b + 1 = 0). Every term in the previous sum is a
multiple of ab and the result follows.
b) Let n 2 2 and let a = xn_1, so that 9.2,, = k“ + 1 = ab for some positive
integer b. We need to prove that c12172 divides a(k“b + 1). Note that a, b are
odd, since k is even. But then using the binomial formula
a(k“b + 1) = a((ab — 1)b + 1) = a(1 + (—1)b + ab2(—1)b—1 + ...) = a2b2 +
and each term in the previous sum is a multiple of a2b2.
El
Remark 2.72. A special case of the previous example is the following problem,
that was proposed in a Romanian TST: prove that if n is an odd positive
integer, then
((17, — 1)” + 1)2 | n(n — 1)<n-1>"+1 + n.
Example 2.73. Find a polynomial f with integer coefficients such that 27 |
4”+f(n) forallnz 1.
2.2.
Induction and binomial coefi‘icients
41
Proof. Expanding using the binomial formula yields
4” = (1+3)” E 1+ (n) 3+ (n) 32
1
2
(mod 27) = 1+3n+ 37202——
2 1)
(mod 27).
We would like to take
f(z)=—<1+3x+W),
but the problem' is that this polynomial does not have integer coefficients.
This can be easily fixed, by observing for instance that
w E —9n(n — 1)
(mod 27)
for all n. We can thus choose
f(X)=9X(X—1)—1—3X=9X2—12X—1.
III
Example 2.74. (Tournament of the Towns 2011) Prove that for all n > 1 the
number
11+33+H.+(2n_ 1)2"—l
is divisible by 2” but not by 2““.
Proof. Let
Sn = 11 +33+---+(2‘" —1)2"-1.
We will prove by induction on n that 2" divides Sn and 2'"+1 does not divide
Sn. The case n = 2 is clear, so assume that Sn = 2"m for some odd number
m. Note that
2n—1
Sn+1 = Sn + Z (k + 2")“2".
k=1
The binomial formula combined with theorem 2.31 yields
(k + 2")'°+2" = (k + 2")2"(k + 2")’6 E (k + 2n)k
E kk + lac—12‘" (1:) = k"(1 + 2“) (mod 2"”).
42
Chapter 2. Divisibz'lz'ty
Thus
2n—1
sn+1 2 Sn + (1 + 2")- Z kk = 2(1 + 2“’1)Sn
k=1
= 2n+1m(1 + 2”_1) E 2n+1m (mod 2"”).
Since m is odd, it follows that 2”+1 divides Sn+1 but 2"+2 does not divide
Sn“, which establishes the inductive step.
III
Example 2.75. Prove that 2” +3” is divisible by n2 for infinitely many positive
integers n.
Proof. Let n be a solution of the problem. We will look for a > 1 such that
m = an is also a solution. We need to ensure that
(1277.2 I 31111 + 2am.-
By assumption we can write 3” + 2” = bn2 for some positive integer n. Then,
using the binomial formula, we obtain
(1-1
30.77, ___ (371.)0. = (M2 _ 2n)a = (_1)a2na + Z(_1)k (Z) 2nk(bn2)a—k.
k=0
Choosing a odd, we need to ensure that
a—l
0.27712 I Z(_1)k (a) 2nk(a)a—k
k=0
k
and the simplest way to make this happen is to impose that a2n2 | (g) (b'nz)“"c
for all '0 g k g a — 1. If we choose b = a, the previous divisibility trivially
holds for 0 S k S a — 2 (since (M2)“‘k is then a multiple of (b???)2 = a2n4)
and it also holds for k = a — 1 since (ail) = a. In order to be able to choose
b = a, we only need to check that b > 1 and that b is odd (which is clear
as b divides 2” + 3'”). This reduces to 3" + 2" > n2, which follows easily by
induction.
The previous discussion shows that for any solution n of the problem we
can create a bigger solution. Thus it remains to check that there is at least
one solution, but it is clear that 1 is a solution.
III
2. 3.
Euclidean division
43
Remark 2.76. We will see later on that there are only two positive integers n
such that n2 | 2" + 1, namely 1 and 3.
2.3
2.3.1
Euclidean division
The Euclidean division
In the previous sections we dealt with those properties of divisibility and
congruences which follow straight from definitions. To make the theory leave
the ground, we need to introduce some new ideas, and the Euclidean division
is one such great idea. The following theorem lies therefore at the very heart of
number theory, despite its rather simple statement and proof, since all deeper
results of elementary arithmetic rely on it.
Theorem 2.77. (Euclidean division) For all integers a, b with b > 0 there is
a unique pair of integers (q, r) such that a = bq + r and 0 S r < b.
Proof. Let us first prove the uniqueness of the pair. Suppose that a = bq+r =
bq1 + r1, with 0 S r, r1 < b, and without loss of generality assume that r1 2 r.
If q 7E ql, then
b>r1—r=lr1—r|=|bl‘|q-q1|Z|b|=b,
a contradiction. Hence q = q1 and r = r1.
Let us now turn to the proof of the existence of (q, r). Let q be the integer
part of ‘3‘, i.e. the largest integer not exceeding %. By definition, we have
q S % < q+ 1 and, since b > 0, this can be written as 0 S a — bq < b. Hence
we can set r = a — bq and the result follows.
[I
The statement and proof of the previous theorem ask for a certain number
of observations, which we gather in the following series of simple but useful
remarks.
Remark 2.78. a) We may be bothered by the hypothesis b > 0, but it is
harmless, since we may always replace b by —b and q by —q. This implies that
for all integers a, b with b 7E O, we can find a unique pair (q, r) with a = bq + r
and 0 S r < |b|.
44
Chapter 2. Diuisibility
b) Uniqueness of the pair (q, r) is lost if instead of the condition 0 S r < |b|
we ask for |r| < |b|. An example is given by —3 = —2 - 2 + 1 = —1 - 2 + (—1).
0) Instead of choosing q the integer part of %, we could have chosen the
integer closest to %. We would then obtain |q — %| S %, i.e. setting r = a — bq,
we would have |r| S g. This can be sometimes more useful than the result of
the previous theorem.
The following theorem is a simple restatement of the Euclidean division in
terms of congruences. Since we will be using congruences constantly in this
book, it is worth explicitly stating the result:
Theorem 2.79. For any integers a, n with n at 0 there is a unique 0 S r < |n|
such that a E r (mod n). In other words, if n is a positive integer then any
integer is congruent modulo n to a unique number in the set {0,1, ...,n — 1}.
The numbers q,r in theorem 2.77 are called the quotient, respectively
remainder of a when divided by b. Sometimes we will denote by a (mod b)
the remainder of a when divided by b > 0. Note that the proof of theorem
2.77 allows us to express a (mod b) as
a
(modb)=a—bl%J.
In practice this is not a very convenient formula to compute a (mod b), but
it can be rather useful in more theoretical problems. Here is a classical and
beautiful example:
Example 2.80. For a positive integer n, let r(n) be the sum of the remainders
of n when divided by 1, 2, ..., n. Prove that r(n) = r(n — 1) for infinitely many
positive integers n.
Proof. Since the remainder of n when divided by k is n — klfij, we have
r<n>=i<n-km>=n2-iklzjk=1
k=1
We deduce that
r(n)—r(n—l)=n2—(n—1)2—k:::1kl%J +:E:klnT_1J.
2. 3.
Euclidean division
45
Since [lg—1] = 0, we can further write
r(n)—r(n—1)=2n—1—:k([gj — FLT-1).
The key observation is that [%_I — [”711] is nonzero if and only if k divides
n, in which case [fij — [HT—ll = 1. This follows immediately by writing the
Euclidean division n = qk + r and observing that for r 2 1 the Euclidean
division of n — 1 by k is simply n — 1 = qk + (r — 1). We conclude that
r(n)—r(n—1)=2n—1—Zk.
kln
We thus need to find infinitely many n such that Zkln k = 2n — 1. Note that
all powers of 2 have this property, since
2k:1+2+...+2"‘1+2"=2”+1—1=2-2"—1.
El
Ic|2n
The most practical way to compute remainders is to use congruences com-
bined with the following result:
Proposition 2.81. Let a, b, n be integers with n aé 0. We have a E b (mod n)
if and only if a and b give the same remainder when divided by n.
Proof. Suppose that a E b (mod n) and write a = b + km for some integer k.
Let b = qn + r be the Euclidean division of b by n. Then
a=kn+b=(k+q)n+r
and since 0 S r < |n| the uniqueness of the Euclidean division implies that r
is also the remainder of a when divided by n. Conversely, if a and b give the
same remainder r when divided by n, then n divides a — r and b — r, thus it
divides (a — r) — (b — r) = a — b, which gives a E b (mod n).
E]
Let us see a few numerical examples showing how to use the previous
proposition:
46
Chapter 2. Divisibz'lity
Example 2.82. Find the remainder of 7321 when divided by 11.
Proof. We have 73 E —4 (mod 11), thus
7321 E (—4)21 = —421 = —647 E —(—2)7 = 27 = 128 E 7 (mod 11),
thus the remainder is 7.
El
Example 2.83. Prove that for all integers n we have n3 E 0, :|:1 (mod 9).
Proof. For all n, we have n = 3k, 3k :1: 1 for some integer k, by the Euclidean
division. If n = 3k, then (3k)3 = 27193 E 0 (mod 9). If n = 3k :I: 1, then
n3 = 27k3 :1: 27k2 + 9k :l: 1 E :|:1 (mod 9). Hence for all n, n3 E 0,:|:1
(mod 9).
III
Example 2.84. Consider the sequence (an)n21 defined by a1 = 2 and an+1 =
2““. Find the remainder of a1 + + a254 when divided by 255.
Proof. We have a2 = 4, a3 = 16, a4 = 216, etc. It is thus clear that an 2 16
for n 2 3. On the other hand, 255 = 256 — 1 = 28 — 1 divides 2k — 1 when
8 | k. Since 8 | an for n 2 3, we have an+1 = 2“" E 1 (mod 255) for n 2 3.
Thus
a1+a2+...+a254E2+4+16+251E18
(mod 255).
D
Example 2.85. (USAJMO 2013) Are there integers a and b such that a5b + 3
and ab5 + 3 are both perfect cubes?
Proof. Assume that there are such integers a, b, and write a5b + 3 = m3 and
ab5 + 3 = y3. Then
(51:3 — 3)(y3 — 3) = a5b - ab5 = afib6 = (ab)6.
The remainders modulo 9 of any cube are 0, 1 or 8 by example 2.83. Assume
that 3 | x, then 3 l x3 = a5b+3, so 3 | a5b. Since each of a, b is congruent to 0
or :|:1 modulo 3 by the Euclidean division, we deduce that a or b is a multiple
of 3. Without loss of generality, assume that 3 | a, then a5b + 3 is a multiple
of 3 but not of 9, so cannot be a cube. Thus 1:, y are not multiples of 3 and so
:63 — 3 and y3 — 3 are congruent to —2 or —4 modulo 9. Thus their product
(ab)6 is congruent to 4,8, or 7 modulo 9. This is impossible, since (ab)6 E 1
(mod 9), as (ab)3 E i1 (mod 9).
III
2. 3.
Euclidean division
47
Remark 2.86. The proof of the previous example contains a proof of an im-
portant fact. If m divides 3n and m is not a multiple of 3, then m divides n.
2.3.2
Combinatorial arguments and complete residue systems
The fact that there are only finitely many possibilities for the remainders of
integers when divided by a fixed nonzero integer n is extremely useful in prac-
tice, since it allows us to use combinatorial arguments to solve number theory
problems. Among them, let us stress the following fundamental pigeonhole
principle (which follows immediately from theorem 2.79).
Theorem 2.87. (pigeonhole principle) a) If n is a positive integer, then
among any n + 1 integers we can find two giving the same remainder when
divided by n.
b) If n is a positive integer, then among n consecutive integers there is
exactly one multiple of n (and for any 0 g r < n there is exactly one congruent
to r modulo n)
c) In any infinite sequence of integers we can find infinitely many terms
having the same remainder when divided by n (in particular n divides the
difierence of any two such terms).
Let us illustrate the previous theorem with a few interesting examples.
Example 2.88. Prove that any positive integer has a multiple whose decimal
representation contains the sequence 20132014.
Proof. Let n be a positive integer and choose k such that 10'“ > n. Consider
the numbers 20132014. 10k + 1, 20132014 - 10k +2,
20132014- 10k +n. Each
of them starts with 20132014 and one of them is a multiple of n.
El
Example 2.89. (Erdo) Prove that among 77. integers we can always choose some
of them whose sum is a multiple of n.
Proof. Let a1, ..., an be arbitrary integers and consider the sums
Sk=a1+a2+m+ak
48
Chapter 2. Divisibility
for 1 S k S 77.. If 8'1, ..., 5,, give pairwise distinct remainders when divided by
n, then one of these remainders is 0 and so some 8'], is a multiple of n, solving
the problem in this case. Otherwise, there are integers 1 g i < j S n such
that S,- and 53- give the same remainder when divided by n. But then
n I Sj—Si=a,-+1+...+aj
and the problem is solved in this case too.
[:1
The next problem is a beautiful application of the previous one.
Example 2.90. (Tournament of the Towns 2002) There’s a large pile of cards.
On each card a number from 1, 2,. . . ,n is written. It is known that the sum
of all numbers on all of the cards is equal to k - n! for some k. Prove that it is
possible to arrange the cards into k stacks so that the sum of numbers written
on the cards in each stack is equal to n!.
Proof. We will argue by induction on n, the case n = 1 being clear. Assume
that the result holds for n — 1. Call a card small if the number on it does not
exceed 17. — 1. Let us focus only on small cards and suppose there are at least
n such cards. Pick 77. small cards and choose a group of such cards among the
n chosen cards such that the sum of the numbers on the cards of this group is
a multiple of n, necessarily of the form rn for some 1' 6 {1,2, ...,n — 1}. Now
compress all cards in the group in a super card and label it with number 1*. If
there are still at least 17. small cards after this procedure, pick again n small
cards and repeat the previous procedure to create a new super card labelled
with some number between 1 and n— 1. Repeating this process, we will end up
with a certain number of super cards and at most 17,— 1 small cards. Note that
the sum of the numbers on these small cards is a multiple of 77., since the sum
of all cards on the table was a multiple of n. Thus the sum of the numbers on
the remaining small cards is of the form 7% for some 7" E {1, 2, ...n— 1}. Finally,
compress these remaining small cards into a super card with label 7". Now we
only have cards labelled with n and a certain number of super cards labelled
with 1, 2,
or n — 1. We can consider each card labelled with n as a super
card labelled with 1, so now we have only super cards labelled with 1, 2,
or
n — 1, and the sum of the labels on these super cards is kn! /n = k(n — 1)!. By
2. 3.
Euclidean division
49
induction, we can split the super cards into R: stacks with the sum of the values
in each stack equal to (n — 1)!. Since each super card is obtained by collecting
some cards, it follows that the original cards can be split into k stacks such
that the sum of the numbers in each stack is n - (n — 1)! = n!. The result
follows.
El
Example 2.91. (Romania 1996) Let a, b, c be integers, with at even and b odd.
Prove that for any positive integer 72. there is an integer a: such that 2” |
0.132 + bx + 0.
Proof. Let f(ac) = az2+bx+c. It suffices to check that f(0),f(1), ...,f(2“— 1)
give pairwise distinct remainders mod 2”, as then among these numbers there
will be a multiple of 2”. NOW, assume that 0 S 'i < j S 2" — 1 and f (7,) E f (J)
(mod 2”). Thus
2" I W) — N) = as“ — 2'2) + be — 2') = (j — z‘)(a(z' +j> + b).
Since a is even and b is odd, a('i + j) + b is odd and so necessarily 2” | j — z",
contradicting the inequalities 0 < j —'i < 2".
III
Example 2.92. (Kvant, M 668) The sequence m1,a:2, . .. is defined by $1 =
1, 932 = 0, x3 = 2 and mn+1 = xn_2 + 2:1:n_1 for all n 2 3. Prove that for each
positive integer m there are infinitely many pairs of consecutive terms of the
sequence divisible by m.
Proof. Consider the terms of the sequence modulo m and denote by n the
reminder of m,- modulo m. Note that any three consecutive terms T137941, n+2
determine not only n+3 but ri_1 too. Hence we may define 1'], for nonpositive
integers k and the obtained new sequence is periodic. Indeed, the number of
triples of nonnegative integers less than m is not larger than m3 and therefore
there are two equal triples (ri,r,-+1,ri+2) = (r¢+a,'r¢+a+1,m+a+2). Since the
first triple is determined uniquely by the second one it follows that for all
k we have (Tk,?‘k+1,7"k+2) = (Tk+a,7“k+a+1,rk+a+2)a ie. the sequence (Tn) is
periodic. On the other hand r0 = 3:3 — 251:1 = 0 and r_1 ’= x2 — x0 = 0. Hence
rka_1 = mm = 0 which shows that for all k the terms xka_1 and sum of the
given sequence are divisible by m.
El
50
Chapter 2. Divisibility
Example 2.93. Prove that each integer n > 1 has a multiple less than n4 whose
decimal representation has at most four difl'erent digits.
Proof. Choose k such that 2’“1 S n < 2’“. The result is easy to check when
k S 5, so assume that k 2 6. There are 21c > n nonnegative numbers less than
10" and having only digits 0 and 1. Two of them must give the same remainder
when divided by n, hence their difference is a multiple of n. But their difference
is a number with digits 0,1,8 or 9, which is less than 10k < 16’“‘1 g n4 (the
inequality 10'c < 16’”—1 is equivalent to 1.6,“ > 16 and holds since 1.66 > 16
and k 2 6).
III
Another very useful observation is the following
Proposition 2.94. Let n be a positive integer and let a1, ...,an be integers
giving pairwise distinct remainders when divided by n. Then these remainders
are necessarily a permutation of 0, 1, ..., n — 1. In particular, for all k 2 1 we
have
a'f+a'2°+...+a§ E 1k+2k+...+(n—1)k
Proof. This is clear.
(mod 71.).
El
Sequences a1, ...,an as in the previous proposition occur quite often in
nature, for instance any sequence of n consecutive integers has this property
(by theorem 2.87). Because of their importance, such sequences deserve a
name:
Definition 2.95. A sequence a1, ...,an of integers is said to be a complete
residue system mod n if a1, ..., an give pairwise distinct remainders when di—
vided by n (and then the remainders of a1, ...,an must be a permutation of
0,1,...,n — 1).
The following examples illustrate the concept of complete residue system.
Example 2.96. Find all positive integers n such that there exist complete
residue systems a1,a2, . . . ,an and b1,b2, . . . ,bn modulo n such that a1 + b1,
a2 + b2, . . ., an + bn is also a complete residue system modulo n.
2. 3.
Euclidean division
51
Proof. If n is odd, it suffices to choose any complete residue system a1, ..., an
and let bl = a1, ..., bn = an, so assume that n is even and that such
(21, ...,an, b1, ..., bn exist. If c1, ...,c,, is a complete residue system, then
n(n
01+...+aO+1+...+(n—1) = A
2
(mod n).
Hence the hypothesis yields
n__(n—1)_’___2__n(n—1)_=Z::ai+zbi
2
i=1
a in” + b,) a 952;” (mod n).
i=1
Thus 77. divides 373—4), which is false for n even.
El
Example 2.97. (Serbia 2012) Find all positive integers n for which one can find
a permutation a1, a2, ..., an of 1, 2, ...,n such that (11 + 1,612 + 2, ..., a1, + n and
a1 — 1, a2 — 2, ..., an — n form complete residue systems modulo n.
Proof. Suppose that (11, ..., an is such a permutation. Then
1+2+...+nE (a1+1)+(a2+2)+...+(an+n)
hence n divides a1 +
(mod n),
+ an = flnz—HZ, and thus n is odd. Also, we have
2(12+22+...+n2) E (a1+1)2+...+(an+n)2+(a1—1)2+...+(an—n)2
and the last sum equals 2(a¥ +
2(12 +
+ oi + 12 +
(mod n),
+n2). It follows that n divides
+ n2) = W, hence 3 does not divide n.
Conversely, if n is odd and not divisible by 3, let a, be the remainder of
21' when divided by n (with the convention that we take remainders between
1 and n, not between 0 and n — 1). The reader can easily check that (L1, ..., an
satisfies all requires properties (the point is that the numbers 22' for 1 g i S n
give different remainders when divided by n, and so do the numbers 31' for
1 S i S n).
[I
52
Chapter 2. Divisibility
Example 2.98. (Romania JBMO TST 2013) Find all positive integers n 2 2
having the following property: there is a permutation {0.1, 0.2, ..., an} of the set
{1,2, ...,n} such that the numbers (11 +a2 +
+ak, Where k E {1, 2, 3, ...,n},
form a complete residue system modulo 17..
Proof. We will prove that there is such a permutation if and only if n is even.
Suppose that such a permutation exists. Then n does not divide a1 +
+
a], — (a1 +
+ ak_1) = ak for k = 2, ...,n. Thus we must have a1 = n and so
n cannot divide a1 +
+ an = WELD, which forces 77. to be even.
Conversely, assume that n is even and let a, = n — 2‘ + 1 for 2' odd and
a,- = i — 1 for i even. Thus the permutation is
n,1,n— 2,3,...
Ifz‘ = 2k- + 1 is odd, then
a1+a2+...+aiE1+(—2)+3+(—4)+...+(2k—1)+(—2k)
i—
—kEn—
2
(mod n).
a1+a2+...+a,- E 1+(—2)+...+(2k—3)—(2k—2)+2k—1 E k E
N|s.
If i = 2k is even, then
(mod n).
It follows immediately that all partial sums (a1 +a2 +...+a,-)1S,-Sn give distinct
remainders modulo n, and the result follows.
[I
We end this section with a series of miscellaneous problems in which the
Euclidean division and its various consequences explained above play a crucial
role.
Example 2.99. (Kvant, M 24) Let 0 < m < n be positive integers. Prove that
there are integers 0 < q1 < < qr such that ql | q2 |
| q, and
m
1
1
n
ql
(12
_ = __ + _ + . .
1
+ ....
'r
2.3.
Euclidean division
53
Proof. We use strong induction on m, the case m = 1 being clear. Suppose
that the result holds up to m— 1 and let us prove it for m. Consider n > m > 1
andwriten=mq+rwith0$r<mandq2 1. Ifr=0, then % = % and
we are done. Otherwise, we have n = m(q + 1) — (m — r) and
fl _ m(q+1) _ n+m—r _
n
n(t1+1)
1
Mq+D —q+1
+ m—r
(4+Dn°
By the inductive hypothesis we can write
m -— r
1
= 7+
n
q2
1
+ '7
qr
with q; |
| q} Letting q1 = q + 1 and q; = (q + 1)q,§ for 2 S i S 7" yields the
desired representation of %.
El
Example 2.100. We say that a positive integer n is good if the remainder of
any perfect square when divided by n is a perfect square.
a) Prove that n = 16 is good.
b) Prove that any good number is smaller than 500.
Proof. a) Let n = 8k + r be a positive integer, with 0 S r S 7. Then 77.2 E 1'2
(mod 16). If r S 3, the remainder of 712 when divided by 16 is 7‘2, a perfect
square. If r = 4, the remainder is 0, while if 5 S 'r S 7 the remainder is
(8 — r)2, again a square.
b) Suppose that n > 500 is good and let q = [Jr—1.] and 'r = n — q2. Then
0 S r 3 2g and q 2 22. Let M = |_(\/2— 1)qj and finally let
ak=(¢1+k)2—nIt is not diflicult to check that for 1 g k S M we have 1 S ak < n, so that
ak is the remainder of (q + [(2)2 when divided by 17.. Hence we can find positive
integers b1 <
< bM such that ch = bi for k S M. Since
aM=(¢J+M)2—ns2q2—nSq2,
it follows that bM S q and so bk 3 q for all Is. For 2 S k S M we have
fi—fi4=%—%4=M+%—L
54
Chapter 2. Divisibz'lity
Combined with the fact that bk S q this easily yields bk — bk_1 2 3 (note that
bk — bk_1 is odd by the previous relation). But then adding these inequalities
yields 3(M — 1) S bM — b1 S q — 1. Coming back to the definition of M it is
not difficult to see that the last inequality is impossible for q 2 22.
El
Remark 2.101. Actually the largest good number is 16, but this requires a
certain number of manual computations which are not very nice.
Example 2.102. (Japan 2000) Let n 2 3. Prove that there are n pairwise
distinct positive integers a1, ...,an such that the product a1a2...a,-_1a,-+1...an
gives remainder 1 when divided by a,- for 1 S i S n.
Proof. The obvious approach is to use induction, but we will see that this is
slightly tricky to implement. For n = 3 choose the numbers 2, 3, 5. Assume
that we constructed a1, ..., an and let us try to construct an“. This should be a
divisor of a1...an— 1. To make our life easy, we try the choice an+1 = alman—l.
Unfortunately, it is no longer true that a1a3...an+1 E 1 (mod a2), as required.
Indeed
a1a3...an+1 = a1a3...an -an+1 E 1 - (—1) E —1
(mod (12).
Since we cannot really say anything about divisors of alman — 1, this naive
approach seems doomed.
To make things work, we start by constructing a sequence b1, b2, ..., bn such
that the product of all terms except b,- gives remainder b,- — 1 when divided
by 12,-. This is fairly easy to construct since this time the previous inductive
argument works: start with bl = 2 and define inductively
bn+1 = b1...bn + 1.
Assuming that b1, ..., bn have the property that Hjaéi bj E —1 (mod b,) for 1 S
'L' S n, the numbers 61,...,bn+1 have the same property, since by construction
bn+1 E 1 (mod b,) for 1 S i S 17..
Now, choose a,- = bi for 1 S i S n and an+1 = b1...bn — 1. Then alman E 1
(mod an“) and moreover for 1 S i S n we have
H
1Sj7£iSn+1
a,- =
H
1975a
bj - an+1 E (—1)-(—1) E 1
(mod (1,),
2. 3.
Euclidean division
55
thus a1, ..., an, an“ are a solution of the problem for all n 2 2.
III
Example 2.103. (St Petersburg 2013) Let a be a positive integer with 54 digits,
each equal to 0 or 1. Prove that the remainder of a when divided by 33-34. . . 39
is larger than 100000.
Proof. To simplify notations, let A = 33 - 39. Since a has 54 digits, each
equal to 0 or 1, we can write a = 10"1 + 10"2 +
+ 10’“! for some integers
k1 >
> kg, with k1 = 53. Write a = Aq + 'r for the Euclidean division of a
by A. The key observation is that 106 — 1 divides A, as can be easily checked
from
106—1: (103—1)(103+1)=9-3-37-7-11-13.
Thus, 7” E a (mod 106 — 1). Now, let r1, ...,rs be the remainders of k1, ..., ks
when divided by 6. Then 10’“ E 10” (mod 106 — 1) and so
7' E a E 10'1 +
+ 10"
(mod 106 — 1).
Note that 11 = 5 as k1 = 53. If
10’"1 +
+ 10“ < 106 — 1,
the previous congruence yields
7' 2 10’1 +
+ 10’s > 105.
Assume that 10’"1 +
+ 10’“ 2 106 — 1. Since k1, ..., ks are distinct numbers
between 0 and 53, at most 9 of them give remainder i when divided by 6, and
this holds for all 0 S i S 5. Thus
10r1+...+10r’$9-l+9-10+...+9-105=106—1
and so this inequality should be an equality, forcing k1 = 53, k2 = 52, ...,
1954 = 0, in other words a would have all digits equal to 1. Moreover, r E 0
(mod 106 — 1), hence r 2 106 — 1 > 105 or r = 0. But if r = 0, then A would
divide a 2 L34, impossible since 5 | A and 5 does not divide a. The result
follows.
III
56
Chapter 2. Divisibz'lity
2.4
Problems for practice
Basic properties
. Prove that the last 12 + 2 digits of 52"4'”+2 are the digits of 5"”, com—
pleted on the left with some zeros.
. Is there a polynomial f with integer coeflicients such that the congruence
f(:1:) E 0 (mod 6) has 2,3 as solutions, but no other solution in the set
{0, 1,
5}?
(Iran 2003) Is there an infinite set S such that for all distinct elements
a, b of S we have a2 — ab+ b2 | a2b2?
(Russia 2003) Is it possible to write a. positive integer in every cell of an
infinite chessboard in such a manner that for all integers m, n > 100, the
sum of numbers in every m x n rectangle is divisible by m + n?
. Prove that if k > 1 is an integer then there are infinitely many positive
integers n such that nlk" + 1.
(Kvant M 904) For each positive integer A with decimal representation
A=m
we set
F(A) = an + 2an_1 + ' ' - + 2”_1a1 + 2nao
and consider the sequence A0 = A, A1 = F(Ao), A2 = F(Al), . . . .
(i) Prove that there is a term A* of this sequence such that A* < 20 and
F(A*) = A*.
(ii) Find A* for A = 192013.
. Are there infinitely many 5—tuples (a, b, c, d, e) of positive integers such
thatl<a<b<c<d<eanda|b2—1,b|c2—1,c|d2—1,d|62—1
ande|a2—1?
2.4. Problems for practice
57
00
. (Romania JBMO TST 2003) Let A be a finite set of positive integers
«D
with at least three elements. Prove that there are two elements of A
whose sum does not divide the sum of the other elements of A.
. (Iran 2005) Prove that there are infinitely many positive integers n such
that n | 3n+1 — 2"“.
10. (Mathematical Reflections S 259) Let a, b, c, d, e be integers such that
a(b+c) +b(c+d)+c(d+e)+d(e+a)+e(a+b) = 0.
Prove that a + b + c + d + e divides a5 + b5 + c5 + d5 + e5 — 5abcde.
11. (Kazahstan 2011) Find the smallest integer n > 1 such that there exist
positive integers a1, a2, . . . ,am for which
a%+...+a%|(a1+...+an)2—1.
12. (Kvant 898) Find all odd integers 0 < a < b < c < d such that
ad=bc, a+d=2k, b+c=2m
for some positive integers k and m.
13. f is a polynomial with integer coefficients such that f (n) > n for
every positive integer n. Define a sequence ($0,121 by $1 = 1 and
act-+1 = f (xi). Assuming that each positive integer has a multiple among
$1,502, ..., prove that f(X) = X + 1.
14. (Iran 2013) Suppose that a,b are two odd positive integers such that
2ab+ 1 | a2 + b2 + 1. Prove that a = b.
15. (Kvant) Prove that n2 + 1 divides n! for infinitely many positive integers
n.
16. (Vietnam 2001) Let (an)n21 be an increasing sequence of positive integers such that an+1 — an S 2001 for all n. Prove that there are infinitely
many pairs (1', j) with i < 3' such that ailaj.
58
Chapter 2. Divisibz'lz’ty
Induction and binomial coefficients
17. (Tournament of the Towns) Define a sequence (an)n20 by a0 = 9 and
an+1 = a§l(3an + 4) for n 2 0. Prove that an + 1 is a multiple of 102"
for all 17..
18. Find the largest integer k which divides 8‘”+1 — 7n —— 8 for all positive
integers n.
19. Let a, b be distinct integers and let n be a positive integer. Prove that
(a — b)2 | a” — b” if and only ifa— b | nbn‘l.
20. (BAMO 2012) Let n be a positive integer such that 81 divides both n
and the number obtained by reversing the order of the digits of n. Prove
that 81 also divides the sum of digits of n.
21. Prove that for all n 2 1 the number W is an integer multiple of
(n + 1)2.
22. Find all integers a such that n2 divides (n + a)" — a for all positive
integers n.
23. (P. Erdos) Prove that every positive integer is a sum of one or more
numbers of the form 2' - 33, where r and s are nonnegative integers and
no summand divides another.
24. (Kvant M 2274)) Let k 2 2 be an integer. Find all positive integers n
such that 2’“ divides 1” + 2" + - - ~ + (2k — 1)”.
25. Let k be an integer greater than 1 and let a1, ..., an be integers such that
a1 + 2ia2 + 3ia3 +
+ nian = 0
for all z' = 1, 2, ..., k — 1. Prove that (11 + 2ka2 +
+nkan is divisible by
kl.
26. Prove that for any integer k 2 3 there are k pairwise distinct positive
integers such that their sum is divisible by each of the given numbers.
2.4.
Problems for practice
59
27. (Kvant) Prove that for any integer n > 1 there exist n pairwise distinct
positive integers such that for any two a, b among them the number a + b
is divisible by a — b.
28. (Romania TST 1987) Let a, b, c be integers such that a + b + c divides
a2 + b2 + 02. Prove that a + b + c divides a,” + b“ + c" for infinitely many
positive integers n.
29. (Russia 1995) Let a1 be an integer greater than 1. Prove that there is
an increasing sequence of positive integers a1 < a2 <
such that
a1+a2+...+ak|a§+...+a,2c
for allkZ 1.
30. Let n be a positive integer. Prove that
a) All multiples of 10'” — 1 which do not exceed 10”(10" — 1) have sum
of digits 9n.
b) The sum of digits of any multiple of 10” — 1 is at least 972.
31. (USAMO 1998) Prove that for each n 2 2 there is a set S of n integers
such that (a — b)2 divides ab for every distinct a, b e S.
32. (Romania JBMO TST 2004) Let A be a set of positive integers such that
a) if a E A, then all positive divisors of a are also in A;
b) ifa,be Asatisfy 1 <a< b, then 1+abEA.
Prove that if A has at least 3 elements, then A is the set of all positive
integers.
33. (USAMO 2002) Let a,b be integers greater than 2. Prove that there
exists a positive integer k and a finite sequence n1, n2, . . . , n], of positive
integers such that m = a, nk = b, and mm“ is divisible by 7n + 7744.1
for eachi (1 g 'i < k).
34. Is it true that for any integer k > 1 we can find an integer n > 1 such
that k divides each of the munbers ('2'), (3),..., nil)?
60
Chapter 2. Divisibz'lity
35. (Catalan) Prove that m!n!(m + n)! divides (2m)!(2n)! for all positive
integers m, 17..
< xn_1 be consecutive positive integers such that
36. Let £1 < .732 <
ask | 19(2) for all 1 S k: S n — 1. Prove that :31 equals 1 or 2.
Euclidean division
37. Prove that for any n > 1 there are 2n — 2 positive integers such that the
average of any n of them is not an integer.
38. Let n be a positive integer. Find the remainder of 32" when divided by
2n+3_
39. (Saint Petersburg 1996) Let P be a polynomial with integer coefficients,
of degree greater than 1. Prove that there is an infinite arithmetic pro-
gression none of whose terms belongs to {P(n)| n E Z}.
40. (Baltic Way 2011) Determine all positive integers d such that whenever
d divides a positive integer n, d also divides any integer obtained by
rearranging the digits of n.
41. (Russia) A convex polygon on the coordinate plane contains at least
m2 + 1 points with integer coordinates in its interior. Show that some
177. + 1 of these points lie on a line.
42. (IMO 2001) Let n > 1 be an odd integer and let c1, C2, . . . , cn be integers.
For each permutation a = a1,a2, . . . ,an of 1, 2, . . . ,n, define
3(a) = 0101 + 620.2 +
+ 011%.
Prove that there are permutations a gé b of 1,2, . . . ,n such that n! |
S’(a) — S'(b).
43. Let n,k > 1 be integers. Consider a set A of k integers. For each
nonempty subset B of A, compute the remainder of the sum of elements
of B when divided by n. Assume that 0 does not appear among these
remainders. Prove that there are at least k distinct remainders obtained
2.4.
Problems for practice
in this way.
61
Moreover, if there are only k such remainders, then all
elements of A give the same remainder when divided by n.
44. (IMO 2005) A sequence (11, a2,
of integers has the following properties:
a) a1, a2, ..., an is a complete residue system modulo n for all n 2 1.
b) there are infinitely many positive and infinitely many negative terms
in the sequence.
Prove that each integer appears exactly once in this sequence.
45. For a positive integer n, consider the set
S:{0,1,1+2,1+2+3,...,1+2+3+...+(n—1)}
Prove S is a complete residue system modulo n if and only if n is a power
of 2.
46. (Argentina 2008) 101 positive integers are written on a line. Prove that
we can write signs +, signs x and parentheses between them, without
changing the order of the numbers, in such a way that the resulting
expression makes sense and the result is divisible by 16!.
47. (adapted from Kvant M33) Consider the remainders of 2” when divided
by 1,2, ...,n. Prove that their sum exceeds cnlogn for some constant
c > 0 (independent of n > 1).
Chapter 3
GCD and LCM
This relatively short chapter discusses properties of the greatest common
divisor and of the least common multiple of several integers, with special
emphasis on the applications of these concepts to diophantine equations. Key
results proved and discussed at length in this chapter are Bézout’s theorem
and Gauss’ lemma. These are crucial results in arithmetic, which will appear
constantly throughout this book.
3.1
3.1.1
Bézout’s theorem and Gauss’ lemma
Bézout’s theorem and the Euclidean algorithm
In this chapter we will be interested in common divisors of two or several
integers. We start by introducing the key definition and notation for this
notion:
Definition 3.1. Let a1, a2, ..., an be integers, not all equal to 0. We denote by
gcd(a1, a2, ..., an) and call the greatest common divisor of a1, ..., an the largest
positive integer that divides a1, a2,..., an simultaneously.
The fact that the previous definition makes sense deserves an explanation:
we need to check that the set of positive common divisors of a1, ..., an has a
greatest element. This set is nonempty, since it contains 1, and this set is finite,
64
Chapter 3. GOD and LCM
since any common divisor of a1, ..., an does not exceed max(|a1|, |a2|, ..., lanl) (if
all ai’s are nonzero, we can replace max(|a1|, ..., Ianl) with min(|a1|, ..., |an|)),
so there are only finitely many common divisors. Note that this crucially uses
the hypothesis that a1, ..., on are not simultaneously equal to 0. We will take
the convention that gcd(a1, ...,an) = 0 when a1 =
= on = 0.
By definition, gcd(a1, ...,an) divides (11, ...,an, hence it divides any linear
combination of a1, ..., an. The fundamental result in this section states that
gcd(a1, ..., an) is actually equal to some linear combination of a1, ..., an. The
Euclidean division plays a crucial role in the proof.
Theorem 3.2. {Bézout} For any integers a1, ..., on there are integers 3:1, ..., xn
such that
gcd(a1, ...,an) = (11:31 +
+ aux”.
Proof. If a1 =
= on = 0, choose x1 =
= xn = 0, so assume that not all
ai’s are equal to 0. Let S be the set of all linear combinations 0.11:1 + + anwn
with integer coeflicients m1, ..., xn. Note that a? +
+ of, is a positive integer
in 5', so there is a smallest positive integer d in S. We will prove that d =
gcd(a1, ..., on), which implies the desired result.
Since d is a linear combination of a1, ..., an, d is a multiple of gcd(a1, ..., on).
It suffices therefore to prove that d divides a1, ..., an in order to conclude. We
will prove that d divides any element 5 of S, and in particular it divides
a1, ..., an. Let s e S’ and suppose that d does not divide 5. Thus 3 = qd + r
for some integers r, s with 0 < r < d. Now .5 and d are linear combinations of
an, ...,an, thus r = s — qd is also a linear combination of 0.1, ...,an and so 1' is
a positive element of S smaller than d. This contradicts the minimality of d
and finishes the proof of the theorem.
III
We record the following simple consequence of theorem 3.2, which will be
constantly used from now on.
Corollary 3.3. If :31, ...,xn are integers and a is a positive integer, then
gcd(a.a:1, ..., awn) = a - gcd(a:1, ...,xn).
Proof. The result is clear if x1 =
= xn = 0, so assume that this is not the
case. Let d = gcd(a:1:1, ...,axn) and e = gcd(a31, ...,xn). Since 6 | 1:,- for all i,
3.1.
Be’zout’s theorem and Gauss’ lemma
65
we have ae I am for all i, hence ae is a common positive divisor of ax1,..., awn
and so ae S d. By the previous theorem e is a linear combination of $1, ..., (on,
hence ae is a linear combination of arm, ..., axn and so ae is a multiple of d. It
follows that ae = d, as needed.
L—J
Example 3.4. (Putnam 2000) Prove that the expression flg—r‘flfl) is an integer for all pairs of integers n 2 m 2 1.
Proof. Write gcd(m, n) = an + bm for some integers a, b, then
gcd(m,n) (n) = a<n> + bfl (71))
thus it suffices to check that %(;) is an integer. But
m n
_m
n!
_
(n—l)!
_
n—l
E m _n.(n—m)!m!—(m—1)!(n—m)!— m—l
is an integer.
El
We will try to find a practical way of computing gcd(a1, ..., an). The obvious and naive approach consists in testing whether k divides a1, ...,an for
1 S k: S max(|a1|, ..., Ianl) (if all ai’s are nonzero, we can replace max with
min) and take the largest such k. This is not efficient at all.
We Will first simplify the problem by reducing it to the case n = 2. In
order to do this, we need the following very important result, which is an easy
consequence of theorem 3.2, but which would not be so easy to prove directly
from the definition of gcd(a1, ...,an).
Corollary 3.5. Let a1, ...,an be integers. Any common divisor of a1, ...,an
divides gcd(a1, ..., an).
Proof. Any common divisor of a1,...,an divides any linear combination of
a1,...,an and, by theorem 3.2, gcd(a1,...,an) is a linear combination of
a1, ...,an.
El
66
Chapter 3. GOD and LCM
The previous corollary easily implies the following property of gcd, which
reduces the computation of the god of n numbers to that of the god of n — 1
numbers and the gcd of two numbers. Inductively, this reduces therefore the
problem of computing the gcd of n numbers to that of computing the god of
two numbers.
Theorem 3.6. For all integers a1, ...,an we have
gcd(a1,...,an) = gcd(gcd(a1, ..., 0.71-1), an).
Proof. Let d = gcd(a1,...,an) and e = gcd(a1,...,an_1). Note that d is a
common divisor of a1, ...,an_1, thus d | e thanks to the previous corollary.
We need to check that gcd(e,a,n) = d. Since d divides an and e, we know
that d g gcd(e,an). On the other hand, gcd(e,an) divides e and an, thus it
divides a1, ...,an and thanks to the previous corollary again, gcd(e,an) | (1,
thus gcd(e, an) S d. We conclude that gcd(e, (1...) = d.
III
The formal reductions of the problem being done, we need to solve the
problem of computing gcd(a, b) for two integers a, b. The key observation is
the following:
Proposition 3.7. Let a,b be integers with b 9E 0 and let a = bq + r be the
Euclidean division of a by b. Then gcd(a, b) = gcd(b,r).
Proof. Any common divisor of a and b divides a — bq = r and so is a common
divisor of b and r. Conversely, any common divisor of b and r = a — bq is
a divisor of a and so a common divisor of a and b. The result follows then
straight from the definition of gcd(a, b) and gcd(b, r).
III
Using the previous proposition, we obtain a very efficient way of computing
gcd(a, b). Ifa = 0, then clearly gcd(a, b) = |b|, and ifb = 0 then gcd(a, b) = lal.
Thus we may assume that a, b aé 0. Also, gcd(a, b) = gcd(lal, |b|), so replacing
a and b with their absolute values we may assume that a, b are positive integers.
Finally, gcd(a, b) = gcd(b, a), so we may assume that a 2 b. Then we apply
3.1.
Be’zout’s theorem and Ganss’ lemma
67
the Euclidean division and obtain the relations
a=bq1+r1,
OST1<b
b=’f'1(12+7‘2,
OST2<T1
r1 =r2q3+r3,
OSr3<r2
1"Is—2 = Tic—1% + 7’19,
0 S Tic < Tic—1
r15—1 = 7”k+1 + 7'k+1a rk+1 = 0
Since b > r1 > r2 > . . . are nonnegative integers, there must be some k for
which rk+1 = 0. Hence our process must terminate. Moreover, by the previous
proposition
d = n(a, b) = n(b, T1) = n(7‘1,7'2) =
= n(rka 7fil<t+1) = n(rka 0) = Th,
thus gcd(a, b) is the last nonzero remainder obtained in the process. We have
just proved the very important
Theorem 3.8. (Euclidean algorithm) Let a > b be positive integers. Define
r0 = a, r1 = b and, as long as r", aé 0, define rn+1 as the remainder in the
Euclidean division of rn_1 by rn. Then there is a smallest n 2 1 for which
r1, = 0, and rn_1 = gcd(a, b).
Example 3.9. Compute
a) gcd(2050, 123).
b) gcd (987654321, 123456789).
c) gcd (2016, 2352, 1680).
Proof. a) The Euclidean algorithm is implemented as follows
2050: 123-16+82
123=82-1+41
82=2-41+0
Hence gcd (2050, 123) = 41.
b) Set a = 987654321, b = 123456789. Euclidean division yields a =
8b + 9. Next, we need to perform the Euclidean division of b by 9. A direct
68
Chapter 3. GOD and LCM
computation shows that 9 | b and so the corresponding remainder is 9. It
follows that gcd(a, b) = 9.
c) We first find
gcd(1680, 2016) = gcd(16 - 105,16 - 126) = 16 gcd(105, 126) = 16 - 21.
We next find
gcd(16 - 21, 2352) = gcd(16 - 21, 16- 147) = 16 - gcd(21,147) = 16 - 21 = 336.
Thus the answer is 336.
3.1.2
III
Relatively prime numbers
We move on to the second important topic of this section, that of coprime
and pairwise relatively prime numbers. Let us define this concept first.
Definition 3.10. Integers a1, ..., an are called relatively prime or coprime if
gcd(a1,...,a,n) = 1.
They are called pairwise relatively prime if gcd(ai, a,-) = 1 for all 1 S 2' 7e 3' g n.
Remark 3.11. Saying that (11, ..., an are pairwise relatively prime is much
stronger than saying that al, ..., an are relatively prime. For instance 6,10,15
are coprime since no integer greater than 1 divides all of them, but gcd(6, 10) =
2 > 1, gcd(6, 15) = 3 > 1 and gcd(10,15) = 5 > 1.
Before moving on to more technical things, let us give some classical examples illustrating the previous notions. The following example is very important,
establishing a key property of the numbers
E, = 22" +1,
called Fermat’s numbers. These numbers play a fundamental role in arithmetic
and quite a lot of difficult problems concern them (we will see the appearance
of Fermat numbers quite often in this book). The following problem shows
that these numbers are pairwise relatively prime (note that it is not entirely
obvious how to construct infinite sequences of positive integers such that any
two terms in the sequence are relatively prime).
3.1 . Be’zout’s theorem and Gauss’ lemma
69
Example 3.12. Let F = 22" + 1 be the nth Fermat number. Prove that
gcd(Fm,Fn) = 1
for m aé 17..
Proof. We may assume that m > n. Suppose that d > 1 is a common divisor
of Fm and F”, then clearly cl is odd, since Fn is odd. Since 22" E —1 (mod d),
we also have
(22”)2m—n E (—1)2m_" E 1
(mod d),
in other words 22m E 1 (mod (1). But by assumption d | Fm, thus 22m E —1
(mod d). We deduce that d | 2 and since d is odd, we must have d = 1.
III
An alternative argument which can be used to prove that the Fermat
numbers are pairwise relatively prime is based on the identity
Fn — 2 = F0F2...Fn_1,
which follows from
22" — 1 = (2 — 1)(2 + 1)(22 + 1)...(2
271—1
+ 1).
Thus if d divides E, and Fm with m < n, then d divides 2 = Fn — F0...Fn_1.
Since d is odd, we must have d = 1.
The next example is a variation on this theme.
Example 3.13. Let f be a polynomial with integer coefficients such that
f (0) = f (1) = 1. Prove that for all integers n, the numbers n, f (n), f (f (12)),
f(f(f(n))), are pairwise relatively prime.
Proof. Let n be an integer and define the sequence (afikzo by a0 = n and
ak+1 = f (ak) for k 2 0. We need to prove that a0, a1,
are pairwise relatively
prime.
By hypothesis f — 1 vanishes at 0 and 1, thus we can write
f(X) = X(X - 1)9(X) + 1
70
Chapter 3. GOD and LCM
'
for some polynomial g with integer coefficients. Then
ak+1 = f(ak) = 1 + ak(ak - 1)g(ak),
which can be written as
ak+1 — 1 = (“k — 1)ak9(ak)A straightforward induction, then gives
m—l
am — 1 = (110 - 1) H (akg(ak))19:0
The right-hand side is a multiple of aoal...am_1. Thus if d divides aj for some
j < m, then (1 divides am — 1 and d does not divide am unless d = 1. We
deduce that gcd(aj, ak) = 1 for j < k and the result follows.
III
Example 3.14. (Miklos Schweitzer Competition 1949) Let n and k be positive
integers, n 2 k. Prove that the numbers (2), (nil), . . . , (":1”) are relatively
prime.
Proof. We prove this by induction on k, the case k = 1 being clear. Assume that the result holds for k — 1 and let d be a common divisor of
(Z), (”:1), . . . , (”II”). Then d divides the successive differences between these
numbers, thus (1 I (”:1)—(‘;;) = ($1), then d | (”:2) — (”:1) = Zfi) and finally
d | ("fifll But by the inductive hypothesis the numbers (1:1), ..., (":5?)
are relatively prime, so d | 1 and the result follows.
El
Example 3.15. (Tournament of the Towns 2003) An increasing arithmetic progression consists of one hundred positive integers. Is it possible that every two
of them are relatively prime?
Proof. Yes, it is possible. We are looking for positive integers a, b such that
a + ib and a + jb are relatively prime for 0 S i < j S 99. Suppose that d
divides a + z'b and a + jb, then it divides (j — i)b and so it divides 99!b. But
since at | 99!a+z'99!b, d also divides 99!a, and so d | 99! gcd(a, b). We choose a, b
relatively prime, then d | 99!. Next, we choose b a multiple of 99!, then (1 divides
a (since it divides 99! and a + ib). Finally, choosing a = 1 (or any number
congruent to 1 modulo 99!) yields the desired arithmetic progression.
III
3.1.
Bézout’s theorem and Gauss’ lemma
71
Example 3.16. (Kvant, M 1014) Let a1, a2, . . . ,an be pairwise distinct and
pairwise relatively prime numbers. Prove that there are infinitely many positive integers b such that the numbers a1 + b, a2 + b. . . , an + b are also pairwise
relatively prime.
Proof. Denote by P the absolute value of the product of all numbers ai — aj,
1 g i < j S n. Then for each positive integer k the numbers a1 + kP,
a2 + kP, . . . , an + kP are pairwise relatively prime. Indeed, let d be a common
divisor of a + kP and aj + kP. Then d divides a; — aj and hence it divides
P. Hence d divides both ai and aj, i.e. d = 1.
E]
The following result (which will be constantly used from now on) explains
why relatively prime integers are simultaneously a natural and useful notion:
Proposition 3.17. Let a1, ..., an be integers and let d = gcd(a1, ..., an). There
are relatively prime integers x1, ...,xn such that ai = dasi for 1 S i S n.
Proof. Since d divides a1, ...,an, we can write ai = drvi for some integers
$1,...,:cn. If d = 0, we have a1 =
= an = 0 and we can take xi = 1
for 1 S i S n. If d 7E 0, then 9:1,...,:cn are relatively prime, since if e > 1 is
a common divisor of :31, ..., xn, then ed is a common divisor of a1, ..., an and
ed > d, a contradiction.
III
Theorem 3.2 yields the following characterization of relatively prime numbers:
Corollary 3.18. Integers a1,...,an are relatively prime if and only if there
are integers x1, ..., as” such that alxl +
+ anxn = 1.
Proof. If there are such integers x1, ..., an, then clearly any common divisor of
a1, ...,an divides 1 = a1x1+...+an:z:n and so gcd(a1, ...,an) = 1. The converse
follows directly from theorem 3.2.
III
We can give a slight improvement of the previous corollary (for n = 2) in
which we take care of positivity:
Corollary 3.19. If a, b are relatively prime positive integers, then we can find
positive integers m, n such that am — bn = 1.
72
Chapter 3. GOD and LCM
Proof. Choose 93,3; 6 Z such that art: + by = 1. For all integers t we have
a(:r + bt) — b(at — y) = 1, hence it is enough to show that we can find t such
that x+bt and at— y are positive integers. Simply choose t > max(—sc, y).
3.1.3
III
Inverse modulo n and Gauss’ lemma
The first part of the following fundamental theorem follows straight from
theorem 3.2.
Theorem 3.20. If gcd(a, b) = 1, then we can find an integer 2: such that
am E 1 (mod b). Moreover, any two such integers a: are congruent modulo b.
Proof. As we have already observed, only the second statement needs a proof.
If so, 93’ are two such integers then are E 1 E ax’ (mod b) and so
56' E aaxc' = (ax’)a: E cc
(mod b),
as needed.
III
Remark 3.21. 1) The converse of the previous result also holds, for if an: E 1
(mod b), then we can write ax — 1 = by for some integer y, hence any common
divisor of a and b will divide 1.
2) By the theorem, all numbers a: satisfying aa: E 1 (mod b) give the same
remainder when divided by b. This remainder is called the inverse of a modulo
b and denoted a”1 (mod b).
The previous theorem has many important consequences, which wouldn’t
be easy to prove directly. For instance, it immediately implies the following
result, which is of utmost importance and will be used throughout the book:
Theorem 3.22. (Gauss’ lemma) If a, b,c are integers such that a | bc and
gcd(a, b) = 1, then a | c.
Proof. Let a: be an integer such that ba- E 1 (mod a) (such :1: exists by theorem
3.20). Since he E 0 (mod a) we obtain xbc E 0 (mod a) and so c E 0 (mod a).
The result follows.
El
Let us write Gauss’ lemma in terms of congruences:
3.1.
Bézout’s theorem and Gauss’ lemma
73
Corollary 3.23. If ab E ac (mod n), then b E c (mod W). In particular, if gcd(a,n) = 1, then b E c (mod n).
Proof. Let cl = gcd(a, n) and write a = du,n = do, with gcd(u,v) = 1. Then
ab E ac (mod n) is equivalent to v | u(b — c). By Gauss’ lemma, this is
equivalent to u | b — c, i.e. b E 0 (mod 1)).
El
Another very important result is the following direct consequence of Gauss’
lemma.
Theorem 3.24. Let a, b,c be integers such that a l c, b | c and gcd(a, b) = 1.
Then ab | c. In other words, if an integer is a multiple of two relatively prime
numbers, then it is a multiple of their product.
Proof. We can write c = ad for some integer d. Since b | c and gcd(a, b) = 1,
by Gauss’ lemma we have b | d. Thus ab | ad = c and we are done.
El
Remark 3.25. An immediate induction shows that if an integer is a common
multiple of finitely many pairwise relatively prime integers, then it is a multiple
of their product.
We also mention the following very useful consequence of theorem 3.20.
Corollary 3.26. If an integer a is relatively prime to each of the integers
b1, b2, ..., bn, then it is also relatively prime to b1b2...bn.
Proof. By theorem 3.20 we can find integers xi such that biz; E 1 (mod a).
Then (b1b2...bn) - (x1...acn) E 1 (mod a), hence a and b1...bn are relatively
prime.
E]
The following result would be fairly difficult to prove using only formal
properties of the divisibility relation:
Corollary 3.27. If a,b are integers and a" | b” for some n 2 1, then a | b.
Proof. If a = 0 or b = 0, then the result is immediate, so assume that a, b are
nonzero. Let d = gcd(a, b) and write a = du and b = do for some relatively
prime integers u,u. Then dnu" I dun”, so u“ | 12‘”. By the previous corollary
gcd(u,v") = 1, and since u divides v" (as u | u" | v"), we deduce that u | 1
and so u = i1. Thus a = :lzd and it clearly divides b = do.
III
74
Chapter 3. GOD and LCM
Let us see how the previous theoretical results work in practice.
Example 3.28. (Saint Petersburg) Find all relatively prime positive integers
2:, y such that
2(933 — a2) = y3 — y.
Proof. Write the equation as
2x3 — y3 = 2a: — y
and let 2 = 2x — y.
Since gcd(a:,y) = 1 we have gcd(ac,z) = 1.
Next,
z | 2x — y hence z I 85c3 — y3 and by hypothesis z | 2x3 — 313, thus 2 | 6903.
Since gcd(a:, z) = 1, we have gcd(z, 1:3) = 1 (corollary 3.26) and Gauss’ lemma
yields 2 | 6. We deduce that z e {—1,—2, —3, —6, 1,2,3,6}. Solving in each
case the corresponding system
2m—y=z,
2x3—y3=z
yields the solutions (as, y) E {(1, 1), (4, 5)}
III
Example 3.29. (Erdos-Szekeres) Let n be a positive integer, and let k and m
be positive integers such that 0 < m S k < n. Prove that the numbers (2)
and (:1) are not relatively prime.
Proof. Assume that the numbers (2') and (:1) are relatively prime and note
that
n
k _
n!
k!
(k) ' (m) — k!(n—k)! .m!(k—m)!
_
n!
.
_m!(n—m)!
(n — m)!
_
n
(k—m)!(n—k)!- m
n—m
k—m'
Thus (2) - (71;) is divisible by (1:) and since (2) and (111:) are relatively prime,
it follows that (:1) is divisible by (:1). Thus (:1) 2 (:1) (note that (1;) 75 0, as
0 < m S k). This is impossible, since by hypothesis k < n, thus
(k) =k-(k—1)-...-(k—m+1)
m
m-(m—1)~...-1
3.1.
Bézout’s theorem and Gauss’ lemma
75
m-(m—1)-...-1
m
Example 3.30. Prove that if n, k are positive integers, with k odd, then
1+2+...+n|1k+2k’+...+nk.
Proof. This comes down to n(n+ 1) | 2(1k+2k+...+nk). Since gcd(n, n+1) =
1, it suffices to prove separately that n | 2(1k+...+n’°) and n+1 | 2(1k+...+nk).
But
2(1k +
+nk) = (1k + (n — 1)’“) + (2" + (n — 2)") + + ((n — 1)’“ + 1“) + 2n!“
= (1" + n’“) + (2k + (n — 1)’°) +
+ (nk + 1’“)
and we conclude in both cases using the fact that a + b I ah + b’6 when k: is
odd.
III
Example 3.31. (IMC 2012) Is the set of positive integers n for which n! + 1
divides (201277,)! finite or infinite?
Proof. The solution is very short but very tricky: we will prove that the set
is finite. Write for simplicity 2012 = k. Assume that n! + 1 | (kn)! for some
n. Since n!"’ | (kn)! (this follows by repeated applications of the divisibility
alb! | (a + b)!) and since n! + 1 and n!k are relatively prime, we must have
(kn)!
However,
f(n + 1) _ (kn + 1)(kn + 2)...(kn + k)(n! + 1)
f(n) _
(n + 1)"((n + 1)! + 1)
(kn+k)’°_
n!+1
kk
(n+1)k (n+1)!+1 < Z’
since
nl+1
(n+1)!+1
<1
n’
76
Chapter 3. GOD and LCM
this last inequality being equivalent to n! > n — 1. Thus, if n > kl“, then
f (n + 1) < f (n). Now, if the problem had infinitely many solutions, there
would be an infinite decreasing sequence of positive integers, which is clearly
absurd. Hence the set is finite.
I]
Yet another result that is very useful in practice and follows directly from
the previous ones is:
Theorem 3.32. Let n be an integer greater than 1 and let a be an integer.
Then 0, a, 2a, ..., (n — 1)a is a complete residue system modulo n if and only if
gcd(a, n) = 1.
Proof. Suppose that gcd(a, n) = 1. It suffices to show that the remainders of
0, a, 2a, . . . , (n — 1)a when divided by n are pairwise distinct, as this implies
that they must be a permutation of 0, 1, 2, ..., n — 1. If ia and ja give the same
remainder when divided by n, then n | (i — j)a and by Gauss’ lemma we have
n | i — j, which is impossible if 0 S i aéj < 72..
Suppose now that 0, a, 20., ..., (n — 1)a is a complete residue system modulo
n, in particular there is j 6 {1,2, ...,n — 1} such that ja E 1 (mod n), hence
gcd(a, n) = 1.
III
Here are two illustrations of theorem 3.32.
Example 3.33. (Gauss) Let a,b be relatively prime integers greater than 1.
Prove that
E [Ic—aJ _ (a— 1)a—1)
k=1
b
2
Proof. Writing [co = qkb + rk with 0 g rk < b, we know that r1, ...,rb_1 is a
permutation of 1, ...,b — 1, since gcd(a, b) = 1. Thus
b—1
b—1
b—1
Zka=b-q+2k
k=1
k=1
k=1
and so
f(ak—k)=a_1-b(b_1)=(a_l)(b_1).
k:—1"
big
k=1
bk=1
b
2
2
3.1.
Bézout’s theorem and Gauss’ lemma
Since qk = [k—g‘J , the result follows.
77
III
Example 3.34. (Landau’s identity) Prove that if m, n > 1 are relatively prime
odd integers, then
._ n
m_<m—)(n—>
J—#gl%J—+gl%
Proof. Consider the set A of numbers of the form mm — yn with 1 g x S ”7—1
and 1 S y S mT—l. We will count the number of elements of this set in
two different ways. First, we claim that A has Sm—dgfl elements, which
reduces to checking that the previous numbers are pairwise distinct. But if
mm — yn = mlm — yln then (x— x1)m = (y — y1)n and so 77. | m(a: — .121). Since
gcd(m, n) = 1, we deduce that n | a: — m1 and since 1 S x,a:1 S ”7—1, we must
have :6 = $1 and y = in, proving the claim.
On the other hand, let us see how many nonnegative numbers are in A.
The inequality mm > yn is equivalent to y < ”—m or y < If”?
m._| For a given
a: 6 {1,2, ... ,"—12} we have [
J < "1—2—1 ,thus thennumber ofyn6 {1,2, ..., fig—l}
such that y S—
295—” is [mm]. Summing2over all values of x, we deduce that there
1
are 22-1 L%J nnonnegative numbers in A. A similar argument shows that
there are 2; 1917—71 nonpositive elements in A. We would have a problem if
0 was in A, since it would be counted twice. However, 0 ¢ A, since if mm = yn
then m | yn, then m | y and this is impossible since 1 S y < m. Thus 0 ¢ A
m_-1
"_-l
and so A has Zk=21 [kfij + Zkil [$J elements. Combining this with the
first paragraph yields the desired result.
I]
We end this section with another very useful result, that will be constantly
used when dealing with expressions of the form a” — b”. It is a simple combination of Bézout’s theorem and Gauss’ lemma, but it is remarkably eflicient
in practice.
Proposition 3.35. Let a,b and m,n be positive integers. If gcd(a, b) = 1,
then
gcd(a’m _ bm,
n _ bn) = agcd(m,n) _ bgcd(m,n).
78
Chapter 3. GOD and LCM
Proof. Replacing a, b, m, n by ag°d(m’”), bg°d(m'"), W227? and @2117; respectively, we may assume that gcd(m, n) = 1. Since a E b (mod (1 — b), we have
(1" E bk (mod a — b) for all k 2 1. Hence a — b divides gcd(am — bm, a" — b").
Conversely, let d = gcd(am — bm, a" — b”) and let us prove that d | a — b. We
have am E bm (mod d) and a" E b” (mod d), hence am" E bm’c (mod d) and
a"l E b"l (mod d) for all k,l 2 1. Since gcd(m, n) = 1, Bézout’s lemma (more
precisely corollary 3.19) gives us k,l 2 1 such that km = ln + 1. Hence
0,111+]. =
mk E bmk = bnl+1 E
b ‘ ant
(mOd d),
that is d | a”l(a——b). But since gcd(a, b) = 1, we have gcd(a,, bm) = 1 and hence
gcd(a, am — bm) = 1. Since (1 divides am — b’", we conclude that gcd(a, d) = 1.
Thus using Gauss’ lemma, we obtain d | a — b and the result follows.
III
Corollary 3.36. Let a > b > 0 and m,n be positive integers. If gcd(a, b) = 1,
then am — bm divides a" — bn if and only if m | n.
Note that one implication of this corollary is a direct consequence of the
fact that if n = md, then am — bm divides a” — b” = (am)d — (bm)d. The
other implication can also be proved independently of the previous proposition
(whose proof is rather technical but whose result is stronger). Indeed, suppose
that am — bm | a” —- b” and write n = mg + r for some integers q,r with
0 S 7' < m. Suppose that 1" > 0. Then
a" — b" = amq(a" — b’) + b’"(amq — bmq).
By the first step am — bm | amq — bmq, hence a‘m — bm | am‘1(a" — b"). Since
gcd(a, b) = 1, we have gcd(amq,am — bm) = 1 and using Gauss’ lemma we
obtain a” — b" | or — b’". But this is impossible, since 0 < a" — br < am —— bm
(to see why the inequality 11’" — b’ < am — 6’" holds, write it in the form
ar—l + ctr—2b +
+ b"1 < a, ‘1 +
+ bm—l).
Let’s give a few examples of applications of the previous proposition and
corollary:
Example 3.37. Let n be an integer greater than 1. Find all positive integers
m such that (2" — 1)2 |'2m — 1.
3.1.
Bézout’s theorem and Gauss’ lemma
79
Proof. Let m be a solution of the problem. We have 2" — 1 | 2m — 1, thus
n | m. Write m = km for some positive integer k. Then
(2" — 1)2 | 2"" — 1 = (2“ — 1)(1 + 2‘" + + (2")k-1)
and so
2" — 1 | 1 +2” +
+ (2")k-1.
On the other hand,
1+2”+...+(2")k‘151+1+...+1=k (mod 271—1),
hence we must have 2” — 1 | k: and thus n(2‘” — 1) | m. Conversely, if m = km
with 2” — 1 | k, then the previous computations and congruences show that
(2" — 1)2 | 2m — 1. Thus the solutions of the problem are all multiples of
11(2” — 1).
El
Example 3.38. (Kvant M 1858) Let a and b be positive integers such that
gcd(2a + 1, 2b + 1) = 1.
Find the possible values of gcd(22“+1 + 2"“ + 1, 22b+1 + 2b+1 + 1).
Proof. The key observation is that for all k 2 0
(22k+1 + 2k+1 + 1)(22k+1 _ 2k+1 + 1) = (22k+1 + D2 _ (2k+1)2 = 24k+2 + 1.
Set d = gcd(22a+1 + 20+1 + 1, 225“ + 2H1 + 1). Then d divides 240+2 + 1 and
hence also 28“+4 — 1. Analogously d divides 28b+4 — 1. Using the hypothesis,
we obtain
n(28a+4 _ 1, 28b+4 _ 1) = 2gcd(8a+4,8b+4) _ 1 = 24 _ 1 = 15
and d is a divisor of 15. Note that 3 does not divide (1 since 22“+1 + 2“+1 + 1 E
2“+1 (mod 3) is not divisible by 3. Thus either d = 1 or d = 5 and both cases
are possible. Indeed, to achieve gcd(22a+1+2a+1+1, 22b+1+2b+1+1) = 1 simply
take a = 1 and b = 2, and to achieve gcd(22“+1 +2“+1 +1, 22b+1 +2b+1 + 1) = 5
takea=3andb=4.
III
80
Chapter 3. GOD and LCM
3.2
Applications to diophantine equations and
approximations
The goal of this section is to illustrate the power of the techniques and
results established in the previous section, by applying them to the resolution
of certain classical diophantine equations. Along the way we will discuss the
important topic of approximations of real numbers with rational numbers and
its arithmetic applications.
3.2.1
Linear diophantine equations
The simplest diophantine equations are the linear ones.
equations of the form
These are the
012:1 + u. + anmn = b,
where 0.1, ..., an, b are given integers. For these equations we have a complete
theory, which describes when these equations have solutions as well as methods
of finding all solutions.
Theorem 3.39. Let a1, ...,amb be integers. The equation
(11221 +
+ anxn = b
has integral solutions if and only if gcd(a1, . . . , a...) | b.
Proof. Let d = gcd(a1, ..., on). If d does not divide b, then clearly the equation
has no integral solution. Assume that d | b. By Bézout’s theorem there are
integers y1,..., yn such that
d = null +
+ any“.
But then setting 3:.- = g - yi yields an integral solution of the equation.
[I
How can we find all solutions of the previous equation? By induction on
n we are reduced to discussing the case n = 2, which is dealt with in the next
theorem.
3.2. Applications to diophantine equations and approximations
81
Theorem 3.40. Let a, b,c be integers with (a, b) aé (0,0). Suppose that the
equation ax + by = c has integral solutions (which is equivalent to gcd(a, b) | c
by the previous theorem) and let ($0,310) be a solution. Then the solutions of
the equation are given by
b
a
(”’° + gcd(a, b)t’y° ' gcd(a, b) t) ’
with t E Z.
Proof. One easily checks that ($0 + Wtw — Wt) is a solution of
the equation for all integers t. Assume now that (x, y) is a solution of the
equation. Subtracting the relations as: + by = c and are + byo = c yields
a(:c — x0) = b(yo - y). Writing a = du and b = du, where d = gcd(a, b)
and gcd(u,v) = 1, we obtain u(a3 — x0) = v(yo — y). Since it | v(yo — y) and
gcd(u, u) = 1, by Gauss’ lemma we can find an integer t such that yo — y = ut.
Then :3 — x0 = ut, hence a: = x0 + wt and y = yo — at. The proof is therefore
finished.
[I
Example 3.41. Solve in integers the linear diophantine equations
a) 15:): + 84y = 39.
b) 3w+4y+52=6.
Proof. a) The equation is equivalent to 5:1: + 28y = 13. A solution is y = 1,
w = —3. All solutions are of the form a: = —3 + 28t, y = 1 — 5t, t E Z, by
theorem 3.40.
b) The equation can be written as 3a: + 4y = 6 — 52. Since gcd(3,4) = 1
solutions exist for all 2, hence we can set 2 = s for any 3 E Z. A solution of
3x+4y = 1 is :1: = —1,y = 1. Soasolution of3x+4y = 6—53 is 930 = 53—6,
yo = 6 — 53. Hence (using again theorem 3.40) all solutions are
a:=5s—6+4t
y=6—5s—3t
2:8
El
Chapter 3. GOD and LCM
82
Example 3.42. (Sylvester 1884) Let a, b > 1 be relatively prime integers. Then
ab — a — b is the largest integer that cannot be written as am + by, with a3,y
nonnegative integers.
Proof. Suppose that ab — a — b = ax + by for some nonnegative integers x, y.
Then —b E by (mod (1) and since gcd(a, b) = 1, we have y E —1 (mod (1).
Similarly a: E —1 (mod b). We deduce that a: 2 b — 1 and y 2 a — 1, hence
ab—a—b=am+byZa(b—1)+b(a—1)=2ab—a—b,
clearly impossible.
It remains to prove that any integer n > ab — a — b can be written in the
desired form. Since gcd(a, b) = 1, there are integers u, U such that au+bv = 77..
Moreover, by replacing u by u + bt and v by v — at for some integer t, we may
suppose that 0 S u < b. Then
ab—a—b+1 Sn=au+bv S a(b—1)+bv,
hence v 2 O. The result follows.
E]
Example 3.43. Let a1, ...,an be positive integers and let gcd(a1, ...,an) = k.
Then all sufliciently large multiples N of k can be written a1x1 +
+ anxn
with x1, ..., an positive integers.
Proof. We will prove the statement by induction, the case n = 1 being clear.
Assume that the result holds for n-1 and let us prove it for 72. Fix a1, ..., an > 0
and let k = gcd(a1, ...,an) and l = gcd(a.1,...,a.n_1). Then k = gcd(l,an) by
theorem 3.6. Let N > lan be a multiple of k. Theorem 3.2 shows the existence
of an integer acn such that N E xnan (mod I). Adding a large multiple of l
to 1:”, we may assume that an > 0. Choose the smallest such 33,, > O and
observe that 11:” S l since if 513,, > l then run — l is a smaller positive solution
of the previous congruence. Choose M such that any multiple of l greater
than M can be written $1111 + +xn_1an_1 with positive integers x1, ..., :cn_1
(this is possible by the inductive hypothesis). Then for any N > M + anl
which is a multiple of k, N — anxn is a multiple of l greater than or equal to
N — anl > M, thus we can write N —— anrrn = mm +
+ :L'n_1an_1 and so
N = (112:1 + + any)” with x1, ..., 23,, > 0. This finishes the inductive step and
solves the problem.
El
3.2. Applications to diophantine equations and approximations
83
Remark 3.44. If a1, ..., an are relatively prime positive integers, let g(a1, ..., an)
be the greatest positive integer N for which the equation
a1m1+~~+anxn=N
has no solutions in nonnegative integers. Then g(a1, ...,an) is well-defined
by example 3.43. The problem of determining g(a1, . . . ,an) is known as the
Frobenius coin problem and it is still open except for n = 2 (in which case
example 3.42 shows that g(a1,a2) = a1a2 — a1 — a2).
Example 3.45. (Iran 2002) Let S be a set of positive integers such that a+b E S
whenever a, b E S. Prove that there are positive integers k and N such that
foralln>NwehavenESifandonlyifk|n.
Proof. It is clear that S is infinite. Let a1 < a2 <
be the elements of S
and consider the sequence 9,, = gcd(a1, ....,an) Clearly 9,, 2 gn+1 for all n,
thus the sequence (9707,21 is eventually constant, say with value It. Clearly
k divides all elements of S. It suffices therefore to prove that all sufficiently
large multiples of k are in S. Since S is stable under addition, S contains
alxl +
+ anxn for any a1, ...,an E S and $1, ...,:cn positive integers. The
result follows then from example 3.43.
El
3.2.2
Pythagorean triples
We want to discuss now one of the most classical and important diophantine equations, namely
:62 + 312 = .22.
Triples of integers (56,31, 2) satisfying this equation are called Pythagorean.
Finding Pythagorean triples is equivalent to finding right-angled triangles with
integer side-lengths. In order to describe all solutions of this equation, we will
need the following result, which turns out to be extremely useful in the study
of diophantine equations.
Theorem 3.46. Leta, b be relatively prime positive integers such that ab = c"
for some positive integer c. Then a and b are both nth powers of positive
integers.
84
Chapter 3. GOD and LCM
Proof. Let d = gcd(a,c) and write a. = du and c = do for relatively prime
positive integers u,v. Then ub = dn'lv". Since gcd(u,v) = 1, we have
gcd(u,v”) = 1 (corollary 3.26). Since u I (in—1v", Gauss’ lemma yields 11. |
d”‘1 and so I)" = #rb is a multiple of b. On the other hand 12" | ub and
gcd(v", u) = 1, thus using again Gauss’ lemma we obtain 1)" | b. We conclude
that b = v” and u = d”_1, thus a = d”. The result follows.
El
Before dealing with the resolution of the equation 2:2 + y2 = 22 we would
like to illustrate the previous theorem with a few interesting examples.
Example 3.47. Prove that the product of three consecutive positive integers is
never a perfect power.
Proof. Write the three consecutive integers n — 1, n, n + 1, and suppose that
(n — 1)n(n + 1) = ad, with a,d > 1.
Then n(n2 — 1) = a“l and since gcd(n, n2 — 1) = 1, it follows that both n and
n2 — 1 are dth powers. Say n = ad and n2 — 1 = ed, for some integers c, e > 1.
Then c2‘l—ed = 1, which can also be written as (c2 —e)(c2(d_1) +...+ed_1) = 1.
This is clearly impossible, since 02 — e 2 1 and amt—1) +
+e‘i_1 Z d > 1.
El
Example 3.48. (IMO Shortlist 2007) Let b,n be integers greater than 1 such
that for all 16 > 1 one can find an integer a. such that k | b — a”. Prove that b
is the nth power of an integer.
Proof. Choosing k = b2, it follows that there are integers a and c such that
b — a" = cb2. This can be written as b(1 — cb) = a". Thus b and 1 — cb
are positive numbers, relatively prime and whose product is an nth power.
It follows that both are nth powers. In particular, b is an nth power, as
desired.
III
Example 3.49. (Vietnam 2013) Find all integers a: such that 312?? is a perfect
square.
Proof. Clearly a: = —1 and a; = 0 are solutions, and we will prove that they
are the only solutions of the problem. If a; < —1, then the fraction is negative
3.2. AppliCations to diophantine equations and approximations
85
and cannot be a perfect square, so we need only consider :1: > 1. Since
$1000 _ 1
{1:500 _ 1
x—l
:3—1
—=_.
500
(:1:
+1)
and gcd ($_500
1.73500 + 1) | 2, and since $500 + 1 is not a squarel, we deduce
m— 1 ,.’L‘
that x500 + 1 = 2a2 and %
= 2v2 for some integers a, v > 1. Thus
50 _ 1 $250 + 1
— - — = v2.
at — 1
2
Note that 4 does not divide $250 + 1 (since 4 does not divide u2 + 1 for any
integer n), hence ”52:01] anid £311 are relatively prime and so each of them
must be a square. But thena’l——
2:1'21 °(w125+1) 1s a square and x125+1 and “—12—:I—1
are relatively prime (sincewz_
2:1 1is odd, because a: is odd). Thus 1:125 + 1 is
a square, say 27125 + 1 = 22. Then (z — 1)(z + 1) = x125 and z — 1,2 + 1 are
relatively prime (since 2 is even), thus 2 — 1 and z + 1 are both the 125th
power of some positive integers p, q. But then q125 — p125 = 2 and so q — p = 1
or q —p = 2. In both case it is easy to see that we cannot have q125 —p125 = 2.
Thus the only solution is x = 0.
III
We are now ready to describe all Pythagorean triples.
Theorem 3.50. The solutions in positive integers of the equation
x2+y2=22
are given by
a: = d(m2 — n2), y = 2dmn, z = (m2 + n2)d
or
a: = 2dmn, y = (m2 — n2)d, z = (m2 + n2)d,
where m > n > 0 are relatively prime and of difl'erent parity, and where d > 0.
1Since $500 + 1 lies strictly between the consecutive squares 150° and ($250 + 1)2.
86
Chapter 3. GOD and LCM
Proof. It is not diflicult to check that the given triples are solutions of the
equation: this reduces to the equality
(m2 — mg)2 + (2mn)2= (m2 + n2)2,
which is easy to check.
Conversely, let (:13, y, 2) be a solution of the equation with m,y, z > 0 and
let (1 = gcd(:c, 3;), so that a: = da and y = db with a, b relatively prime positive
integers. Moreover,
d2(a2 + b2) = 22
hence d2 | 22 and so d | 2. Say 2 = do for some positive integer c, then
a2 + b2 = 02.
Since a, b are relatively prime, the previous relation implies that a, b, c are
pairwise relatively prime. Also, note that c is odd: otherwise, since a, b are
relatively prime they must be both odd but then c2 = a,2 + b2 E 2 (mod 4),
impossible. Thus a and b have different parities. By symmetry, we may assume
that a is odd and b is even. Rewrite the equality a2 + b2 = 02 as
(b)2_c—ac+a
2
_
2
2
and observe that since gcd(a, c)— 1 we also havecgcd (91-2“, Lg“ =1 (note that
the sum and difference of the numbers 9—42” an —2—c“ are c and a respectively).
We deduce that % and ”+7“ are both perfect squares, say
c—a_
2
c+a_
2
2 ‘n’ 2 _
Note that m > n are relatively prime-positive integers of different parities
(since m2 + n2 = c is odd). Also b = 2mn and
a: = d(m2 — n2),
as desired.
y = dn,
z = d(m2 + n2),
El
3.2. Applications to diophantine equations and approximations
87
One of the most famous problems in number theory is the resolution of
Fermat’s equation
$11. + yn = Zn-
We have just seen how to solve it for n = 2. The general case was solved by
Wiles in 1994 (more than 350 years after the problem was posed), who proved
that for n > 2 there are no nontrivial solutions. The proof of this deep result
is one of the most spectacular applications of the interplay between number
theory and algebraic geometry (needless to say, the proof goes far beyond the
scope of this modest book). Already the case n = 3 is quite challenging (even
though in this case there is an elementary, though fairly technical proof). The
next theorem deals with the case n = 4 and establishes a stronger result,
using Fermat’s method of infinite descent (we have already encountered some
applications of this method in the first chapter).
Theorem 3.51. (Fermat) The equations .734 + y4 = 22 and x4 — y4 = 22 have
no nontrivial {i.e. with myz 75 0) integral solutions.
Proof. We only give the proof for the equation x4+y4 = 22, the argument being
similar for the other one. We may restrict ourselves to solutions at, y, z in which
2:, y, z 2 0 (since changing each of x, y, 2 into its absolute value does not change
the fact that they form a nontrivial solution of the equation). Assume the
contrary and consider a nontrivial solution ($0,110, 20) with smallest possible
value of 20. Then necessarily gcd(zco, yo) = 1 (otherwise letting d = gcd(a'o, yo),
d2 must divide z and so (if, 93°, 3g) gives a nontrivial solution with smaller
value of z, contradicting the minimality of 20). Also, one of $0,310 must be
even (otherwise we obtain 22 E 2 (mod 4), a contradiction), say without loss
of generality yo is even. Using theorem 3.50 we may find relatively prime
positive integers a, b such that
$3 = a2 — b2, y?) = 2ab, 20 = a2 +b2.
Since :33 = a2 — b2, 11:0 is odd (as yo is even and gcd(xo,yo) = 1) and
gcd(a, b) = 1, we deduce, using again theorem 3.50, the existence of relatively
prime positive integers c, d such that
x0=c2—d2, b=2cd, a=c2+d2.
Chapter 3. GOD and LCM
88
It follows that
cd(c2 +d2) = a; = (E)?
2
Since 6, d, 02 + d2 are pairwise relatively prime, we conclude that each of them
must be a perfect square, say c = 13, d = v2 and 02 + d2 = 102. Then
11,4+'u4‘=w2
and so (u, v, w) is a nontrivial solution. By minimality of 20, this forces 11) 2 20.
But this is certainly impossible, since
20 =a2+b2 > a2 = (c2+d2)2 > 62+d2 =u4+v4=w2.
El
The result follows.
Remark 3.52.
1. On the other hand, the equation
x4 + y4 + 24 = t4
has nontrivial solutions: a famous example due to Elkies (1988) is
26824404 + 153656394 + 187967604 = 206156734.
Another example, found by Eye is
958004 + 2175194 + 4145604 = 4224814.
The equation
fi+f+i+fi=fi
also has nontrivial solutions, for instance Lander and Parkin (1967)
found the solution
1445 = 275 + 845 + 1105 + 1335.
These examples disprove a conjecture of Euler, namely that for n > 2
the equation
a?+ag+... +GZ_1 = b”
has no solutions in positive integers (this turns out to be true for n = 3,
as we have already mentioned).
3.2. Applications to diophantine equations and approximations
89
2. With exactly the same arguments one can prove that the equation x4 —
y4 = 22 has no nontrivial integral solutions. We deduce immediately
that the equation x4 + y4 = 22.2 has only the obvious integral solutions,
by writing it in the form
24—(xy)4=(
x4
4 2
2y).
3. In general, if d is a positive integer, then one can prove that the equa-
tion x4 — y4 = clz2 either has no nontrivial solutions or infinitely many
solutions in relatively prime positive integers.
Example 3.53. For which integers x, y do we have x4 —— 21;2 = 1?
Proof. Writing the equation as
x4 +y4 = (y2 + D2
and applying Fermat’s theorem above we obtain y = 0 and then x = :l:1.
III
Example 3.54. Find all integers x, y such that 8x4 + 1 = y2.
Proof. Suppose that (x, y) is a solution. Replacing x,y with their absolute
values, we may assume that x, y 2 0. If y = 1, we obtain the solution (0,1).
Suppose that y > 1. Clearly y is odd, say 3; = 2z+1 for some positive integer 2.
Then z(z+ 1) = 2x4 and since gcd(z, z+ 1) = 1, we deduce that either 2 = 2a4
and z+1 = b4 for some positive integers a, b, or z = a4 and 2+1 = 2b4 for some
positive integers a, b. In the first case we obtain b4 — 2a4 = 1, contradicting
the result established in the previous example. In the second case we obtain
a4 + 1 = 2b4, which can be written as
4
4
“—1
a+<
2)
2
8
=b.
Since a, b 2 1 and the equation x4 + y2 = z4 is impossible in positive integers,
Since the equation x4 + 22 = y4 has only trivial solutions and since we deduce
that a = 1 and b = 1, thus 2 = 1 and x = 1, y = 3. We conclude that the only
solutions are (x,y) = (0, :|:1), (21:1, :|:3).
El
90
Chapter 3. GOD and LCM
Example 3.55. Solve in integers the equation
3:4 + (11:2 + 1)2 = 312.
Proof. Again, we may assume that :I:,y 2 0. If a: = 0, we obtain y = 1, so
assume that :I: > 0. Then $2,332 + 1 and y form a Pythagorean triple with
gcd(:c2, :32 + 1) = 1 and moreover x2 is even (if a: is odd, then the left-hand side
is congruent to 5 mod 8, while the right—hand side is congruent to 1 mod 8).
Thus there are relatively prime positive integers m > n of different parity such
that m2 = 2mn and m2+1 = m2 —n2. Letting x = 2a, we obtain mn = 2a.2 and
m2 — n2 = 4a2 + 1. Since m, n have different parity and m2 — n2 E 1 (mod 4),
m must be odd and 17. must be even. Since mn = 2a2 and gcd(m,n) = 1, we
conclude that n = 2n2 and m = 122 for some integers u,v > 0, and a = uv.
We conclude that
v4 — 4244 = 41¢s + 1,
which can also be written as
('u2 — 211.2)2 — 811.4 = 1.
By the previous example we obtain (since u > O) u = 1 and v2 — 2n2 = :|:3.
This is however impossible, thus the only solution is (0, :|:1).
El
Example 3.56. Solve in integers the equation
(21:2 — 1)2 = 2y2 — 1.
Proof. We may assume that 13,3; 2 0. Clearly y 2 1 and if y = 1 we obtain
ac = 0 or :1: = 1. Assume from now on that y > 1, so that a: > 1.
Write the equation as
(9:2)2 +(:1:2 — 1)2 = 312.
We discuss two cases, according to the parity of 51:.
Suppose that a: is odd, then 1:2 = a2 — b2, 51:2 — 1 = 2a.b and y = a2 + b2
for some a > b > 0 relatively prime and of different parity. Write a — b = 11.2
and a + b = v2 with 0 < u < v relatively prime and odd (note that such u,v
3.2. Applications to diophantine equations and approximations
91
exist since (a — b)(a + b) = x2 and gcd(a — b,a + b) = 1). Then a: = no and
the equation :32 — 1 = 2ab becomes
2
(W)
_1=2. 'u,2+v2
vz—u2
2
2
or
211,202 — 2 = v4 - U4.
This is equivalent to (v2 — 'a2)2 = 2(u4 — 1) and writing '02 — u2 = 27.0 yields
u4 — 2102 = 1. Using example 3.53 we obtain a contradiction.
Suppose now that a: is even. Similar arguments yield the existence of a > b > O
relatively prime, of different parity such that 1:2 = 2ab, 11:2 — 1 = a2 — b2 and
y = a2 + b2. Since a2 — b2 = x2 — 1 E —1 (mod 4), we deduce that a is even
and b is odd. Since 2ab = x2 is a square, a is even, b is odd and gcd(a, b) = 1,
we obtain a = 2m2, b = n2 and a: = 2mn for some positive integers m, n,
which are relatively prime. Then the equation (1:2 — 1 = a2 — b2 becomes
4m2n2 — 1 = 4m4 — 12.4.
This can be rewritten as
(n2 +2m2)2 = 8m4 + 1.
Using example 3.54 we obtain m = 1 and n2 + 2m2 = 3, thus m = n = 1. But
thena=2,b=1,a:=2andy=5.
Weconclude that the solutions are (0,':|:1), (:|:1, :|:1), (:|:2, :|:5).
El
Example 3.57. Find all integers x, y such that
1+x+x2+sc3=y2.
Proof. Write the equation as (1 + :13)(1 + x2) = y2, which makes it clear that
a: 2 —1. If a: = —1 we obtain the solution (—1,0), and if x = 0 we obtain the
solutions (0, :|:1). If a: = 1 we obtain the solutions (1, :|:2).
Assume from now on that :c > 1 and, without loss of generality, that y 2 0
(and so y_ > 2). If a: is even, then gcd(1 + 56,1 + m2) = 1 and we deduce that
92
Chapter 3. GOD and LCM
1 +51: and 1 +.'r2 are perfect square, which is clearly impossible. Thus a: is odd,
and then gcd(1 + as, 1 +332) = 2. We deduce that 1 +3: = 2a2 and 1 +132 = 2b2
for some a, b 2 1, and y = 2ab. But then
(2.12 — 1)2 = 2b2 — 1.
Using the previous example we obtain a = 2 and b = 5.
Butthenx=2a2—1=7andy=20.
We conclude that the solutions of the problem are
(—1,0),(0,:|:1),(1,:|:2),(7, 120).
m
Example 3.58. (Bulgaria 1998) Prove that the equation 5623/2 = 22 (z2 —-a:2 —y2)
has no solutions in positive integers.
Proof. Assume the contrary and let a = x2 + y2 and b = 2223/. Then
a2 _ b2 = ($2 _ y2)2
and
a2 + b2 = m4 + 2/4 + 6¢2y2.
On the other hand, since the equation (2.2)2 — 22a —- % has integer solutions,
we deduce that its discriminant a2 + b2 is a perfect square. Thus a2 — b2 and
a2 + b2 are both squares and so a4 — b4 = t2 for some integer t. Since a, b > 0,
we deduce that a = b and so :3 = y. But then (22 — x2)2 = 2934, contradicting
the fact that x/i is irrational (see example 3.62 for a proof of a more general
result).
El
Remark 3.59. The proof shows that already the equation x2312 = z(z — x2 — 312)
has no solutions in positive integers.
3.2.3
The rational root theorem
We will discuss now another application of Gauss’ lemma, the rational root
theorem. This theorem bounds the denominators of the possible rational zeros
of a polynomial with integer coefiicients. One important consequence is that
any rational root of a mom'c polynomial with integer coefficients must be an
integer.
3.2. Applications to diophantine equations and approximations
Theorem 3.60. (the rational root theorem) Let f (X) = anX” +
93
+ a0 be a
polynomial with integer coefficients and an aé 0. If :1: = g (with p, q relatively
prime integers) is a rational root of f, then q | an.
Proof. Multiplying the equality f (1:) = 0 by q” yields
anp” + an_1p"‘1q +
+ aoq” = 0-
All terms in the sum except the first one are clearly multiples of q. Thus
q | anp". On the other hand gcd(q, p) = 1, thus gcd(q,p”) = 1 and using
Gauss’ lemma we conclude that q | an, as desired.
El
Corollary 3.61. Let f be a manic polynomial (i.e. the leading coefficient of
f is 1) with integer coefi‘icients. Any rational root of f is an integer.
Example 3.62. Let n be a positive integer and let d > 1 be an integer. Prove
that if {Vi—7, is a rational number, then it is an integer.
Proof. Let a: = {/5 and observe that a: is a rational root of the monic polynomial with integer coefficients Xd — n. Thus :3 must be an integer, by corollary
3.61.
III
In particular, if a, b,c are integers with a aé 0 and if the equation axz +
bx + c = 0 has a rational solution, then the discriminant A = b2 — 4ac must
be a perfect square. Indeed, x/K = |2ax + b| is rational and we conclude it
is an integer using the previous example. Here is a nice application of this
observation.
Example 3.63. (Kvant M 1740) Let a, b, c be positive integers such that
a2+b2+02 = (a—b)2+(b—c)2+(c—a)2.
Prove that ab, bc, co and ab + be + co are all perfect squares.
Proof. We can rewrite the given relation as
a2+b2+c2=2(ab+bc+ca).
92
Chapter 3. GOD and LCM
1 +1: and 1 +x2 are perfect square, which is clearly impossible. Thus a: is odd,
and then gcd(1 +513, 1 +5132) = 2. We deduce that 1 +3: = 2a2 and 1 +1122 = 2b2
for some a, b 2 1, and y = 2ab. But then
(2a2 — 1)2 = 2b2 — 1.
Using the previous example we obtain a = 2 and b = 5.
Butthenx=2a2—1=7andy=20.
We conclude that the solutions of the problem are
(—1, 0), (0, :|:1), (1, :|:2), (7, $20).
El
Example 3.58. (Bulgaria 1998) Prove that the equation x2312 = 22 (22 —a:2 —y2)
has no solutions in positive integers.
Proof. Assume the contrary and let a = x2 + y2 and b = 29:14. Then
a2 _ b2 = (1‘2 _ y2)2
and
a2 + b2 = x4 + y4 + 6'x2y2.
On the other hand, since the equation (7.2)2 — 22a — g has integer solutions,
we deduce that its discriminant a2 + b2 is a perfect square. Thus a2 — b2 and
a2 + b2 are both squares and so a4 — b4 = t2 for some integer t. Since a, b > 0,
we deduce that a = b and so a: = y. But then (22 — 2:2)2 = 2:34, contradicting
the fact that \/2_ is irrational (see example 3.62 for a proof of a more general
result).
III
Remark 3.59. The proof shows that already the equation x2112 = 2(2 — (1:2 — yz)
has no solutions in positive integers.
3.2.3
The rational root theorem
We will discuss now another application of Gauss’ lemma, the rational root
theorem. This theorem bounds the denominators of the possible rational zeros
of a polynomial with integer coefficients. One important consequence is that
any rational root of a monic polynomial with integer coefficients must be an
integer.
3.2. Applications to diophantine equations and approximations
Theorem 3.60. {the rational root theorem) Let f(X) = anX" +
93
+ a0 be a
polynomial with integer coefi‘icients and an aé 0. If x = 5 (with p, q relatively
prime integers) is a rational root of f, then q | an.
Proof. Multiplying the equality f (x) = 0 by q” yields
anp" + an—lp""1q +
+ aoq” = 0-
All terms in the sum except the first one are clearly multiples of q. Thus
q | anp”. On the other hand gcd(q, p) = 1, thus gcd(q,p") = 1 and using
Gauss’ lemma we conclude that q | an, as desired.
III
Corollary 3.61. Let f be a manic polynomial (i e. the leading coefficient of
f is 1) with integer coefficients. Any rational root of f is an integer.
Example 3.62. Let n be a positive integer and let d > 1 be an integer. Prove
that if {75 is a rational number, then it is an integer.
Proof. Let x = {1/5 and observe that x is a rational root of the monic polynomial with integer coefl‘icients X‘1 — n. Thus x must be an integer, by corollary
3.61.
El
In particular, if a, b, c are integers with a aé O and if the equation ax2 +
bx + c = 0 has a rational solution, then the discriminant A = b2 — 4ac must
be a perfect square. Indeed, x/K = |2ax + bl is rational and we conclude it
is an integer using the previous example. Here is a nice application of this
observation.
Example 3.63. (Kvant M 1740) Let a, b, c be positive integers such that
a2+b2+02 = (a—b)2+ (b—c)2+(c—a)2.
Prove that ab, bc, ca and ab + be + ca are all perfect squares.
Proof. We can rewrite the given relation as
a2+b2+c2=2(ab+bc+ca).
94
Chapter 3. GOD and LCM
Considering this as a quadratic equation in a, the discussion preceding the
problem shows that the discriminant A = 16bc must be a perfect square. We
conclude that be is a perfect square and by symmetry we also obtain that ab
and ac are perfect squares. Writing bc = m2 for some integer x, we obtain
a= b+c:l:2:r and so b+c=a+€-2x withe 6 {—1,1}. But then
ab+bc+ca=a32+a(b+c) =x2+a(a+2s-x) = (a+a-a:)2,
finishing the proof.
III
The following exercise refines the rational root theorem.
Example 3.64. Let f be a polynomial with integer coefficients and let a: = g
be a rational root of f, with p, q relatively prime integers. Then we can find
a polynomial g with integer coefficients such that f(X) = (qX — p)g(X).
Proof. Write f(X) = anX" + an_1X"_1 +
form g(X) = bn_1X"‘1 +
+ a0 and let us look for g of the
+ be. The equality f(X) = (qX —p)g(X) reduces
(after looking at the coefficient of Xj on both sides for all j) to the system of
equations
‘PbO = 0'0) q _Pb1 = 0,1, "~aqbn—2 ‘Pb —1 = an—la qb‘n—l = an-
Solving successively we obtain
bo _ -9 b1 _ _qa.H—_pal
—
p
,
—
p2
,IIO,
b _ _q"‘1ao +pqn‘2a1 + +pn‘1an_1 _ 91
”—1 —
p"
_' q '
Thus we need to prove that all these expressions are integers. Note that the
rational root theorem is precisely the statement that bn_1 is an integer. In
general, we need to show that p"+1 divides qkao+q_1a1 + +pkak. However
we know that
anp" + an—ip””1q + + ak+110k+1q”"°”1 + akpkqn‘k + + aoq” = 0.
We deduce that p""“1 divides akpkqn_k +
+ aoq" = q"_k(akpk +
+ aoqk).
Since pk+1 and qn_k are relatively prime, we deduce that pk'l'1 divides akp’“ +
+ aoqk, as needed.
El
3.2. Applications to diophantine equations and approximations
95
Here is a nice application of the rational root theorem. Assume that a, b
are rational numbers such that a + b and ab are integers. We claim that a
and b are actually integers. Indeed, a and b are roots of (X — a) (X — b) =
X2 — (a + b)X + ab, which is a monic polynomial with integer coeflicients,
by assumption. Using the previous corollary, we deduce that a and b must
be integers. A similar argument shows that if a, b, c are rational numbers and
a + b + c, ab + be + ca and abc are all integers, then a, b, c are all integers. This
kind of result is very useful in many contexts, and can lead to quite surprising
results.
Example 3.65. Find all positive integers a, b, c such that %+ % +§ and %+ g +%
are both integers.
Proof. Consider the polynomial with roots %,%,5
f<x>=<x-%>-<X—2>-<x—:>.
A brutal expansion shows that
_3_222
222)_
c X 1
(b+c+a)X2 +(a+b+
f(X)—X
and so (a, b, c) is a solution of the problem if and only if f has integer coefficients. Consider such (a, b, c) and note that f is also monic and has rational
roots %, g, 5. By the rational root theorem, these roots must be integers, thus
%, g, g are positive integers. Since their product is 1, they all must be 1 and
so a = b = 0. Conversely, if a = b = c then obviously (a, b, c) is a solution of
the problem.
III
Example 3.66. (USAMO 2009) Let 31,52,33, . .. be an infinite, nonconstant
sequence of rational numbers.
Suppose that t1, t2, t3, . . . is also an infinite, nonconstant sequence of rational
numbers with the property that (s,- — 3j)(ti — tj) is an integer for all i and
j. Prove that there is a nonzero rational number i" such that (s, — sj)?~ and
(t,- — tj)/r are integers for all i and j.
96
Chapter 3. GOD and LCM
Proof. By working with the sequence 0, 52 — 31, 33 — 31,
instead of 51, $2, ...,
we may assume that 31 = 0. Similarly, we may assume that t1 = 0. In
particular sit,- is an integer for all 2', thanks to the assumption of the problem.
But then (s,- — sj)(t,- — tj) — (sit, + sjtj) must be an integer, i.e. sitj + sjti is
an integer for all 2', j. Fix 2', j and note that (Sitj) - (Sjti) is an integer, since it
equals (siti) - (Sjtj). Since the sum and product of the rational numbers sit,and sjti are integers, both these rational numbers must be integers. Thus sit]is an integer for all 2', j. By choosing i such that s, aé 0, we see in particular
that there is a nonzero integer N such that Ntj is an integer for all j. Define
l
r = N gcd(Nt1,Nt2, ....)
By Bézout’s theorem (note that gcd(Nt1, Nt2, ...) is actually the god of finitely
many of the Ntj ’s) 7' is a linear combination with integer coefficients of t1, t2,
(and only finitely many of the coeflicients will be nonzero). Since Sitj is an
integer for all i, j, we deduce that rs,- is an integer for all 2', thus (3,- — sj)r is
an integer for all i, j. Finally, it is clear by construction that
t, —t,~ _
'r
Nt, —Nt,-
_ gcd(Nt1,Nt2,...)
is an integer for all 2', j.
3.2.4
III
Farey fractions and Pell’s equation
In this subsection we start the study of two fundamental diophantine equations
3:2 + y2 = n
and
a: 2—ny2=1,
where n is a given positive integer. Note that the first equation clearly has
finitely many solutions since |a:| and |y| cannot exceed W We will prove that
the equation 932 + y2 = n has as many solutions as the congruence 22 E —
(mod n). We will see in later chapters how to find the number of solutions of
this congruence (once enough theory is introduced, this will become a straightforward exercise, while the problem of giving a closed formula for the number
of solutions of the equation x2 + y2 = n is definitely not easy). We will also
3.2. Applications to diophantine equations and approximations
97
prove that if n is not a perfect square, then x2 — 11.312 = 1 (known as Pell’s
equation) has infinitely many solutions and that if one knows the smallest
solution, then one can obtain all other solutions by a simple recipe. In order
to prove all these results, we will introduce and study a very beautiful object:
Farey sequences.
Let n > 0 be an integer. Consider all fractions (in lowest form) whose
(positive) denominator does not exceed 17., in other words all rational numbers
of the form % with a, b relatively prime integers and 0 < b S n. Arrange these
fractions in increasing order and call the resulting sequence the Farey sequence
of order n.
The key property of Farey sequences is then:
Theorem 3.67. Let % and %; be consecutive terms in the Farey sequence of
order n. Then
b+b’ 2n+1
and ba’——ab’=:l:1.
Proof. We may assume that 3% < ‘37,. We will actually identify the fraction :7,
as follows. Consider two integers 117,31 such that
bx—ay=1
and
—b<y—n$0.
Note that such integers exist: by theorem 3.20 the congruence ay E —1
(mod b) has at least one solution y in the set {n,n — 1, ...,n — b + 1} (which
is a complete residue system modulo b). Note that since by definition b S n
andy>n—b,wehavey>0.
We prove now that ‘ffi = g. Suppose that this is not the case. Since % and
{‘7' are consecutive in the Farey sequence of order n and since 5 is also a term
G‘IQ
@IR
of this sequence (as clearly gcd(a:,y) = 1 and 0 < y g n) and
+i>2
byb’
‘QIR
we deduce that g > %,’-, hence
1’
b’ _
b’.'r:—a’y> 1
b’y
_ b’y
98
Chapter 3. GCD and LCM
A similar argument yields
L51
b’
th
us
b
bb”
111
1+1bb’
by_y
b‘b’y
which gives b’ 2 y+b > n, a contradiction with the fact that ‘37, is in the Farey
sequence of order n.
Thanks to the previous paragraph we know that “—1 = g and so b’a; = a’y.
We deduce from Gauss’ lemma that b’ = y and then a’ = 9:. Taking into
account the choice of as, y, we conclude that
a’b—ab’=ba:—ay=1 and b+b’=b+y>n.
The result follows.
El
A simple but very important consequence of the previous theorem is the
following approximation result:
Corollary 3.68. If a: is a real number and n is a positive integer, then we
can find relatively prime integers a, b such that 0 < b S n and
1
a <_.
__
"7 b —b(n+1)
Proof. Let f1 < f2 <. .< fd be the terms of the Farey sequence of order n
that belong to the closed interval [3: — 1, a: + 1]. If f1: 4 with gcd(a,, b )—
—1
and O < b- S n, consider
g. = M
z
bi + bi+1
for 1 S i < d. Thanks to the previous theorem we have
9 _ f- = biai+1— aibi+1_
1
6(0
1
]
1
z
biah' + bi+1) _’b”(b + bi+1)
’ (n + DIN
and similarly fz+1— gi€0( , M]. We deduce that
f1<91<f2<92<f3<---<fd—1<9d—1<fd-
3.2. Applications to diophantine equations and approximations
99
Since 1: lies in one of the intervals [f,-, 9,] or [9,, fi+1] (for some i), the result
follows.
El
Remark 3. 69. If b—(n1+1) is replaced with m, a simple proof of the previous
corollary, based uniquely on the pigeonhole principle, goes as follows: consider
all numbers of the form 1 + [kmj— ka: for 0 S k S n. We have n + 1 numbers
that belong to [0,1), so by the pigeonhole principle two must lie 1n an interval
(n,+
L1]
n for some 0 < j < n. We deduce the existence of integers u1,u2 and
0 3 v1 < v2 3 n such that
1
W2 — u1 — $(v2 — v1)| < ;.
Setting
_
v2 — v1
gcd(v2 — v1, u2 — ul)’
a _
U2 — U1
gcd(v2 — v1, U2 — ul)
yields the desired result.
We are now ready to deal with the equation x2 + y2 = n. More precisely,
we will prove the following beautiful theorem.
Theorem 3.70. The map sending a pair (x,y) to you—1 (mod n) (where m‘1
is the inverse of a: modulo n) establishes a bijection between the set of pairs
(at, y) of relatively prime positive integers x,y such that x2 + y2 = n and the
set of solutions of the congruence 22
—1 (mod n)
Proof. Clearly if at, y are relatively prime positive integers such that :32 + y2 =
n, then gcd(:v,n) = 1 (any common divisor of a: and n would divide y2, but
gcd(sc, y2) = 1, so this divisor must be 1 or —1) and letting z = yx‘l (mod n)
we have
0 E x2 + y2 E 3:2(22 + 1)
(mod n),
thus z2 E —1 (mod n) by Gauss’ lemma. This shows that the map is welldefined.
Let us prove first the injectivity of the map. Consider two different pairs
(x1,y1) and ($2,342) that have the same image, say z. Thus 3/2 E $22 (mod n)
Chapter 3. GOD and LCM
100
and y1 E 3612 (mod n). It follows that :clyg E x2111 (mod n), thus n divides
9313/2 — x2311. On the other hand
n2 = (xi + 213% + 1/3) = ($1112 — $2211)2 + ($1211 + $2y2)2,
thus lxlyz—xgyfl < n. We conclude that mm = $2311. But then Gauss’ lemma
yields :31 | .732 and :02 | :51, thus :31 = x2 and then y1 = yg, a contradiction.
Finally, let us deal with the most diflicult part, the surjectivity of the
map. Consider a positive integer 2 such that 22 E —1 (mod n). We want to
show that we can find relatively prime positive integers x, 3,1 such that y E :32
(mod n) and x2 + y2 = n. By corollary 3.68 we can find relatively prime
integers a, b such that 0 < b 3 [fl] and
—za
n
b
1
1
S b<1+ M) < W'
It follows that
0< b2+(bz+an)2 <n+n=2n
and on the other hand
b2 + (b2 + an)2 E b2 + bzz2 = b2(1 + 22) E 0 (mod n).
Thus we must have
n = b2 + (bz + an)?
In particular
b2-
22+1
n
+2abz—1+a2n=0
and so gcd(b,n) = 1 and also gcd(b,bz + an) = gcd(b, an) = 1. We deduce
that if bz+ an > 0 then a: = b and y = bz +an work, while if bz + an < 0 then
III
x = —bz —— an and y = b work. The result follows.
We turn now to the diophantine equation 1:2 — dy2 = 1, where d > 1 is
not a square (if d is a square, say d = e2, then the equation can be written
as (a: — ey)(a: + ey) = 1, the resolution being therefore very easy).
This
equation is widely known as Pell’s equation, even though Pell did not have
3.2. Applications to diophantine equations and approximations
101
major contributions to its study. Note that while studying Pell’s equation we
may assume that a: and y are nonnegative. There is a trivial solution (1,0),
but it is not clear at all that there are other solutions. We will prove now
that there are infinitely many solutions of this equation. This requires a. few
preliminary steps.
We fix a positive integer d which is not a perfect square, so that x/cl is an
irrational number by example 3.62.
Proposition 3.71. There are infinitely many pairs (:5, y) of positive integers
1
such that
I113 — yfll < a.
Proof. By corollary 3.68 for any n 2 1 we can find integers 0 < bn S n and
an such that
11.
Note that necessarily an > 0. If the sequence
+1(bn)n has infinitely many distinct
terms, we are done, so assume that this is not the case. Then the sequence
(an)n is bounded and so has only finitely many distinct terms. It follows that
there are indices i, j such that bn = b, and an = aj for infinitely many n. But
for such it we have
Ibix/d— ail
and the quantity
+1”
<—
n+ 1
becomes smaller (for 71. large enough) than any given
positive real number. We deduce that bif—
— a,-, contradicting the fact that
\/d is irrational.
CI
The proof of the previous proposition adapts immediately to prove the
following more general (and very useful) result:
Theorem 3.72. If :1: is an irrational number, then there are infinitely many
pairs (p, q) of integers with gcd(p, q) = 1 and
x—I—)|<
q
1
(12'
102
Chapter 3. GOD and LCM
On the other hand, the result established in the previous theorem fails for
rational numbers, as the following exercise shows.
Example 3.73. Prove that if x is a rational number, then there are only finitely
many rational numbers 512 such that |x — 5| < 315.
Proof. Suppose that 5% is an infinite sequence of pairwise distinct rational
numbers (in lowest form) such that
for all n. If the sequence (qn)n20 is bounded, then the previous inequality
shows that the sequence (12,01,213 is also bounded, which is clearly impossible.
Writing a: = g in lowest form, we deduce that for infinitely many n we have
aI > |v|. But since by assumption
’0
lqnu—pnvl < Iq—I < 1,
lnl
it follows that for infinitely many n we have qnu = pnu, contradicting the fact
that the numbers 4% are pairwise distinct. The result follows.
El
Theorem 3.74. Let d be a positive integer which is not a perfect square. The
equation 9:2 — dy2 = 1 has integral solutions a, y with x, y > 0.
Proof. We will prove this in two steps. We first establish the existence of a
nonzero integer k: such that the equation :62 — dy2 = k has infinitely many
integral solutions with 51:, y > 0. Note that if z, y are positive integers and
1
Ix-w/t-il < -,
y
thenx<y\/c_l+1 <2yx/dand s0
1
lxz — dyzl < its + y\/c_l) < E - 3yx/d = 3%.
3.2. Applications to diophantine equations and approximations
103
Using proposition 3.71, we conclude that for infinitely many pairs (11:, y) of positive integers we have x2 — dy2 E {—N, ..., —1, 1, ..., N} for some fixed positive
integer N = 1 + |_3\/c_tj . The result follows then from the pigeonhole principle.
Fix now a nonzero integer k such that 11:2 — dy2 = k has infinitely many
integral solutions with cc, y > 0. Considering the pairs (a: (mod k), y (mod 19))
for these solutions, we see (using again the pigeonhole principle) that we can
find two solutions (x1,y1) and ($2,312) for which an E 11:2 (mod k) and y1 E yg
(mod k). Setting
a: = 5131932 —d
k 1111/2,
y = 581112 _
1,; 9322/1,
a simple calculation shows that
.32 — do = gar — dam — as) = 1.
On the other hand, since :31 E :32 (mod k) and y1 E yg (mod 16), we have
931502 — dylyg E (It? — dyf E 0
(mod k)
and so so is an integer. Similarly y is an integer. If we prove that y 75 0, then
we are done (as then considering the numbers |x|, |y| finishes the proof).
Assume now that y = 0, so that x1312 = $2311 and x2 = 1 (since 3:2 — dy2 = 1).
Thus :0 = 21:1, i.e. $1122 — dylyz = ik. Replacing 2:2 by ”5—31l yields
2/203? - dyf) = ik - 2/1
and so 312 = :tyl. Finally, we obtain y1 = 312 and :31 = $2, a contradiction.
III
We are now ready to express all positive solutions of the equation :62 —dy2 =
1 in terms of a distinguished solution. Namely, considering all pairs of positive
integers (x, y) which satisfy 9:2 — dy2 = 1, it is clear that there is a unique pair
(at, y) for which 2; has the smallest possible value (or equivalently :1: + yx/d has
the smallest possible value). We call this pair the smallest positive solution.
This solution generates all positive solutions, as the following theorem shows.
104
Chapter 3. GOD and LCM
Theorem 3.75. Let ($1,311) be the smallest positive solution of the equation
x2 — dy2 = 1. The geneml solution (mmyn) is given by
xn + yaw/3 = ($1 + 111%)"We have
$n+1 = 51:13:11 + dylym
yn+1 = ylmn + 317191;
and the explicit formulae
x = ($1 + Elm/3)" +2 ($1 - yn/a)” )
n
- ($1 - yix/cl)" _ ($1 + Elm/3)"2w
y‘n —
Proof. Note that by the binomial formula and the fact that x/d is irrational
there are unique integers an, yn such that
asn + urn/3 = («'61 + yn/E)”,
and moreover they satisfy
arn - ynx/cl = ($1 - yn/c—l)",
i.e. they are given by the explicit formulae appearing in the theorem. One
sees directly that
xn+1 = 961% + dyiyn,
yn+1 = 311% + xiyn.
We have
$2 — dy?1 = (son + ym/c—l) - (mu — ynx/d) = (at? — dyf)” = 1,
thus (an, yn) is a positive solution of the equation m2 — dy2 = 1. Conversely,
consider a positive solution (9:, y) of this equation and set
21=x1+y1\/¢l,
z=$+y\/c—l.
By minimality of zl, we have 2 2 21. Since 21 > 1, we deduce that there is a
unique n 2 1 such that
21‘s 2 < zi‘“.
3.2. Applications to diophantine equations and approximations
Write
105
z
2—” = (a: + yx/d)(a:1 — yn/d)” = u + vx/d
1
for some integers a,b, then 1 S u + m/d < 21. Note that, by the binomial
formula and the fact that x/d is irrational we also have
u — «ME = (m — yx/d)(x1 + ylx/d)”
and so
u2 — do2 = (x2 — dy2)(a:% — dyf)” = 1.
Assuming that u + vx/d > 1, we conclude that (u,v) is a positive2 solution
of the equation 3:2 — dy2 = 1 which is smaller than ($1,311), a contradiction.
Thus a + vx/d = 1 and so 2 = 21‘, as needed.
III
Example 3.76. Are there integers a,b > 1 such that ab + 1 and ab3 + 1 are
both perfect squares?
Proof. Assume that such integers exist and write
ab+1=c2,
ab3+1=x2.
Then
51:2 — 1 = (c2 — 1)b2.
Consider this as a Pell equation in the variables a: and b. Then smallest positive
solution is obviously x = c and b = 1, thus the general solution is given by the
previous theorem. In particular, defining sequences :6” and bn by
xn+1 = 03317, + (CZ _ 1)bna
bn+1 = xn + Cbn
we deduce that b = bn for some n. Since b > 1, we must have n > 1. If n 2 3,
then bn 2 b3 > c2 — 1, contradicting the fact that b = bn | c2 — 1 = ab. Thus
n = 2 and b = 2c. It follows that 2c | c2 — 1, which is clearly impossible for
c > 1. Thus there are no such a, b.
2To see that u,v Z 0 note that u — m/d = m 6 (0,1) since u + vx/d > 1.
E]
106
Chapter 3. GOD and LCM
Finally, let us deal with the more general equation
as:2 — by2 = 1.
Example 3.77. Let a, b be positive integers such that ab > 1 is a square. Prove
that the equation acc2 — by2 = 1 has no solutions in positive integers.
Proof. The existence of a solution (any) clearly forces gcd(a, b) = 1. Since
ab is a. square, it follows that a and b are squares. Thus as? and by2 are
consecutive positive perfect squares, which is impossible.
III
Example 3.78. Prove that there are no positive integers a, b such that 2a2 +
1, 2b2 + 1, 2(ab)2 + 1 are all perfect squares.
Proof. We argue by contradiction and assume that there are such integers.
Clearly a, b > 1 and by symmetry we may assume that a 2 b. Then
4(2a2 + 1)(2a2b2 + 1) = (4a2b + (2)2 + 8a2 — b2 + 4
is a perfect square. However we clearly have
(4a2b+b)2 < (4a2b+b)2+8a2—b2+4 < (4(121;+b+1)2 = (4a2b+b)2+8a2b+2b+1.
The result follows.
El
Theorem 3.79. Let a, b be positive integers such that ab > 1 is not a square.
Let (£51,311) be the smallest positive solution of the equation as:2 — by2 = 1 and
let (an, vn) be the general positive solution of the equation u2 ——abv2 = 1. Then
the general solution of the equation azz:2 — by2 = 1 is given by (mmyn), with
xn = xiun + byivn,
ya = yiun + axivn-
Proof. One checks that if (a), y) is a solution of the equation as:2 —by2 = 1, then
u = amlx — byly and v = ylx —a:1y is a solution of the equation u2 — abvz = 1,
and we can recover a: and y from u and v by the formulae
:1: = mm + bylv,
y = y1u + axlv.
III
3.2. Applications to diophantine equations and approximations
107
Example 3.80. Let d be a positive integer which is not a perfect square and
such that m2 — dy2 = —1 is solvable in positive integers. Let (mmyo) be the
smallest positive solution and define (.731, yl) by
{1:1 + ylx/d =(1L'o + ym/d)2.
Prove that ($1,311) is the smallest positive solution of the equation 1:2 —dy2 = 1.
Proof. Clearly ($1,311) is a positive solution of the equation 51:2 — dy2 = 1. Let
($2,312) be the smallest positive solution of the equation 11:2 — dy2 = 1. For
i = O, 1, 2 set
2i = $1 + ZINE.
We prove first that 20 < 22. Assuming that 20 2 22, we clearly have 20 > 22
and so letting u, v be the integers such that
u + vx/d = fl = ($0 + yox/dxzz — yzx/d)
22
we have
11.2 — d1? = ($3 — dy3)(m§ — (121%) = -1
and u + vx/d > 1, as well as u + vx/d < 20, contradicting the minimality of
(compo). Thus zo < z2.
Assume next that 28 > 22, so letting u, v be integers with
2
MM = f0 = ($2 +y2~/&>(mo — own)
we obtain 11,2 — dv2 = —1 and x0 + Elm/d > u + vx/d > 1, contradicting again
the minimality of ($0,310). Thus 23 3 z2. Finally, by minimality of (:32, pg) it
is clear that 2% 2 :32, thus 22 = 23 and we are done.
III
We deduce from the previous example that if the equation x2 — dy2 = —1
(with d > 0 not perfect square) has solutions in positive integers and (mo, yo) is
the smallest positive solution, then all solutions in positive integers are given
by considering the odd (and positive) powers of $0 + ym/c—t. Also, all solutions
in positive integers of the equation x2 — dy2 = 1 are obtained by considering
the even (and positive) powers of x0 + ym/E.
Chapter 3. GOD and LCM
108
Example 3.81. Find all m,n positive integers such that 3’” = 2722 + 1.
Proof. The answer is (m, n) = (1,1), (2,2), and (5, 11).
There are two cases to consider:
1) If m is even then (3m/2,17,) forms a solution to x2 — 2y2 = 1. The
solutions for x in this Pell equation are given by the recurrence formula
$0 = 1, 9B1 = 3, 96k = 693k—1 - 9319—2It is easy to check that 32 = 9 divides wk if and only if k E 3 (mod 6). But
for such k, :51, is also divisible by 11, implying that m/2 does not exceed 1.
Hence, m = 2 gives the only positive solution (m, n) = (2, 2).
2) If m is odd then (3(m‘1)/2,n) forms a solution to 3x2 — 2y2 = 1. The
solutions for x in this Pell-like equation are given by the recurrence formula
:60 = 1, $1 = 9, ask = 10xk_1 — (Bk—2-
It is easy to check that 33 = 27 divides wk iff k E 4 (mod 9). But for such k,
56;, is also divisible by 17, implying that (m — 1) /2 does not exceed 2. Hence,
m = 1 and m = 5 give the only solutions, (m, n) = (1,1) and (5,11).
III
Example 3.82. (Romania TST 2011) Prove that there are infinitely many positive integer numbers n such that n2 + 1 has two positive divisors whose difference is n.
Proof. In formulas, we are asked to show that there are infinitely many solu-
tions to n2 + 1 = d(n + d) in positive integers. This equation is equivalent
to (2d — n)2 — 577.2 = 4. The Pell equation 9:2 — 5y2 = 1 has infinitely many
solutions, and setting n = 23; and d = a: + y gives infinitely many solutions to
the desired equation.
III
Example 3.83. (AMM 10622) Find infinitely many triples (a, b, c) of positive
integers forming an arithmetic progression and such that ab + 1, be + 1, ca. + 1
are all perfect squares.
3.2. Applications to diophantine equations and approximations
109
Proof. Consider solutions (11:, y) in positive integers of the Pell equation x2 —
3y2=1andset
a=2y—a:, b=2y, c=2y+x.
Then
ab+1 = 4y2—2xy+1 = y2—2xy+a:2 = (y—w)2, bc+1 = 4y2+2xy+1 = (we?!)2
and
ca+1=4y2—x2+1=y2.
Since a, b, c clearly form an arithmetic progression and since the Pell equation
above has infinitely many solutions in positive integers, the problem is solved.
El
Remark 3.84. One can prove (not without effort) that there are no positive
integers a, b, c, d in arithmetic progression such that ab + 1, ac + 1, ad + 1, be +
1, bd + 1, at + 1 are all perfect squares.
Example 3.85. (AMM 10220) Let a: > 0 be a real number. A positive integer
n is cc-squarish if one can write n = ab for some integers a, b such that 1 S a S
b < (1 + a‘)a. Prove that there are infinitely many sequences of 6 consecutive
positive integers in which each term is x-squarish.
Proof. We will try to impose that each of the numbers n2, n2 — 1, n2 — 2, n2 —
3,112 — 4, n2 — 5 is w—squarish. Clearly n2, n2 — 1 = (n — 1)(n + 1), n2 — 4 =
(n — 2) (n + 2) are w—squarish for n large enough, so it remains to deal with
n2 — 2,n2 — 3 and n2 — 5. Choosing n of the form n = a2 + a — 2 for some
integer a > 1, one checks that
n2—2= (n—a)(n+a+1)
is ac-squarish (if a is big enough) and so is
n2—5 = (n—2a+1)(n+2a+3).
Finally, if we can also ensure that such n’s are of the form n = 2b2 — 2 for
some integer b, then
n2—3=(n—2b+1)(n+2b+1)
110
Chapter 3. GOD and LCM
is also x-squarish for b big enough. It is thus suflicient to prove that for
infinitely many positive integers a we can find integers b such that
a2+a—2=2b2—2.
This reduces to (2a + 1)2 — 8b2 = 1. Since the equation u2 — 8172 = 1 has
infinitely many positive solutions and u is odd in any such solution, the result
follows.
III
Example 3.86. (AMM 10238) a) Prove that 1 + a. and 1 + 3a are both perfect
squares for infinitely many positive integers a.
b) Let (11 < am <
be all positive integers satisfying the conditions of
part a). Prove that 1 + anan+1 is a perfect square for all n.
Proof. Imposing 1 + a = 9:2 and 1 + 3a = y2, we are reduced to showing that
the Pell-like equation 3,;2 — 3x2 = —2 has infinitely many positive solutions.
Taking into account part b), we also need to find explicitly all solutions. For
this, we observe first that for any solution (1:, y) both a: and y are odd (by
taking the equation y2 — 3:132 = —2 modulo 4). Letting
we obtain positive integers u, 12 such that u2 — 3122 = 1. The smallest positive
solution of this last equation being (2,1), we deduce that all solutions are
given by (un, on), where
an + vn\/§ = (2 + x/g)",
in other words
_ An + 311
2
An _ Bn
’ v"_—W’
where A = 2 + \/§ and B = 2 — fl. Since we can recover :r,y from u,v via
a: = u+v and y=3v+u, we deduce that
an = (m. +12")2 - 1,
3.2. Applications to diophantine equations and approximations
111
with the notation introduced in part b) of the problem. This immediately
implies part a). A simple but tedious computation yields then
A2n+2 + B2n+2 __ 8) 2
6
1 + anan+1 =<
.
_ u2n+1-2 is an integer for
It suflices therefore to prove that A2"+2+B2”+2—8
6
_
3
all n. This follows easily since the formula for an coming from the binomial
formula applied to (2 + V3)” shows an E 2” (mod 3).
El
Example 3.87. Solve in integers the equation
<w2—1)<y2—1>=(Off—Q2.
Proof. Write the equation as
__2
_4
owl—fi—wfi+1=1—EL§@—+(£§£)
or equivalently as
((
2
x-y
2 > +9331)
((
2
2
w—y
_ xy)+ (w+w
_
—O
2
2 )
and finally
(:::+y)2 x2 —6zy+y2 + (a:+y)2 _
4
'
4
2
_
0.
Thus either :1: + y = 0, giving the family of solutions (t, —t), with t E Z, or
x2 — fists/+312 +8 = 0. This last equation is equivalent to (y — 3:73)2 = 8(2)2 — 1).
Hence y— 3:3 is a multiple of 4, say y— 311: = 42, and x2 — 222 = 1. Let (an, on)
be the family of solutions of the Pell equation u2 = 2122 = 1 in positive integers
u and '0. Then we get a second family of solutions with :1: = :tun and z = ion.
Noting that 3a,, :l: 412.” = “nil; we see that y = iunfl. Being careful with the
signs, we find solutions (can, yn) = (an, un+1), (un+1, an), (—un, —un+1), and
(—un+1, —'u,n).
El
112
Chapter 3. GOD and LCM
Example 3.88. Prove that the only positive integers n for which 3" — 2 is a
perfect square are n = 1 and n = 3.
Proof. Suppose that n > 3 is a solution of the problem. Write U2 = 3” — 2 and
observe that 17. must be odd, since otherwise the right—hand side is congruent
to —1 (mod 8), and no square is congruent to —1 (mod 8). Let '0 = 371—211,
so that v.2 — 3122 = —2. As we saw in example 3.2.4, this Pell-like equation
can be reduced to a Pell equation by analyzing parities. Letting (an, on) the
general positive solution of this equation, with no = 120 = 1, we have v1 = 3
and vn+2 = 4vn+1 — on for all n 2 0. It is not difficult (though rather tedious)
to check that on is a multiple of 9 if and only if n E 4 (mod 9) and that on is
a multiple of 17 if and only 72. E 4 (mod 9). Writing 1) = 3117—1 = w, for some
k, we have 9 | v = 12;, since n > 3. We deduce that n E 4 (mod 9) and so
17 I vk. Since we is a power of 3, this is clearly impossible. Hence any solution
77. satisfies n S 3, and the result follows easily.
III
Example 3.89. (USA TST 2013) Determine if there exists a (three-variable)
polynomial P(as, y, z) with integer coefficients and with the following property:
a positive integer n is not a perfect square if and only if there is a triple (:23, y, z)
of positive integers such that P(a:, y, z) = n.
Proof. We will prove that there is such a polynomial P e Z[X,Y, Z], more
precisely that the polynomial
P(X,Y, Z) = Z2(X2 — ZY2 — 1)2 + Z
is a solution of the problem.
If n is not a perfect square, then the Pell equation :1: 2 — ny2 = 1 has
nontrivial solutions. Choosing z = 11. yields P(:r,y,n) = 77.. On the other
hand, suppose that P(:L', y, z) = n for some triple (315,31, 2) of positive integers.
Then
22(532 — zy2 — 1)2 + z = n.
Assume that n is a perfect square, then 1:2 — zy2 — 1 is nonzero and
(z(ar;2 — zy2 — 1))2 < n < (241:2 — zy2 — 1| + 1)2,
a contradiction.
I]
3.3.
113
Least common multiple
Example 3.90. (Putnam 2000) Prove that for infinitely many positive integers
n each of the numbers n,n + 1 and n + 2 can be written as the sum of two
squares of integers.
Proof. Choosing n of the form n = 9:2 — 1 for some a: > 1, the numbers
n + 1 = x2 + 02 and n + 2 = 1:2 + 12 are automatically sums of two squares. It
remains to ensure that n itself is a sum of two squares for suitable 51:. Simply
choose a: such that 2:2 — 2y2 = 1 for some y > 1. As this Pell-type equation
has infinitely many solutions, we are done.
III
Remark 3.91. One can avoid the use of Pell’s equation here, by choosing :c =
21/2 + 1 for some y > 0, in which case
n = x2 — 1 = (23/)2 + (2y2)2.
3.3
Least common multiple
In this section we study the dual notion of god, namely that of least common multiple. We will see very soon that the two notions are closely linked to
each other.
Definition 3.92. Let a1, ..., an be nonzero integers, not all equal to 0. The
least common multiple of a1, ..., an, denoted lcm(a1, ..., an) is the smallest positive integer which is divisible by a1, a2, ..., an.
Note that the definition makes sense: the set of positive integers divisible
by a1, ...,an is nonempty, since Ial...a.n| is such an integer (as a1,...,an are
nonzero). We make the convention that lcm(a1, ..., an) = 0 when one of the
ai’s is equal to 0.
Before moving on to theoretical properties of the 1cm function, let us mention the following beautiful problem of Erdos:
Example 3.93. Let n be an integer greater than 1. Integers 1 < a1 < on <
< ak < n have the property that lcm(a,-,aj) > n for all 1 S 71 aé j S k.
Prove that:
1
1
1
—+—+...+—<—.
a1
a2
a];
2
114
Chapter 3. GOD and LCM
Proof. The idea is extremely beautiful: let us count the number of multiples
of one of the numbers (11, ...,ak in the set {1,2, ....,n} For each 1 S i S k there
are [GEJ such multiples of a,. The crucial claim is that no multiple of a,- can be
I
equal to a multiple of aj for some 1 S i 75 j S k, since this common multiple
would be at least lcm(a,-, aj) > n. Thus the total number of multiples of one of
the numbers on, ..., (1;, is 217:1 lfij, and in particular (using that [:13] > :1: — 1)
k
n
k
n
nZZl—J >Z——k.
i=1 0’"
i=1 “i
The problem is then reduced to proving that k S %. But if k > % then
by Erdos’ problem 3.93 there are indices i < j such that a,- | aj, and so
(13' = lcm(a,-, (1,) > n, a contradiction.
[I
The following theorem is dual to the statement that any common divisor
of a1, ...,an is a divisor of gcd(a,1, ...,an):
Theorem 3.94. Any common multiple of the integers a1, ..., an is a multiple
of lcm(a1, ..., an).
Proof. Let Z = lcm(a,1, ...,an). We may assume that l 75 0 (i.e. that all a, are
nonzero). Let a: be a common multiple of a1, ..., an and assume that 1 does not
divide 11:. Thus we can write a: = ql + r for integers q, r such that 0 < r < I.
But then r = x — ql is a common multiple of a1, ..., an (since so are a: and ql),
and 0 < r < l, contradicting the minimality of l. The result follows.
El
Example 3.95. Show that
lcrn(1,2,. . . ,2n) = lcm(n+ 1,n+2,... ,2n).
Proof. Let A denote the left-hand side and B the right-hand side. Since A is a
multiple of 71+ 1, n+2, ..., 2n, and B is the smallest multiple of these numbers,
we have B s A. To prove that A S B, it suffices to prove that B is a multiple
of 1, 2, ..., 2n and this reduces to checking that B is a multiple of 1, 2, ..., n. Fix
k 6 {1,2, ...,n} Among the k consecutive numbers 12+ 1, 71+ 2, ..., n+ k 3 2n
there is a multiple of k, and this multiple is a divisor of B by definition. Thus
k | B and the result follows.
III
3.3.
Least common multiple
115
Using the previous theorem, the reader can easily check that
lcm(a1,..., an) = lcm(lcm(a1, ..., an_1), an)
for all integers a1, ..,,a,,.
Thus computing the lcm of a family of integers
reduces to understanding the computation for two integers.
The link between the god and the 1cm of two numbers is given by the
following important result.
Theorem 3.96. If a, b are positive integers, then
ab
lcm(a, b) = m,
in other words
lcm(a, b) - gcd(a, b) = ab.
In particular, if gcd(a, b) = 1 then lcm(a, b) = ab.
Proof. Let d = gcd(a, b) and write a = dal and b = dbl with gcd(a1,b1) = 1.
By definition, lcm(a, b) = dk for some integer k, and dk is a multiple of both
a and b, thus k is a multiple of a1 and b1. Since gcd(a1,b1) = 1, we deduce
that albl | k and so da1b1 = “7b divides lcm(a, b). Since on the other hand
gd—b = da1b1 is a common multiple of a and b, we have “7” 2 lcm(a, b). Thus
lcm(a, b) = “71’ and the theorem is proved.
[I
Let us mention the following useful consequence of theorem 3.96:
Corollary 3.97. For all integers 0 < a < b we have
ab
lcm(a, b) >
_ b _ a,’
or equivalently
;<l_L
lcm(a, b) _ a
b
Proof. It suffices to observe that gcd(a, b) is a positive divisor of b — a, thus
gcd(a, b) S b — a. The result follows.
El
116
Chapter 3. GOD and LCM
Here is a beautiful and rather classical application of the previous corollary:
Example 3.98. (Kvant M 865) Prove that for any integers 1 S04) < a1 <
we have
1
2——
01cm(a;,1, ak+1)
< an
< — —.
2”
Proof. We will prove this inequality by induction, the case n = 1 being clear.
Suppose now that the inequality is true for any choice of 1 3 a0 <
andfixlSao<...<a,,.
< an_1
Using corollary 3.97, we obtain
71-1
z:l—_—cm(akl, ak+1)
<
1
1
1
1
1
——— =———<1——
I;0(a);
ak+1 )
a0
an _
an ’
the inequality holds if an S 2'”.
Suppose now that an > 2", hence lcm(an_1,an) 2 an > 2”. Using the
inductive hypothesis, we obtain
1 =1—i
:2:— <1— 1 +—
0lcm(akl,a,k_.,1)
2—"—1
2”
2’"
proving the inductive step in this case also.
[I
We continue with a few other illustrations of theorem 3.96.
Example 3.99. (Kvant) Let a and b be positive integers such that
1cm(a, b)
gcd(a, b) = a ‘ b‘
Prove that lcm(a, b) = (gcd(a, b))2.
Proof. Set d = gcd(a, b). Then a = and, b = bld, where gcd(a1,b1) = 1.
On the other hand
lcm(a., b):
ab
_d2_a,1b1
d(a b): T
=da1b1.
3.3.
117
Least common multiple
Hence the given identity can be written as a1b1 = d(a1 — b1). It follows that
(11 divides dbl, i.e. a1 divides d. Analogously b1 divides d. Thus a1b1 divides
d and we conclude that al — bl = 1 and d = a1b1. Hence
lcm(a, b) = dalbl = d2 = (gcd(a, b))2.
Remark. The above arguments show that all positive integers a and b satisfying
the given identity have the form
a = n(1 + n)2,
b = (1 + n)n2,
where n is a positive integer.
III
Example 3.100. (Saint Peterburg 2009) Let 9:, y, 2 be pairwise different positive
integers such that
lcm(m, y) — lcm(w, z) = y — z.
Prove that a: divides both y and 2.
Proof. Since the left-hand side is a multiple of cc, so must be the right—hand
side, thus we can write y — z = km for some integer k. Then
xy
_
my
_
my
lcm(w, y) = gcd(a:, y) _ gcd(a:,z + kw) _ gcd(a:,z)'
Since lcm(m, z) = figs—25, we can rewrite the equation as
90(3/ - 2) _
scd(w, z) _ y _ 2'
Since y 7E 2, we deduce that a: = gcd(a:,z) and so :1: | 2. Since a: | y — 2, we
conclude that :1: I y, too.
[I
Example 3.101. (Romania JBMO TST 2007) Find all positive integers n Which
can be written as lcm(a, b) + lcm(b,c) + lcm(c,a) for some positive integers
a, b, c.
118
Chapter 3. GOD and LCM
Proof. Call such integers good. Clearly, if n is good, then so is 2n (simply
replace a,b,c by 2a, 2b and 2c). By choosing b = c = 1 we see that all odd
integers greater than 1 are good, hence by the first observation all integers
except for powers of 2 are good. Now, we will prove that powers of 2 are bad,
thus finishing the solution.
Suppose that 2’“ = lcm(a,, b) +lcm(b, c) +lcm(c, a) for some positive integers
a, b, 0.
Clearly k > 1. We may write a = 2Aa1,b = 2Bbl,c = 2001 with
A 2 B 2 C (by symmetry we may assume this) and a1, b1, c1 odd. We deduce
that
2’6 = 2A(lcm(a,1, b1) + lcm(a1, c1)) + 2Blcm(b1, cl).
Dividing by 23 we obtain a power of 2 greater than 1 in the left-hand side
and an odd number in the right-hand side (note that lcm(a1, b1) + lcm(a1, c1)
is even), which is clearly absurd.
El
Algebraic identities can be very powerful when trying to understand the
lcm of a family of numbers a1, ...,an. The idea is the following: one tries
to find integers b1,...,bn such that one has total control on g]; +
+ g3.
Since this expression is clearly of the form m for some integer k,
this leads to nontrivial information about lcm(a,1, ...,an) (such as order of
growth or divisibility properties). Combinatorial identities are very powerful in
finding suitable b1, ..., bn as above. So are techniques coming from algebra, such
as the Lagrange’s interpolation formula, which leads to numerous algebraic
identities. Let us recall this last result. Consider pairwise distinct real numbers
a1, ..., an and arbitrary real numbers b1, ..., bn. Then Lagrange’s interpolation
polynomial
n
P(X) = Z bk fl
k=1
#1:
X—aj
ak—aj
is the unique polynomial of degree 3 n— 1 such that P(ak) = bk for 1 S k S n.
Indeed, it is easy to see that this polynomial satisfies P(ak) = bk for 1 S k S n
(since Hfik 71%]; vanishes at aj for any j aé k). If Q is another polynomial
of degree S n — 1 such that Q(ak) = bk for 1 g k S n, then P — Q has degree
S n — 1 and at least n different roots (namely a1, ...,an), thus must be the
zero polynomial, which gives P = Q.
3.3.
Least common multiple
119
Let us give a few examples of how algebraic identities can be used to obtain
interesting properties of lcm(a1,..., an).
Example 3.102. Let a > b 2 n be positive integers. Prove that
a, _
b
lcm(1,2, ...,n) - W E Z.
Proof. Let k = a — b and let N = lcm(1,2,...,n). We need to prove that
%((b+k) — (3)) is an integer. Using Vandermonde’s identity
a+b _ i a
n
we obtain
b
_ k=0 k
n—k
-<(”i’°) (11>) =-§;(’i )0
so it is enough to check that %(’f) is an integer for 1 S 2' S 17.. But
ak ki _i
_E. k—1
i—l
and it! is an integer by the definition of N.
El
Example 3.103. Prove that for all positive integers a, b we have
a(a:b) llcm(b+1,b+2,...,b+a).
Proof. Using a partial fraction decomposition of Wm, we obtain
the identity
77'!
_Z—(_1)i_
—('Zn)
1
(:1:+1)(:1:+2).. .(rI:+n)
t=1
ac+i
Therefore
1
a!
(7777’) =...(b+1)(b+a)
—Z(———_1)i 12(2) —aZ(_ 1)" (2:11)
i=1
b+i
i=1
b+z'
120
Chapter 3. GOD and LCM
The last expression is clearly of the form m for some integer k.
Thus act”) |lcm(b+ 1,b+2,...,b+a), as needed.
D
Example 3.104. Prove that for all integers n > 1 we have
(n + 1)lcm ((3), (711') , ..., (2)) = lcm(l, 2, ...,n + 1).
Proof. Let
N = lcm(l, 2, ...,n + 1).
First, we prove that the left-hand side divides N. It suffices to prove that
(71+ 1) (7:) = (2‘ + 1) (2:11)
divides N for all 0 g 72 S n, which follows directly from the previous example.
On the other hand, we claim that the left-hand side is a multiple of N. For
this, it suffices to prove that z'+ 1 divides the 1cm of the numbers (n + 1) ('3‘) =
(j+1)(;‘1'11), which is clear since z'+1 divides (i+1) (ll-:11)- The result follows. III
Example 3.105. Prove that for all n > 1
lcm(1,2, ...,n) 2 2"_1.
Proof. This follows directly from the previous example, since
...((g),<g),...,(;»BMW .
Example 3.106. (Saint Petersburg 2004) Given distinct positives a1, a2, . . . ,an.
Let b,- = (a, — a1)(a,- — a2) . . . (ai — ai_1)(a,- — a,~+1) . . . (a, — an). Prove that
lcm(bl, b2, . . . ,bn) is divisible by (n — 1)!.
3.4.
Problems for practice
121
Proof. For any polynomial f of degree < n we have
f(X)=
#ka
In particular, for any f (X) = cX"_1 + dX"_2 +
we have (by looking at the
coeflicients of X”—1)
n
c:
f(ah)
f(Gk)
k=11Hj¢k(ak—aj) =kzb— '
If moreover f (ah) 18 an integer for all 1 < k < n, then the expression 219:1 flba—kz
is clearly of the form c—mUu—F for some integer u, in particular lcm(b1,... ,bn)
c is an integer. Take now
f(X) = (751) = flax — 1)...(X — n+2).
In this case c = (El—IV and f(ak) = ( n—l
“k ) is an integer for all 1 g k S n. We
deduce that (n — 1)! divides lcm(b1, ..., bn).
3.4
III
Problems for practice
Bézout’s theorem and Gauss’ lemma
1. Prove that for all positive integers a, b, c we have
gcd(a,bc) | gcd(a, b) 0 gcd(a,c).
2. (Romania TST 1990) Let a, b be relatively prime positive integers. Let
x, y be nonnegative integers and let n be a positive integer for which
ax+by=an+b”.
Prove that
122
Chapter 3. GOD and LCM
(Kvant M 1996) Find all 'n, > 1 for which there exist pairwise different
positive integers a1, a2, . . . ,0,” such that
0'1
a2
an—l
an
(12
as
an
al
is an integer.
. Let m, n be positive integers greater than 1. We define the sets
pm={i,3,...,_"L:l}
andP ={1,3,...,E}.
m m
m
n n
n
Find
min{|a — bl : a E Pm,b E Pn}.
. (Saint Petersburg 2004) Positive integers m, n, k are such that 5” — 2
and 2’“ — 5 are multiples of 5m — 2m. Prove that gcd(m, n) = 1.
(Russia 2000) Sasha tries to find a positive integer X S 100. He can
choose any two positive integers M, N less than 100 and ask for gcd(X +
M, N). Prove that he can find X after 7 questions.
(Poland 2002) Let k be a fixed positive integer. The sequence {an}n21
is defined by
a1 = k+1,an+1 =ai—kan+k.
Show that if m 9E n, then the numbers am and an are relatively prime.
(Romania TST 2005) Let m, n be relatively prime positive integers with
m even and n odd. Prove that
We denoted by {:13} the fractional part of x, i.e. {(L'} = :17 — [3:].
An infinite sequence a1, a2, . . . of positive integers has the property that
_gcd(am,an) = gcd(m, n) for all m aé n 2 1. Prove that an = n for all
n21.
3.4.
Problems for practice
123
10 . (Iran 2011) Prove that there are infinitely many positive integers n such
that n2 + 1 has no proper divisor of the form k2 + 1.
11. a) (Romanian Masters in Mathematics 2009) Let a1, ...,ak be nonneg—
ative integers and let d = gcd(a1, ...,ak) and n = a1 +
+ ak. Prove
that
d
n!
n
a1!...ak!
— - — 6 Z.
b) Prove that (n)!kk!|(nk)! for all positive integers n, k.
12. (Brazil 2011) Are there 2011 positive integers a1 < a2 < . . . < (12011 such
that gcd(ai, (1,) = aj — ad for any i, 3' such that 1 S i <j S 2011?
13. (Tournament of the Towns 2001) Are there positive integers a1 < «12 <
. . . < 0100 such that
n(a1,a2) > g0d(az,as) >
> n(099,a1oo) > g0d(aioo,a1)?
14. (Russian Olympiad 2012) Let n be an integer greater than 1. When a
runs overs all integers greater than 1, what is the maximum number of
pairwise relatively prime numbers among 1 + a, 1 + a2, ..., 1 + (1271—1?
15. (Brazilian Olympic Revenge 2014) a) Prove that for all positive integers
n we have
gcd (n, [Tn/2D < V4 817,2.
b) Prove that there are infinitely many positive integers n such that
gcd (n, [Tn/2D > V4 7.99112.
16. (AMM) The greatest common divisor of a set D of positive integers is 1.
Prove the existence of a bijection f : Z —> Z such that I f (n) — f (n— 1)| E
D for all integers n.
124
Chapter 3. GOD and LCM
17. (China TST 2012) Let n be an integer greater than 1. Prove that there
are only finitely many n—tuples of positive integers (a1, a2, ..., an) such
that
a) a1 > (12 >
> an and gcd(a1,a2, ...,an) 2 1.
b) We have
0.1 = gcd(a1, a2) + gcd(a2, a3) +
+ gcd(a,.n_1, an) + gcd(an, (11).
Applications to diophantine equations and approximations
18. Integers a, b and rational numbers cc, y satisfy 3/2 = x3 + as: + b. Prove
that we can write :5 = '57 and y = 5’3 for some integers u,v,w, with
gcd(u,v) = gcd(w,v) = 1.
19. (Kvant M 905) Let a: and n be positive integers such that 41:" + (m + 1)2
is a perfect square. Prove that n = 2 and find at least one a: with this
property.
20. Solve in positive integers the equation
21. (Romania TST 2015) A Pythagorean triple is a solution (cc, 3/, z) of the
equation x2 + y2 = 22 in positive integers, Where we count (as, y, z) and
(y,:r, 2) as the same triple. Given a non-negative integer n, prove that
some positive integer appears in precisely n distinct Pythagorean triples.
22. Find all triples (1:,y, n) of positive integers with gcd(a:, n + 1) = 1 and
a3” + 1 = 31”“.
23. Let n be a positive integer such that n2 is the difference of the cubes of
two consecutive positive integers. Prove that n is the sum of the squares
of two consecutive positive integers.
3.4.
Problems for practice
125
24. (Vietnam 2007) Let (1:, y be integers different from —1 such that ”it: +
9:711 is also an integer. Prove that x4y44 — 1 is a multiple of a: + 1.
25. (Balkan 2006) Find all triplets of positive rational numbers (m, n, 1)) such
that the numbers m + nip, n + pim, p + i are all integers.
26. A polynomial f has integer coeflicients and satisfies | f (a)| = | f (b)| = 1
for some distinct integers a, b.
a) Prove that if |a — bl > 2, then f has no rational root.
b) Prove that if Ia — bl = 2, then the only possible rational root of f is
Eli
2 .
27. (Turkey 2003) Find all positive integers n for which 22’“lrl + 2" + 1 is a
perfect power.
28. Let f be a polynomial with rational coefficients such that for all positive
integers n the equation f(x) = n has at least one rational solution. Prove
that deg(f) = 1.
Least common multiple
29. (Kyiv mathematical festival 2014)
a) Let y be a positive integer. Prove that for infinitely many positive
integers :1: we have
lcm(x, y + 1) - lcm(:z: + 1,y) = :r(a: + 1).
b) Prove that there exists positive integer y such that
lcm(a;,y + 1) -lcm(a: + 1, y) = y(y + 1)
for at least 2014 positive integers x.
30. (Kvant M 666) Find the least positive integer a for which there exist
pairwise different positive integers a1, a2, . . . ,ag greater than a such that
lcm(a, a1, a2, . . . , a9) = 10a.
126
Chapter 3. GOD and LCM
31. (Korea 2013) Find all functions f z N —> N satisfying
f(mn) = 101110”, n) ' n(f(m)a f(n))
for all positive integers m, n.
32. (Romania TST 1995) Let f(n) = lcm(1,2,...,n). Prove that for any
n 2 2 one can find a positive integer a: such that
f(:c) = f(x + 1) =
= f(:c + n).
33. Prove that for all positive integers a1, ..., an
lcm(a,1, ..., an) _>_
a1a2...an
H1Si<a nW, 01')
34. (AMM 3834) Let n > 4 and let a1 < 0.2 <
< an S 2n be positive
integers. Prove that
IgnijriSnlcmmz-mj) S 6(|_n/2J + 1).
35. Let (an)n21 be a sequence of integers such that m — n | am — an for all
m, n 2 1. Suppose that there is a polynomial f such that |an| S f (n) for
all 'n. 2 1. Prove that there is a polynomial P with rational coefficients
such that an = P(n) for all n 2 1.
36. Let n, k be positive integers and let 1 < a1 <
< ak S n be a sequence
of integers such that lcm(a,-,aj) S n for all 1 S i, j S k. Prove that
k s 2 lx/fil37. (AMM E 3350) For n 2 1 and 1 S k S n define
A(n,k) = lcm(n,n — 1, ...,n — k + 1).
Let f(n) be the largest I: such that A(n, 1) < A(n, 2) <
a) Prove that f(n) S 3%.
b) Prove that f(n) > k if n > k! + k.
< A(n, k).
3.4.
Problems for practice
127
38. Let (11 < a2 <
< an be an arithmetic progression of positive integers
such that 0.1 is relatively prime to the common difference. Prove that
a1a2...an divides (n — 1)! - lcm(a1, ...,an).
39. Let n > 1 and let on < (11 <
< an be positive integers such that
1
1 .
.
.
.
55’ ..., a IS an anthmetlc progressmn. Prove that
Chapter 4
The fundamental theorem of
arithmetic
This chapter is devoted to the proof and the many consequences of the
fundamental theorem of arithmetic: the unique factorization of integers into
products of prime numbers; Basic properties of prime and composite numbers are studied, with many examples. These are then applied to prove the
fundamental theorem of arithmetic, and the remaining part of this chapter is
devoted to applications of this theorem, for instance to the study of arithmetic
functions.
4.1
Composite numbers
We start by defining prime and composite numbers. Prime numbers are
the bricks of arithmetic, and most of the material in this book will be devoted
to a better understanding of this notion.
Definition 4.1. a) An integer n > 1 is called a prime number (or simply
prime) if the only positive divisors of n are 1 and n, in other words if n has
no proper divisors.
b) An integer n > 1 is called composite if it is not a prime number, in
other words if there is an integer 1 < d < n such that d | n, or equivalently if
130
Chapter 4. The fundamental theorem of arithmetic
n = ab for some integers a, b > 1.
Note that even though the only positive divisor of 1 is 1, but we do not
consider 1 to be a prime. There are many reasons for this. For example, if
1 were called prime, then the unique factorization of integers into products
of prime numbers would need a cumbersome restatement. The sequence of
primes starts as
2, 3,5,7,11,13, 17, 19, 23,29, 31,...
It is not clear for now that there are infinitely many prime numbers, but we
will prove later on that this is indeed the case.
Before focusing on primes, let us spend some time dealing with composite
numbers. First of all, note that there are many composite numbers: all even
integers greater than 2 are composite, and also all multiples of 3 greater than
3, all multiples of 4, etc. It looks therefore natural to conjecture that most of
the integers greater than 1 are composite: for instance, if n is large enough,
then more than 99.99999 percent of the integers between 1 and n are composite. Though this looks intuitively true, the proof of this statement is already
nontrivial and we will be able to prove it only after having introduced a fair
amount of theory.
Since we are dealing with the basics for now, we can only prove the following weak result, which is already very important historically: prime numbers
have unbounded gaps, that is for any N there are two consecutive primes whose
difference is greater than N. Establishing that there are infinitely many pairs
of consecutive prime numbers that have bounded difference is a much deeper
problem and was only established in the spectacular work of Yitang Zhang
in 2013: he showed that there are infinitely many pairs of consecutive primes
which differ by at most 70 - 106. This was later improved in several articles
to 270. Replacing 270 with 2 and therefore proving the famous twin primes
conjecture (saying that there are infinitely many primes p such that p + 2 is a
prime) will probably require a great deal of new ideas. The fact that primes
have unbounded gaps is equivalent to the following:
Proposition 4.2. For any n > 1 there are n consecutive composite numbers.
Proof. The numbers (n+1)!+2, (n+1)!+3, ..., (n+1)!+n+1 are n consecutive
4. 1.
Composite numbers
131
composite numbers, since i divides (n+1)!+i for 2 S i S n+1 and (n+1)!+i >
2'.
Cl
Example 4.3. Is there a sequence of 2005 consecutive positive integers that
contains exactly 25 primes?
Proof. The answer is positive. Let f(n) be the number of primes among
n+1, n+2, ..., n+2005. One easily checks that f (1) > 25. The key observation
is that f(n+ 1) — f(n) is either —1,0 or 1. Indeed, if both n+ 1 and n + 2006
are both composite or both-prime, then f (n + 1) — f (n) = 0. If only n + 1
is prime, then f(n + 1) — f(n) = —1 and if only n + 2006 is prime, then
f (n + 1) — f(n) = 1. Since there are arbitrarily long strings of consecutive
composite integers, there is n such that f(n) = 0. Since f cannot increase or
decrease by more than 1 at a time, it follows that there must be k such that
f(k) = 25.
III
The next example is a more elaborate version of the proof of proposition 4.2.
Example 4.4. (Kvant M 2284) Prove that there exists a strictly increasing
sequence a1, a2, . . . of positive integers such that for any arithmetic progression
b1, b2, . . . of positive integers all but finitely many terms of the sequence a1 +
b1, (12 + b2, . . . are composite.
Proof. We will show that the sequence an = (n2)!, n 2 1 has the desired
property. Let b1, b2, . . . be an arithmetic progression of positive integers with
common difference d, so that bk = b1 + (k — 1)d. For k: 2 max(b1, d) we have
bk S k-max(b1, d) 3 k2, thus for n > max(b1, d) the number a.,,+bn is divisible
by bn > 1 and so it is not a prime.
CI
The next example is also historically very important: it shows that in any
nonconstant polynomial sequence there are infinitely many composite numbers. In other words, nonconstant polynomial sequences cannot generate only
primes.
Theorem 4.5. (Goldbach) Let f be a nonconstant polynomial with integer
coefficients and with positive leading coefficient. There are infinitely many
composite numbers in the sequence f (1), f (2), f (3),
132
Chapter 4. The fundamental theorem of arithmetic
Proof. Since f has positive leading coeflicient, there is an n such that f (n) > 1.
Note that f(n + kf(n)) E f(n) (mod kf(n)), thus f(n) | f(n + kf(n)) for all
k. But f (n + kf (71.)) is a nonconstant polynomial in k with positive leading
coefficient. Hence there is a K such that for all k 2 K, we have f(n+ kf (77.)) >
f(n) Hence f (n + kf (77.)) is composite for k 2 K.
El
Remark 4.6. If we consider polynomials in several variables, the situation can
change rather drastically: Jones, Sato and Wada constructed a polynomial
f in 26 variables a,b,c,
such that when a,b,c,
range over the nonnegar
tive integers, the positive numbers among f(a, b, c, ...) are precisely the prime
numbers!
‘
In the next examples, we discuss a few methods that are often used to
prove that a given number is composite. Algebraic identities can be used from
time to time to establish that numbers are composite.
n+1
Ewample 4.7. (Komal A 622) Prove that 7—;w is composite for all n 2 1.
Proof. The key ingredient is the algebraic identity
x7+1
:1:+1 =(cz:+1)6—7:1:(:z:2+a:+1)2
Checking that this holds is a purely mechanical matter, which we will leave to
the reader. It follows that if z = 73,12 for some y > 1 (which is the case when
m = 77” with n 2 1) then
x7+1
m+1
= ((a: + 1)3 — 7y(:z:2 + a: + 1))((:1: + 1)3 + 7y(a:2 + a: + 1)).
If we prove that (:1:+ 1)3 — 7y(ar:2 +az+ 1) is greater than 1, then we can conclude
that %% is composite. But
x2+m+1=
$3—1
1:3
:1:—1 <x—1
and (a: + 1)3 > x3 + 1, thus it sufl'ices to check that 7y < :1: — 1, or equivalently
7y2 — 7y — 1 > 0. This is clear for y > 1, so we are done.
El
4.1.
Composite numbers
133
Congruences are also a very useful tool in proving that a given integer is
composite. Here are a few examples:
Example 4.8. Prove that 521 0 12” + 1 is composite for all n 2 1.
Proof. If n is odd, then 521 - 12” + 1 E 521 - (—1)" + 1 E 0 (mod 13) and we
are done. If n E 0 (mod 4), we work mod 29 (since 122 + 1 = 5 - 29, hence
124 E 1 (mod 29)) and get
521°12n+15521+1=522=18°29§0
(m0d29).
Finally, if n E 2 (mod 4), then 521-12" + 1 E 2" + 1 E 22 + 1 E 0 (mod 5)
and we are done again.
El
Remark 4.9. One can also prove that 78557 - 2" + 1 is composite for all n 2 1,
by proving that it is a multiple of one of the numbers 3, 5, 7, 13, 19, 37 or 73.
We do not know whether for any a > 1 there is k > 0 such that k - a” + 1 is
composite for all n.
Example 4.10. (Kvant) The sequence of positive integers a1,a2, . .. satisfies
an+2 = anon“ + 1 for all n 2 1. Prove that if n 2 9 then an — 22 is composite.
Proof. Let n > 1 and let k = on“. Then an+2 E 1 (mod 19), an+3 =
an+1an+2 + 1 E 1 (mod k), an+4 = an+2an+3 + 1 _ 2 (mod k) and similarly an+5 E 3 (mod k), an+6 E 7 (mod k) and an+7 E 22 (mod k). Hence
k | an+7 — 22. In other words, an“ I an+7 — 22 for all n 2 1. We want to
prove that an+7 — 22 is composite for n 2 2. Note that a1 _>_ 1, a2 2 1 and the
recurrence relation immediately yields an+6 2 21. Moreover, the recurrence
relation also gives an+5 2 an+1 + 1. Thus an.” = an+5an+6 + 1 > an+1 + 22
and so an+7 — 22 is composite.
El
Remark 4.11. The same proof shows that if bl = 1, b2 = 1 and bn+2 = bnbn+1 +
1, then an — b;c is composite for n 2 k + 3, since it is a multiple of an_k greater
than an_k.
Example 4.12. (Putnam, 2010) Prove that for each positive integer n, the
number 101010 + 1010" + 10" — 1 is composite.
134
Chapter 4. The fundamental theorem of arithmetic
Proof. Put N = 101010” +1010" +10"— 1. Write n = 2mk with m a nonnegative
integer and k a positive odd integer. For each nonnegative integer j,
102"? E (—1)J' (mod 102’" + 1).
Since 10” 2 n 2 2m 2 m + 1, 10” is divisible by 21%“, and similarly 1010" is
divisible by 21°" and hence by 2m+1. It follows that
N 2 1+ 1 + (—1)+(—1) a 0 (mod 102’" + 1).
Since N 2 1010" > 10" + 1 2 102m + 1, it follows that N is composite.
4.2
III
The fundamental theorem of arithmetic
In this section we will prove the fundamental theorem of arithmetic: the
existence and uniqueness of prime factorization for integers greater than 1.
This theorem will be constantly used from now on.
4.2.1
The theorem and its first consequences
We start with a weak form, the existence of the factorization.
Theorem 4.13. Any integer n > 1 is a product of (not necessarily distinct)
prime numbers.
Proof. We argue by contradiction and assume that n > 1 is the smallest
counterexample. In particular, n is not a prime number, hence it must have
a proper divisor d. Since n is the smallest counterexample, d and g are the
product of some prime numbers. But then 72. = 3 - d is also the product of
some primes, contradiction. The result follows.
CI
The uniqueness of prime factorization is deeper and relies on the following
fundamental theorem, which establishes a crucial and not formal property of
prime numbers. Despite the rather easy—looking statement, the next theorem
is not at all a formal consequence of the definition of a prime and the proof
requires Gauss’ lemma (which required Bézout’s theorem, which itself required
the Euclidean division...). Fortunately, we have already done all the hard work.
4.2.
The fundamental theorem of arithmetic
135
Theorem 4.14. Let a,b be integers and let p be a prime divisor of ab. Then
p | a or p | b.
Proof. Suppose that p does not divide a. Then gcd(a, p) = 1, since gcd(a, p) is
a positive divisor of p and cannot be p. Since p | ab and gcd(a, p) = 1, Gauss’
lemma yields p | b, finishing the proof.
III
A useful corollary (which will be considerably refined in later chapters) of
the previous theorem is the following:
Corollary 4.15. Let p be a prime and let a be an integer not divisible by p.
There is a positive integer k such that p | a,“ — 1.
Proof. Consider the remainders of the numbers 1, a, a2,
when divided by p.
Since there are only finitely many remainders, the pigeonhole principle yields
the existence of 0 S i < j such that a‘. and aj give the same remainder when
divided by p. Thus p | a‘(aj_i — 1). Since p does not divide a, the previous
theorem yields 13 | a7”. — 1 and so we can take k = j — i.
El
We are now ready to state and prove the fundamental theorem of arithmetic:
Theorem 4.16. (Fundamental theorem of arithmetic) Any integer n > 1 can
be uniquely written as a product of prime numbers, up to the order of the
factors. In other words, ifp1, p2, ..., pk and q1...q; are prime numbers such that
plpz...pk = q1...ql then k = l and there is a permutation o of 1,2, ...,k such
that qi = pa.(.,;) for 1 S ’l S k.
Proof. The existence has already been established. In order to prove uniqueness, it suffices to prove the statement concerning p1, ...,pk,q1, ...,ql. We will
prove this by induction on k + l, using the previous theorem. The base case
k + l = 2 is clear. Since p1 divides q1...qz, the previous theorem shows that
there exists i such that p1 divides qi. Since p1 and qi are primes, this forces
p1 = q,-. By permuting q1, ..., q;, we may assume that i = 1. Dividing by p1 we
obtain p2...p,c = q2...q; and the number of factors in the products decreases.
Hence we can apply the inductive hypothesis to conclude.
El
136
Chapter 4. The fundamental theorem of arithmetic
If an integer n > 1 is a product of primes p1p2...pk, we say that p1, ...,pk
are the prime divisors or prime factors of n. In other words, a prime p is a
prime factor or prime divisor of n if p | n. Note that if a, b > 1 are integers,
then the set of prime factors of ab is the union of the set of prime factors of a
and that of b, since a prime p divides ab if and only if p divides a or p divides
b.
By collecting equal numbers among p1, ..., pk in the equality n = p1p2...pk,
we deduce that n can be written as
a
a
a
n _.
— q11q22...qs’
with q1, ...,qs pairwise different prime numbers and a1, ...,as positive inte-
gers. This is called the prime factorization (or canonical factorization) of n.
Note that by the fundamental theorem of arithmetic the numbers q1, ..., q, and
an, ...,as are unique.
The fundamental theorem of arithmetic describes the multiplicative structure of the set of integers, in terms of prime numbers. The additive structure
of the set of integers is relatively simple, but the interaction between the two
structures is the source of many very difiicult (and most of the time unsolved)
problems. For instance, one of the oldest and most intractable problems (so
far) is the famous Goldbach conjecture, stating that any even integer greater
than 2 can be written as the sum of two prime numbers. A weaker version
of this conjecture (also known as the ternary Goldbach problem) states that
any odd number greater than 5 can be written as the sum of three (not necessarily distinct) primes. After almost one century of hard work (starting with
Hardy and Littlewood in 1923, Vinogradov in 1937 and ending with Helfgott
in 2013), this weaker conjecture is now a theorem.
Another famous conjecture relating the additive and multiplicative structure of integers was stated in 1986 by Masser and Oesterlé. In order to state
it, let us introduce a notation: if n is an integer greater than 1, let
7‘(n) = Hp
pln
be the product of all different prime factors of n.
4.2.
The fundamental theorem of arithmetic
137
Conjecture 4.17. (the abc conjecture) For any 8 > 0 there is a constant
C(E) > 0 such that for all nonzero integers a, b, c satisfying a + b + c = O and
gcd(a, b, c) = 1 we have
maX(|a|, Ibl, ICI) < 6(6) -T(abC)1+€This conjecture lies extremely deep, since it is not difficult to prove that it
implies many difficult results, which are either already theorems or still conjectural. Fer instance, the abc conjecture immediately implies that Fermat’s
last theorem holds for all sufficiently large n: if n is large enough, then the
equation x" + y” = z" has no integer solutions with myz 75 0. Indeed, suppose
x, y, z is such a solution (with x, y, 2 positive to simplify notations). Then we
may assume that gcd(m, y, z) = 1 and hence
z" < c(1/2)r(a:yz)% S c(1/2)z%.
Since 2 2 2 (otherwise my = 0) we deduce that
2n-% < c(1/2),
which bounds n from above.
Similarly, it is a simple exercise to deduce from the abc conjecture the
following result (which is a deep theorem of Darmon and Granville, proved
independently of the abc conjecture): if p, q, r 2 2 and the equation :17” + yq =
2? has infinitely many solutions in positive integers with gcd(a:, y, z) = 1, then
1
1
1
-+—+-ZL
p q r
Indeed, for any 8 > 0 and any solution we will have
zr g c(e)r(a;yz)1+6 g C(e)z(1+€)(%+%+l),
We deduce that
1
1
1
15(—+—+—)(1+d
P
q
7'
and since 5 > 0 was arbitrary, the result follows.
138
Chapter 4. The fundamental theorem of arithmetic
It is not difiicult to check that the only triples (p, q, r) with p, q, 'r 2 2 and
1
1
1
p
q
7"
—+—+—>1
are (2,2,n) (with any n 2 2), (2,3,3), (2,3,4) and (2,3,5) and their permutations, while the only triples with
1
1
1
P
‘1
7‘
—+—+—=1
are (3,3,3), (2,4,4), (2,3,6) and their permutations. For instance, we have
already seen that the equation x4 + y2 = 24 has no nontrivial solutions. On
the other hand, one can prove (with a. lot of work!) that the only nontrivial
solutions of the equation x3 + y6 = 22 are 23 + (:lzl)6 = (:|:3)2. In a different
direction, each of the equations 1:3 + y3 = z2, $4 + y3 = z2, x4 + y2 = z3,
:05 + y3 = 22 have infinitely many solutions, for instance for the equation
x3 + y3 = 22 a family of solutions is given by
a: = a4 + 6a2b2 — 35*, y = —a4 + 6a2b2 + 3b4, z = 6ab(a4 + 3b4)
with arbitrary positive integers a, b. These are not the only solutions, for
instance another infinite family of solutions is given by
x = a4 + 8ab3,y = —4a3b + 4b4, z = a6 — 20a3b3 — 8b6.
Yet more examples of nontrivial solutions of such equations are given by
9mfi+nnnmfl=lmiwi+wmmfi=ammifi+1fi=1mam
The remaining part of this section is devoted to a long series of exercises
and examples that illustrate the previous fundamental theoretical results.
Example 4.18. (Zhautykov Olympiad 2010) Find all primes p, q such that
4.2.
The fundamental theorem of arithmetic
139
Proof. Write the equation as
Mp2 - 1) = 4((16 - 1) = (1(q3 - 1)(q3 + 1)
= q(q — 1)(¢12 + q + 1)(q + 1)(q2 — q + 1)Thus p divides one of the numbers q,q — 1,q2 + q + 1,q + 1,q2 — q + 1. We
claim that p > q2, which then implies that p = q2 + q + 1. Indeed, if p S q2,
then
q(q6—1)=p3—p<p3-l 916—1,
impossible.
Hence p = q2 + q + 1 and the equation becomes
102 - 1 =q(q- 1)(q+1)(q2—q+1)
or equivalently
q(q + 1)(q2 + q + 2) = q(q + 1)(q - 1)(qr2 — q + 1)Dividing by q(q + 1) and simplifying the resulting expressions yields
(q - 3)(92 + 1) = 0,
hence q = 3 and then p = 11.
III
Example 4.19. (Saint Petersburg 2013) Find all primes p, q such that 2p — 1,
2q — 1 and 2pq — 1 are all perfect squares.
Proof. Say 2p— 1 = a2, 2q — 1 = b2 and 2pq— 1 = c2 for some positive integers
a,b,c. Thenp | a2+1 andp | c2+1, thusp | 02—a2 andsop | c—aor
p | c+ a. Note that a, c are odd and p is odd, hence p S 0+7“ and with a similar
argument q 3 k211i In other words
CZZp—a,
c22q—b.
Butthen
2pq—1:022 (2p—a)(2q—b)=4pq—2pb—2qa+ab,
140
Chapter 4. The fundamental theorem of arithmetic
which becomes
2pq + 1 + ab S 2pb + 2qa.
In particular pq < pb + qa and so
b a
\/5 \/§
1<—+—<
—+ a
q
P
‘1
P
We may assume that p S q. The previous inequality yields p g 7. Clearly
p = 7 is not a solution since 2p — 1 is not a square in this case. Thus p S 5
and since p = 2 and p = 3 are not solutions, we obtain p = 5. But then
c=y/10q—122q—b=2q—‘/2q—1,
which immediately implies that q S 5 and then q = 5. Hence p = q = 5 is the
[I
only solution.
Next, we discuss a series of exercises in which theorem 4.14 is used to prove
that certain numbers are composite.
Example 4.20. (Kvant M 888) Let a, b, c, d be positive integers such that ab =
cd. Prove that for every positive integer k the number ah + bk + ck + dk is
composite.
Proof. Replacing a, b, c, d with ah, bk, ck,d’°, we may assume that k = 1. Let
a
m
us write — = — = — in lowest terms, where m,n are positive integers. Since
c
n
m divides na and gcd(m, n) = 1, we must have m I a, hence a = mu and
c = nu for some positive integer 11.. Similarly d = mi) and b = no for some
positive integer 1). But then
a+b+c+d=mu+na+mv+nv=(m+n)(u+'u)
is composite.
Here is another proof, more in the spirit of the argument used to solve
the next exercise: assume that a + b + c + d = p is a prime and note that
a + b E —c — d (mod p) and ab E (—c) - (—d) (mod p) (the first congruence is
clear and the second one follows from the hypothesis of the problem). Thus
4.2.
The fundamental theorem of arithmetic
141
the coefficients of the polynomial (X — a) (X — b) — (X +c) (X +d) are multiples
of p and so its value at a is a multiple of p. In other words, p | (a + c) (a + d).
Since p is a prime, p divides one of the numbers a + c and a + d, which is not
the case since p > max(a + c, a + d).
E]
Example 4.21. Let a, b, c, d be positive integers such that
a2+ab+b2 =c2+cd+d2.
Prove that a + b + c + d is composite.
Proof. Assume that p = a + b+ c+ d is a prime number. Then a + b E —c — d
(mod p) hence
a2+b2+ab+abEcz+d2+cd+cd (modp),
which combined with the hypothesis yields ab E cd (mod 1)). Considering the
polynomial (X — a) (X — b) — (X + c) (X + d) and arguing as in the previous
example we deduce that —(a + c) (a + d) is a multiple of p. It follows that
p divides one of the numbers a + c and a + d, which is impossible since p is
greater than each of them.
III
Example 4.22. (IMO Shortlist 2005) Let a, b, c, d, e, f be positive integers
such that S = a+b+c+d+e+f divides abc+def and ab+bc+ca—de—ef—df.
Prove that S is composite.
Proof. Suppose that S is a prime and let a: = —d,y = —e, z = — f , so that
a+b+cEx+y+z (mod S),
ab+bc+casxy+yz+zm
(mod S)
and abc E acyz (mod S). Considering the polynomial
(T - a)(T - b)(T - c) - (T - x)(T - y)(T - Z)
and arguing as in the previous examples we obtain that
S l (a - x)(a - y)(a - Z) = (a + d)(a + e)(a + f)Since S is a prime, S divides one of the numbers a + d, a + e, o. + f, which is
impossible since S is greater than any of them. Hence S is composite.
El
142
Chapter 4. The fundamental theorem of arithmetic
Remark 4.23. There are many exercises (more or less difficult) with a very
similar flavor and solution. Here are two more examples, left to the reader:
a) (IMO 2001) Let a > b > c > d be positive integers such that
ac+bd=(b+d+a—c)(b+d—a+c).
Prove that ab + at is composite.
b) (USAMO 2015) Let a, b, c, d, e be distinct positive integers such that
a4 + b4—
— c4 + (14—
— e5 .Prove that ac + bd 1s a composite number.
Example 4.24. (IMO Shortlist 2001) Is it possible to find 100 positive integers
not exceeding 25000, such that all pairwise sums of two of them are different?
Proof. We will prove more generally that for any odd prime p we can find p— 1
numbers a1, ..., ap_1 not exceeding 2122 and such that all pairwise sums of two
of them are different (then taking p = 101 will solve the problem). If a is an
integer, let a be the remainder of a when divided by p. Let an = 2np + W for
1 S n S p — 1. The numbers a1, ...,ap_1 are smaller than 2p(p — 1) +p < 2p2
and it remains to see that the pairwise sums are different. Suppose that
an+am = ak+a1 for somenaém and k 75 l between 1 andp— 1. We write
this equality as
2p(n+m—k—l)=W+l—2—W—W.
The right-hand side is between 2— 207— 1) and 2(p— 1)— 2 and is a multiple
of 2p_(since_the left-hand side 18 so). Thus we must have n + m—
— k + l and
19—2 + l—22—
- m—2 + 71—2. We deduce that n2 + m2:
— k2 + l2 (mod p). Combined
with n2 + m2 + 2mn—
— k2 + l2 + 2lk and using the fact that p is odd we obtain
E lk (mod p). Thus the coeflicients of the polynomial
(X—m)(X—n) — (X—l)(X—k)
are multiples of p and so 1) I (m — l) (m — k). We deduce that either m = l and
n=korm=kandn=l.
El
Recall that the Fibonacci sequence (fn)n21 is defined by f1 = f2 = 1 and
fn—1 + fn_2 for n 2 3. It is not difficult to prove that if fn is a prime
=
fn
4.2.
The fundamental theorem of arithmetic
143
number, then n is also a prime number or n = 4, but the converse does not
hold since f19 is not a prime. Many prime Fibonacci numbers are known (for
instance one of the largest ones is f1968721), but it is not known whether the
Fibonacci sequence contains infinitely many primes. The following interesting
result describes all primes in the shifted Fibonacci sequence (fn + 1)n21. A
crucial ingredient in the proof is Catalan’s identity
f3; _ fn+rfn—r = (—1)n_rf3’
whose proof is left as an easy exercise for the reader, recalling that we have
the classical formula
_ ¢" — (-¢)"
fn _
«5
where ¢ = lizé. Another crucial ingredient is theorem 4.14.
Example 4.25. a) Prove the Gelin-Cesaro identity
153— fn—a—lfn+1fn+2 = 1,
n 2 3
b) Find all n for which fn + 1 is a prime.
Proof. a) We use Catalan’s identity with r = 1, 2 to obtain
fn+1fn—1 - f3 = (-1)" = f3 — fn+2fn—2-
Thus f3 — 1 and f3, + 1 are fn_1fn+1 and fn_2fn+2 in some order. The desired
result follows since in either case
f3 — 1 = (133- 1)(f3+ 1) = fn—2fn—1fn+1fn+2b) It is easy to check that fn+1 is a prime for n = 1, 2, 3. Suppose that n >
3 and that fn + 1 is a prime. Since fn + 1 divides f3 — 1 = fn_2fn_1fn+1fn+2,
it must divide one of the numbers fn_2, fn_1, fn+1, fn+2. Since it is greater
than fn_2 and fn_1, it either divides fn+1 or fn+2. On the other hand, it is
clear that the Fibonacci sequence is increasing and so fn+2 < 2fn+1 for all
77., thus fn+2 < 4f”. If fn + 1 | fn+1, since fn+1 < 20”,, + 1) we must have
fn+1 = fn+ 1 and then fn_1 = 1, impossible for n > 3. Thus fn+1 | fn+2 and
144
Chapter 4. The fundamental theorem of arithmetic
since fn+2 < 4(fn + 1) and fn+2 > fn + 1 we must have fn+2 = 2(fn + 1) or
fn+2 = 3(fn + 1). In the first case we obtain fn+1 = fn + 2, that is fn_1 = 2,
then n = 4 and f4 + 1 = 4 is not a prime. In the second case we obtain
fn+1 = 2fn + 3, impossible since fn+1 < 2fn. Thus the only solutions of the
problem are n = 1, 2, 3.
El
4.2.2
The smallest and largest prime divisor
The next problems are concerned with the largest and smallest prime fac-
tors of integers. We will introduce therefore the following notation: if n > 1
is an integer, P(n) will denote the largest prime factor of 77., while p(n) will
denote the smallest prime factor of n.
The first two examples exploit a very specific property of monic quadratic
polynomials. This class of polynomials can be characterized by the property
that
f(X)f(X + 1) = f(X + f(X))We leave it to the reader as a very pleasant exercise to prove this property.
In particular, if q(n) = P(f (n)) is the largest prime factor of f (n), then the
previous relation yields
(10% + f(72)) = maX(q(n), (10! + 1)).
Example 4.26. (IMO Shortlist 2013) Prove that there exist infinitely many
positive integers n such that the largest prime divisor of n4 + n2 + 1 is equal
to the largest prime divisor of (n + 1)4 + (n + 1)2 + 1.
Proof. Let f(X) = X2 — X + 1, then f(X + 1) = X2 + X + 1 and so the
previous identity becomes
f(n2 + 1) = n4 + n2 + 1 = f(n)f(n + 1),
Letting q(n) be the largest prime factor of f(n), the problem requires
(10%2 + 1) = q((n + 1)2 + 1)
for infinitely many n, or equivalently (thanks to relation (1))
maX(q(N), W» + 1)) = maX(q(n + 1), q(n + 2))
(1)
4.2.
The fundamental theorem of arithmetic
145
for infinitely many n. This is the case if q(n + 1) 2 max(q(n), q(n + 2)), and
we will prove that this inequality holds for infinitely many n. Assume that
this is not the case, hence q(n + 1) < max(q(n),q(n + 2)) for n 2 N, where
N is some positive integer.
Since there is no infinite decreasing sequence
of positive integers, there is no > N such that q(no + 1) 2 q(no). Since
q(no + 1) < max(q(no), q(no +2)), we obtain q(no+ 1) < q(no +2). Combining
this with q(no+2) < max(q(no+1),q(no+3)) we see that q(no+2) < q(no+3)
and inductively q(n) < q(n + 1) for n > no. But then the equality
(10%2 + 1) = maX(q(n), (101 + 1))
cannot hold for n > no, since n2 > n and n2 > n + 1.
El
Example 4.27. (Russia 2011) Let q(n) be the largest prime divisor of n2 + 1.
Prove that there are infinitely many pairwise distinct positive integers a, b, c
such that q(a) = q(b) = q(c).
Proof. Letting f(X) = X2 + 1 we obtain
f(X2 + X + 1) = f(X)f(X + 1)
thus
«10%2 + n + 1) = maX(q(n), (10% + 1))
(1)
and
q(n2 - n + 1) = (1((71 - 1)2 + (n - 1) + 1) = maX(¢I(n - 1),q(n»Hence if n > 1 and q(n) 2 max(q(n - 1),q(n + 1)) then
q(n) =qr(n2 -n+1) =q(n2+n+1)
and the numbers n, n2 — n + 1 and n2 + n + 1 are pairwise distinct. It suffices
therefore to prove that for infinitely many n we have
q(n) 2 max(q(n — 1), q(n + 1)),
which can be done exactly as in the previous problem.
III
146
Chapter 4. The fundamental theorem of arithmetic
The next problems deal with the smallest prime divisor of a number. Before discussing them, we would like to mention the following very important
criterion of primality:
Proposition 4.28. A number n > 1 is composite if and only if it has a prime
divisor p 3 fl, that is if the smallest prime factor of n does not exceed fl.
Proof. If n has such a prime factor, it is clear that n is composite. Conversely,
suppose that n is composite, so we can write n = ab, with a, b > 1. Then each
of a, b has at least one prime factor, say p and q. Since n 2 pq, we deduce
that min(p, q) is a prime factor of n, not exceeding J77.
III
Example 4.29. (Kvant M 557) Prove that each set of n pairwise relatively
prime numbers greater than 1 and less than (2n — 1)2 contains at least one
prime.
Proof. Suppose that the given numbers a1, a2, . . . , on are all composite. Denote by q,- the least prime divisor of 04', 1 S i S n and assume Without loss
of generality that q1 <
< qn (note that the qi’s are pairwise distinct as
gcd(a¢,aj) = 1 for i aé j). Thus q1 2 2, (12 2 3 and qi+1 Z q,- + 2 for i 2 2,
which easily yields qn 2 2n — 1. But then an 2 qf, 2 (2n — 1)2, a contradiction.
III
Example 4.30. (Russia 2014) Find all integers n > 1 such that for any positive
divisor a of n the number a + 1 divides n + 1.
Proof. Clearly all odd primes are solutions of the problem. Conversely, suppose that n is a solution and let us prove that n is a prime. If not, then n has
a proper divisor a 2 J77. (namely n/p, where p is a prime factor 3 Jr? of n).
By hypothesis a + 1 divides n + 1, thus a + 1 divides n + 1 — (a + 1) = n — 0..
Since a I n — a and since gcd(a,a + 1) = 1, we deduce that a(a + 1) | n — a
and so n — a 2 a(a + 1) > a2 2 n, a contradiction. Thus the solutions of the
problem are the odd prime numbers.
III
Example 4.31. (Saint Petersburg 2008) If a is an integer greater than 1, let
p(a) be its smallest prime factor. Let m, n be integers greater than 1.
4.2.
The fundamental theorem of arithmetic
147
a) Prove that if
m2 + n = p(m) + Mn)2
then m = n.
b) If
m + n = 10W)2 - 10002,
what are the possible values of m?
Proof. a) We have p(n)2 — n = m2 — p(m) > 0, that is p(n) > W. Thus n is
a prime, say n = q, and p(n) = q. The equation becomes m2 — p(m) = q2 — q,
hence p(m) divides q(q — 1). Assume that p(m) divides q — 1, then q > p(m)
and (m — q)(m + q) = p(m) — q < 0, that is m < q. We conclude that
qz—q=m2-p(m) <m2S (q-1)2,
a contradiction. Thus p(m) = q and then m2 = q2, hence m = q = n.
b) We have this time
n +1201)2 = 100”)2 - m
and again p(m) > M, showing that m is a prime. If m = 2, then n+p(n)2 =
2, which is impossible. Thus m is an odd prime. Conversely, if m is an odd
prime, then we look for n even such that n + p(n)2 = p(m)2 — m, a relation
which can also be written as n + 4 = m2 — m. Thus n = m2 — m — 4 works
(note that n > 1 since m 2 3).
El
Example 4.32. (Russia 2001) Find all odd positive integers n > 1 such that if
a and b are relatively prime positive divisors of n, then a + b — 1 divides n.
Proof. Let p be the smallest prime divisor of n and let n = pkm with k 2 1
and m relatively prime to p. By hypothesis p + m — 1 | n. Note that
n(p+m_ 1am) = n(p_ 1am) ln(p— 1,77,) = 1)
the last equality being a consequence of the fact that all prime factors of
p — 1 are less than p and so they cannot divide n. Thus p + m — 1 | pk and
p+m— 1 =pl for some 1 S k.
148
Chapter 4. The fundamental theorem of arithmetic
Suppose that k 2 2, then p2 + m — 1 l n and similarly
gcd(p2 + m — 1,m) = gcd(;o2 — 1,m) |gcd(p2 — 1,n) = 1.
Note that the last equality crucially uses the hypothesis that n is odd, to
ensure that all prime factors of p + 1 are less than or equal to %1 < p (since
p is odd). As above, we deduce that p2 + m — 1 = p7 for some j S k. Then
m-1=p7-p2=p'—p,
that is p7 + p 2 pl + p2 or pl(p7"l — 1) = p(p — 1). This immediately implies
l = 1 and then m = 1. In other words, if k 2 2, then n is a power of an odd
prime, and it is clear that any such number is a solution of the problem.
Assume now that k = 1, thus necessarily l = 1 (as l S k and clearly l > 0)
and then again m = 1 and n is a power of 13. Thus the solutions of the problem
are the odd prime powers.
[I
The polynomial X2 + X +41, discovered by Euler and Lagrange in the late
18th century, takes prime values for X = 0, 1, ..., 39. The next example shows
that it suflices to check this only for X = 0,1,2, 3.
Example 4.33. (IMO 1987) Let n be an integer greater than 2 such that k2 +
k + n is a prime number for all 0 S k S «g. Prove that k:2 + 16 +77. is a prime
for allOSkSn—2.
Proof. Let f (X) = X2 + X + n and let p be the smallest prime factor of any
of the numbers f(O), f (1), f (2), ..., f (n — 2). Suppose that the required result
fails, so there is some k S n — 2 such that f(k) is composite. The smallest
prime factor q of f(k) satisfies q2 S f(k) S (n — 2)2 + n — 2 + n < 77.2, hence
q < n. Since p s q, it follows that p < n.
Now let k e {0, ...,n — 2} be such that p I f(k). Let s be the remainder of
k when divided by p and let r = min(s, p — 1 — 3). Note that p also divides
f(s) and f(p — 1 — s), so p | f(r). Moreover, r S 9—31, thus
_ 2 _
_
f(r)Sn+(p—2-1)+pTl=n+p%.
4.2.
The fundamental theorem of arithmetic
149
Since p < n (as shows the first paragraph), we have p aé f (r), hence we can
choose a prime factor q of fig). By minimality of p, we have q 2 p, hence
p2 S f(r) S n+#. It follows thatp < 2\/-%— and then r < 723 < fl. But by
assumption f (r) is a prime number, contradicting the fact that it is a multiple
of pq.
El
Remark 4.34. a) In 1952 Heegner proved that 41 is the largest integer A with
the property that n2 + n + A is a prime for all n = 0,1, ..., A — 2 (Heilbronn
proved that there are only finitely many such A’s in 1934).
b) The polynomial 36X2 — 810X + 2753 gives (by taking X = 0,1,...,44
and considering absolute values in case a number is negative) a string of 45
different prime values. Also for
f(X) = X5 — 133X4 + 6729X3 - 158379X2 + 1720294X — 6823316
the number %| f(n)| is a prime for 0 S n S 56.
Similarly |3n3 — 183722 + 3318a — 18757| is a prime for 0 g n g 46.
4.2.3
Combinatorial number theory
Finally, we discuss some problems with a more combinatorial flavor. Most
of these problems are fairly tricky.
Example 4.35. (Tuymaada 2005) The positive integers 1, 2, ..., 121 are arranged
in the squares of a 11 x 11 table. Dima found the product of numbers in each
row and Sasha found the product of the numbers in each column. Could they
get the same set of 11 numbers?
Proof. The answer is negative. Consider the 12 primes
61, 67, 71, 73, 79, 83, 89, 97, 101,103,107, 109.
The only multiple of such a prime belonging to the set {1,2, ..., 121} is the
prime itself. Two of these primes, say 1), q, must be in the same row. If Dima
and Sasha found the same numbers, then there would be a column whose
product of elements is a multiple of p, q. But then 1), q would have to be in
that column. Thus p, q belong to the same row and column, contradiction. III
150
Chapter 4. The fundamental theorem of arithmetic
We will use several times the observation that if a | b, then the prime
factors of ab are exactly the prime factors of b.
Example 4.36. (Kvant) Consider an infinite arithmetic progression of positive
integers. Prove that there are infinitely many terms in this progression such
that any two of them have the same set of prime divisors.
Proof. Say the general term of this progression is a + nd, with n 2 0. All
numbers a(1 + d)" with n 2 0 are terms of this progression and they satisfy
the desired condition.
[I
Example 4.37. (Iran 2004) Let n be an integer greater than 1. Prove that
there are n positive integers a1 < a2 <
< an such that for all nonempty
subsets I, J of {1,2,...,n} the numbers 2,61 a, and ZjeJ aj have the same
prime factors.
Proof. Let a,- = 1' ~ N! for 1 S i S n, where N is a large integer to be chosen
later. If I C {1, 2, ...,n} is a nonempty subset, then
2 a, = N! - :2“
iEI
and
ieI
1
132t$1+2+m+n=m.
.
2
1.61
Thus if we choose N = 91%;), then the prime factors of 2,6I ai are exactly
the primes dividing Nl, and this is independent of the choice of I.
E!
Example 4.38. Let p be a prime, let r 6 {1,2, ...,p — 1} and let a1,a2, ...,ar 6
{1, 2, ..., p — 1}. Consider the remainders of all numbers ZieS ai when divided
by p, over all subsets S of {1, 2, ..., r} (including the empty set, for which the
corresponding sum is 0). Prove that there are at least r+1 different remainders
among them.
Proof. The result is clear for r = 1. Assume that it holds for r = k and that it
is not true for r = k+1, With k+1 < p. By assumption we can find pairwise dis—
tinct numbers C1,...,c;c E {1, 2, ...,p — 1} such that 0, c1, ..., ck all appear as remainders of some of the numbers 2,63 a,- with S C {1, 2, ..., k}. Since the sums
4.2.
The fundamental theorem of arithmetic
151
2,63 a,- with S C {1, 2, ..., k + 1} give at most k + 1 distinct remainders, and
they contain all sums 2,65 a,- with S C {1,2, ..., k}, it follows that 0, c1, ..., Ck
are all possible remainders of 2,65 (1,- with S C {1,2, ...,k + 1}. In particular
the remainders of ak+1, ak+1 + C1,...,ak+1 + ck (which are pairwise different)
are among 0,01, ..., ck, and so they must be a permutation of 0,01, ...,ck. This
implies that the remainders of all numbers 0,ak+1, 2ak+1, ..., (p — 1)ak+1 are
among 0, c1, ..., ck, which forces p S k+ 1, contradicting the fact that k+1 < p.
Hence if the assertion holds for 7' = k and k: + 1 < p, then it also holds for
k + 1. This yields the desired result.
[I
Escample 4.39. (Erdos-Ginzburg-Ziv theorem) Let n > 1 be an integer. Prove
that among any 2n — 1 integers we can choose n whose arithmetic mean is an
integer.
Proof. The proof is done in two steps: we prove the theorem when n is a
prime using the result established in the previous example, then we deduce
the general case by an elementary argument.
Assume first that n = p is a prime. We may assume that our integers
a1, a2, ..., a2p_1 are between 0 and p — 1 (by replacing them with their remainders when divided by p), and we may also assume that a1 3 a2 3
S a2p_1.
If there is j e {1,2,...,p — 1} such that ap+j = aj+1, then we must have
aj+1 = aj+2 =
= aj+p and aj+1 +
+ aj+p is a multiple of 1). So as-
sume that aj+1 75 aj+p for 1 S j < p. By the previous example, the sums
of the numbers aj+p — aj+1 (for 1 S j < p) give at least p distinct remainders modulo p, i.e. they cover all possible remainders. In particular, if r
is the remainder of a1 + a2 +
+ ap, then there is a sum giving remainder
p — r. That is, we can find some indices 1 S jl <
< 3‘], S p — 1 such that
a?“1 +
+ap+jk — ajl —
— ajk +a1 +
+ap is a multiple of 12. But this last
sum is clearly equal to the sum of 1) numbers among a1, ..., a2p_1. The result
follows.
We now treat the general case. Since any n > 1 is a product of primes,
it suffices to prove that if a,b > 1 and the result holds for a and b, then
it holds for ab. Consider 2ab — 1 integers. We choose 2a — 1 of them, and
among the chosen ones we choose a whose arithmetic mean m1 is an integer.
We now consider the remaining 2ab — 1 — a numbers and repeat the previous
152
Chapter 4. The fundamental theorem of arithmetic
procedure: we select 2a — 1 such numbers (if possible), then among them we
select a whose arithmetic mean m2 is an integer, and we keep doing this 2b — 1
times, obtaining arithmetic means m1, ...,m2b_1 of collections of a numbers.
Since the result holds for b, there are b numbers among m1, ...,m2b_1 whose
arithmetic mean is an integer. These b arithmetic means correspond to ab
integers among the 2ab — 1 original ones, whose arithmetic mean is an integer,
proving the result for ab.
III
Example 4.40. (adapted from Iran TST 2008) Let (an)n21 be a sequence of
positive integers such that for all m,n 2 1, all prime factors of am + an are
among the prime factors of m + n. Prove that an = n for all n.
Proof. The key observation is that P I an + am whenever p is a prime and m, n
are positive integers such that m + n is a power of p. Indeed, an + am 2 2, so
there is a prime q | an + am, but by hypothesis q | n + m and so q = p.
We first prove that if m 7E 77., then am 7E an. Suppose that an = am and
choose a large prime p. By the first paragraph, 19 | an+ap_n, thus p | am+ap_n
and then p | m + p — n. Thus p l m — n for all large primes, contradiction.
Next, we prove that |an — an+1| = 1 for all n 2 1. Suppose that there
is n for which this is not the case and let p be a prime factor of an+1 — an.
Let k be such that pk > n. Then by the first paragraph 1) | an + apk_,,,
and so p | an + apk_n + an+1 — an. That is, p | apk_n + an+1..and then
p | pk — n + n + 1 = pk + 1. Since this is absurd, the claim is proved.
Finally, the previous two paragraphs yield an+2 — an+1 = an+1 — an = c
for all n and some 0 6 {—1,1}. Since the sequence takes positive values, we
must have c = 1 and so an = n + k for some k 2 0. Take a large prime p.
Choose positive integers m, n such that p | m + n + 2k. Then p | am + an and
so p | m + n. Subtracting, we deduce that p | 2k for all large primes p, thus
k = O and we are done.
[I
Remark 4.41. The original problem was weaker, the hypothesis being am +an |
(m + n)’° for all m,n 2 1, where k is fixed.
Example 4.42. (IMO Shortlist 2007) Find all sequences (an)n21 of positive
integers such that:
a) Each positive integer appears at least once in the sequence a1, a2, ...;
4.2.
The fundamental theorem of arithmetic
153
b) an + am and an+m have the same set of prime divisors for all n, m 2 1.
Proof. We will prove in a sequence of steps that only the sequence an = n
is a solution of the problem. Note that if a prime p divides am, am, ..., ank,
then it also divides an1+n2, am, ..., ank and continuing like this we obtain that
p I an1+n2+..+nk-
First, we prove that a1 = 1. Otherwise, there is a prime p dividing a1.
Using the observation in the first paragraph, we obtain p I an for all n, con-
tradicting condition a). Hence a1 = 1.
Next, we prove that gcd(an,a,,+1) = 1 for all n. Suppose that this is not
the case and let n 2 1 and let p be a prime dividing an and an“. Then p also
divides am+y(.,,+1) for all m,y 2 0 (see the first paragraph). Now all integers
m 2 n(n + 1) can be written in the form am + y(n + 1) (see example 3.42),
so we obtain that all but finitely many terms of the sequence a1,a2,
are
multiples of p, contradicting again assumption a).
We are now ready to prove that Ian—an+1| = 1 for all n. Suppose that there
is n for which this is not the case, and choose a prime p dividing an — an“.
By hypothesis a), we can choose m 2 1 such that p | an + am. Then p | an+m
and also p I am + an“, thus p | an+m+1. This contradicts the fact that
n(an+m, an+m+1) = 1 (preVious paragraph).
The previous paragraph shows that an+1 6 {an — 1, an + 1} for all 17.. Since
an > 0 for all n and a1 = 1, we must have a2 = a1+1 = 2. We are now in good
shape to prove that an = n for all n. Indeed, assume that there is n such that
an+1 = an — 1. Since an.” = an — 1 and an + a1 = an + 1 have the same prime
factors, both an — 1 and an + 1 must be powers of 2 (as gcd(an — 1,an + 1)
divides 2) and so necessarily an = 3 and an+1 = 2. Repeating the argument
then yields an+2 aé an+1 — 1, so an+2 = an+1 + 1 = 3. But then an + a2 = 5
and an+2 = 3 don’t have the same prime factors, a contradiction. Hence
an+1=an+1for allnand finallyan=nforalln.
El
Example 4.43. (Kvant M 1863) Consider the sequence of positive integers
(an)n21 such that a1 = 1, a2 = 2 and for all n 2 3 the number an is the least
positive integer different from a1,a2, . . . ,a,,_1 which is not relatively prime
with an_1. Prove that this sequence contains all positive integers.
154
Chapter 4. The fundamental theorem of arithmetic
Proof. The solution is based on the following two lemmas:
Lemma 4.44. The sequence (an)n21 contains infinitely many even integers.
Proof. Assume the contrary, i.e there exists m such that am,am_1_1, am+2, . . .
are all odd. Since all terms of the sequence are different there exists k 2 m
such that ak < ak+1 and a1,a2,...,am_1 < ak. Let p be the least prime
divisor of ah. Then ak+1 2 ak + p since otherwise ak and ak+1 are relatively
prime. But ak + p is an even integer and therefore ak+1 > ah + p. This shows
that ak+1 is not the least positive integer different from a1, a2, . . . ,ak which is
not relatively prime with ak, a contradiction.
El
Lemma 4.45. If the sequence (an)n21 has infinitely many terms divisible by
a prime p then it contains all positive integers divisible by p.
Proof. Let k be a positive integer such that pic is not a term of the given
sequence. Let m be such that an > pic for all n 2 m. There is a term as of the
sequence divisible by p with s > m. The by the definition of as+1 it follows
that a3+1 3 pk, a contradiction.
El
Now we turn to the solution of the problem. By lemmas 4.44 and 4.45 the
sequence contains all positive even integers. Then by 4.45 it follows that for
every prime p the sequence contains all positive integers divisible by p. This
solves the problem.
CI
4.3
Infinitude of primes
Having seen several examples of prime and composite numbers, we will
focus on the problem of proving that there are infinitely many primes. One
obvious approach to this problem is to find explicitly a sequence that contains
infinitely many primes. This sounds easy, but it is not: for many sequences
that naturally appear in number theory it is not known whether they contain
infinitely many prime numbers.
4.3. Infinitude of primes
4.3.1
155
Looking for primes in classical sequences
One of the most natural sequences are polynomial ones, so let us start
with them. Let f (X) = a0 + alX + + aa be a nonconstant polynomial
with integer coeflicients and with positive leading coefficient an, so that f (k)
is a positive integer for k large enough. We would like to know whether the
sequence f(l), f(2),
contains infinitely many primes. There is an obvious
obstruction for this to happen: if there is an integer d > 1 dividing all the
numbers f (1) , f (2), ..., then there are only finitely many primes in the previous
sequence. Also, if we can write f as a product of two nonconstant polynomials
with integer coefficients, then again there can be only finitely many primes in
the sequence f (1), f(2),
A remarkable and wide open conjecture is that
these two obstructions are the only ones:
Conjecture 4.46. Let f be a nonconstant polynomial with integer coefi‘lcients
and positive leading coefiicient. Assume that:
a) there is no integer d > 1 dividing all the numbers f(l), f(2),
b) f is not the product of two nonconstant polynomials with integer coefi‘i—
cients.
Then f (n) is a prime number for infinitely many positive integers n.
To give a hint on how diflicult the previous conjecture is, let us mention
that there is not a single polynomial of degree greater than 1 for which the
conjecture is proved! There are also versions of the previous conjecture, which
involve several polynomials f1, ..., fk and ask that f1 (n), ..., fk(n) should be
simultaneously prime for infinitely many n. A famous such conjecture is
Conjecture 4.47. (Hardy-Littlewood' prime k-tuple conjecture) Let a1, ..., ak,
b1,...,b;c be integers such that gcd(aj,bj) = 1 for 1 S j S k and such that
for any prime p g k there is a: E Z such that p does not divide any of the
numbers alm + b1, ...,akw + bk. Then there are infinitely many 17. for which
aln + b1, ..., mm + bk are all prime numbers.
Remark 4.48. Granville proved the following amazing result: if the previous
conjecture holds, then there are infinite sets A, B of positive integers such that
for all a E A and b E B the number a + b is prime! Also, he proved that the
previous conjecture implies the existence of an infinite set A such that for all
156
Chapter 4. The fundamental theorem of arithmetic
a, b E A the number “T‘H’ is prime. It is known (this is a deep theorem of
Balog) that for any n there is a set A of n primes such that for all a, b E A
the number “7'” is prime, and all these prime numbers are pairwise distinct.
Even the case when f has degree 1 in conjecture 4.46 is highly nontrivial: in
this case the conjecture was proved by Dirichlet. Let us restate his remarkable
and very deep result:
Theorem 4.49. (Dirichlet ’s theorem) Let a, b be relatively prime integers with
a > 0. The arithmetic progression (an+b)n20 contains infinitely many primes.
One can also consider the problem of understanding the arithmetic progressions all of whose terms are primes. It is an easy exercise left to the reader
to check that there cannot be such an infinite arithmetic progression. On
the other hand one can produce arithmetic progressions of fairly large length
consisting exclusively of primes: the smallest 10-term arithmetic progression
consisting of primes is 199 + 210n for 0 S n S 9, the smallest 21-term arithmetic progression of primes is 5749146449311 + 26004868890n for 0 S n S 20,
and an arithmetic progression of primes with 26 terms is
4.3142746595714191 + 5283234035979900n
with 0 S n S 25. One can easily see that they involve huge numbers for the
common difference (and also the first term). The next example explains this
partially:
Example 4.50. (Thébault’s theorem) An increasing arithmetic progression of
length n > 2 consists of prime numbers. Prove that the common difference is
a multiple of the product of all primes less than n.
Proof. Suppose that a, d are positive integers such that a, a+d, ..., a+ (n— 1)d
are primes. We want to prove that any prime p < n divides d. Assume that
p < n does not divide d. Note that gcd(a,d) = 1, otherwise gcd(a,d) > 1
would divide both a,a + d and so a = a + d = gcd(a,d), a contradiction.
Since p does not divide n, the numbers a, a + d, ..., a + (p — 1)d give pairwise
distinct remainders when divided by p, so one of the remainders must be 0
and a+jd is divisible by p for some j 6 {0,1, ...,p— 1}. Since p S n, a +jd is
4.3. Infinitade of primes
157
a prime and so necessarily p = a + jd 2 a and a < n (since p < n). But then
a + ad = a(1 + d) is a prime and so a = 1, a contradiction with the fact that
a is a prime.
El
Here is a nice application of the result established in the previous example:
Example 4.51. (Tournament of the Towns 2007) Find all increasing arithmetic
progressions consisting only of prime numbers, such that the number of terms
is larger than the common difference.
Proof. Let a,a + d, ...,a + (n — 1)d be an arithmetic progression as in the
statement of the problem, so 77. > d. Let (pn)n21 be the increasing sequence of
primes and let k be such that pk < n S pk“. By Thébault’s theorem p1...pk
divides d and so
Plu-Pk S d < n S Pk+1~
If p1...pk > 2, then p1...p;c — 1 2 pk+1 since p1...p;c — 1 must have a prime
factor, and this prime factor cannot be p1,...,pk.
So if p1...p,c > 2, then
p1...pk > pk“, contradicting our assumption. It follows that p1...p;c = 2, then
k = 1 and n S 3. Hence we must have n = 3, d < n = 3 and a,a+d,a+2d are
all primes. If at = 1, this is impossible since a, a + 1 being primes forces a = 2,
but then a + 2 is not a prime. If d = 2, then a, a + 2, a + 4 should be primes.
One of these numbers is a multiple of 3 and this immediately implies that
a = 3. Hence the problem has a unique solution, the progression 3, 5, 7.
CI
The following amazing (and very deep) theorem was proved in 2004, solving
a problem that was open for at least 200 years:
Theorem 4.52. (Green— Tao) For any n 2 3 there is an arithmetic progression
of length n consisting of prime numbers.
Remark 4.53. Just to see how powerful this theorem is, let us mention a
few straightforward consequences which would be extremely hard to prove
otherwise. . .
a) For any n there is a set A of n primes such that for all a, b E A the
number “T'H’ is prime, and all these prime numbers are pairwise distinct. Here
is such a set for n = 12:
A = {71, 1163, 1283, 2663, 4523, 5651, 9311, 13883, 13931, 14423, 25943, 27611}.
158
Chapter 4. The fundamental theorem of arithmetic
As we have already mentioned, this is a theorem of Balog, proved before the
Green—Tao theorem. Using the Green-Tao theorem, this becomes a simple
exercise: consider an arithmetic progression a+ jd of primes for 0 S j S 2““,
and let A be the set of numbers a + (2j — 1)d for 1 S j S n.
b) It follows from Green-Tao that for any h and d one can find a polynomial
f with integer coeflicients of degree d such that f(0), f(l),..., f (k) are all
primes. Indeed, if a + jd are primes for 0 S j S 16“, the polynomial bXd + a
works. It is harder to solve the similar problem with monic polynomials.
0) Yet another consequence of the Green-Tao theorem: there are arbitrarily
large sets of integers A such that the average of the elements of any nontrivial
subset of A is a prime. Moreover, we can impose that these primes are pairwise
distinct.
Indeed, first without the restriction of the primes distinct, the construction
is easy: take an arithmetic progression of primes a + jd, O S j < k: := n . n!
and set
A: {a+jn!d|0 Sj < n}.
The average of the numbers a+jn!d for j E S C {1,2, ...,n} is a+d(zzes aflfi
and this is a number belonging to our arithmetic progression of primes, so it
is a prime: indeed
USMM <n-n!=k.
ISI
If we want the primes to be pairwise distinct we employ the following trick.
Consider a set B = {b1 <
< bn} such that all averages of all subsets of B
are pairwise distinct (for instance take b,- = (i + 1)! for 1 S i S n), then take
k = (bn — b1)n!, an arithmetic progression of primes a + jd as above and set
A = {a + (bj — b1)n!d|1 S j S n}. For instance, for n = 4 we have the set
5,17,89,1277, for n = 5 we can take the set
209173, 322573, 536773, 1217893, 2484733.
Already for n = 7 it is very difficult to write down an example of such a set!
Other important sequences that arise very often in arithmetic are sequences
of the form a" + 1 and a” — 1, where a > 1 is a fixed integer. One may wonder
4.3.
Infinitude of primes
159
when a” + 1, respectively a,” — 1 are primes, where for simplicity n > 1. Again,
there are a few easy obstructions for this to happen.
Assume first that a” — 1 is a prime and that n is composite, say n = mk
withm,k > 1. Thenam—1|a.”—1 andl <a,""—1 <an—1, thus an—l
is not a prime. Therefore if a” — 1 is a prime, then n is a prime. Moreover,
a—1|an—1 anda—l < an—l, thus necessarilya—l = 1 anda= 2.
In other words, the only possible primes of the form a” — 1 with a,n > 1
are those of the form 21’ — 1 with p a prime. However, it is not true that all
these numbers are primes: one can check that 23 | 211 — 1 and 47 I 223 — 1.
Prime numbers of the form 21’ — 1 are known as Mersenne primes. It is not
known whether there are infinitely many such primes, and it is not even known
whether the sequence (21" — 1),” where 1) runs over the prime numbers, contains
infinitely many composite numbers (one can prove that this is the case if there
are infinitely many primes p E 3 (mod 4) such that 2p + 1 is also a prime,
by proving that for such p the number 2p + 1 divides 2P — 1). The largest
Mersenne prime known in 2015 is 274207281 — 1, and 49 Mersenne primes are
known up to now!
Assume now that a" + 1 is a prime, with a,n > 1. If n has a proper odd
divisor m, then a% + 1 | a” + 1 and a“ + 1 is not a prime, contradiction.
Thus n is necessarily a power of 2. One very important case is when a = 2,
then we see that the only primes of the form 2“ + 1 are among the Fermat
numbers E, = 22" + 1. Here, the situation is much worse: again, it is not
known whether the sequence F0, F1,
contains infinitely many primes or infinitely many composite numbers, and we only know 5 primes in this sequence:
F0, F1, F2, F3, F4. This is in stark contrast with Fermat’s original conjecture
that all Fermat numbers are primes, a conjecture which was disproved by Euler, who proved that 641 [ F5 = 232 + 1 (actually F5 = 641 - 6700417; see also
example 2.12). The only Fermat numbers whose prime factorization is known
are F0, F1, ..., F11 (even though one knows that E, is composite for 5 S n g 32,
no prime factor of F20 or F24 is known!).
Yet another sequence which appears very often in number theory is (n!+ 1),,21.
Again, it is not known whether this sequence contains infinitely many primes,
even though one knows that it contains infinitely many composite numbers
(this would be hard to prove at this moment, but we will see later on that
160
Chapter 4. The fundamental theorem of arithmetic
n + 1 | n! + 1 when n + 1 is a prime, a result known as Wilson’s theorem,
and this immediately implies the desired result). We will however use this
sequence below to prove that there are infinitely many primes.
4.3.2
Euclid’s argument
We can summarize the discussion in the previous section by saying that
many of the natural sequences appearing in arithmetic are expected to contain infinitely many primes, but we are far from being able to prove such
a statement. Instead of dealing with such difficult (and most of them wide
open!) problems, we present in this section Euclid’s wonderful indirect argument proving there are infinitely many primes, some of the consequences
of the result and some related results that can be obtained with similar (but
more technically involved) arguments.
Theorem 4.54. (Euclid) There are infinitely many primes.
Proof. Note that 2 is a prime, so there is at least one prime. Assume that there
are only finitely many primes, call them p1, ...,pk, and consider the number
1 + p1 - - pk. It is greater than 1, so it is a product of primes. Choose one of
these primes and call it q. Then q 6 {p1, ..., pk}, since by assumption p1, ..., pk
exhaust all primes. In particular, q divides p1 - pk. But q also divides
p1 - - pk + 1, hence q divides 1, a contradiction with the fact that q > 1. The
result follows.
El
Remark 4.55. a) Start with a1 = 2 and define an.” to be the largest prime
divisor of 1 + a1a2...an. This sequence is not monotonic since am < a9. It is
not known whether this sequence contains all sufliciently large primes.
b) Consider the sequence whose nth term is 1 + p1 -p2 - - 1)“, where p1 <
172 <
is the increasing sequence of primes. The first 5 terms of this sequence
are all primes: 3, 7, 31, 211, 2311. However, the 6th term 1 +2-3-5 - 7- 11 - 13 is
composite (a multiple of 59). It is not known if this sequence contains infinitely
many prime numbers, or if it contains infinitely many composite numbers.
There are many other ways of proving that there are infinitely many primes,
based on theorem 4.13 (which ensures that every integer greater than 1 has
a prime factor). For instance, suppose that (113,.)121 is a sequence of integers
4.3.
Infinitude of primes
161
greater than 1 and pairwise relatively prime. Let pn be a prime divisor of
9:7,. Then 101, p2,
are pairwise distinct primes, thus there are infinitely many
primes. We know from the previous section how to construct many such
sequences (xn)n21: for instance xn = 22" + 1 the nth Fermat number, or
Sylvester’s sequence defined by :51 = 2 and xn+1 = :33, — :1:n + 1, etc.
The next examples either imitate or refine Euclid’s argument. Most of
them are crucially dependent on the uniqueness of the prime factorization of
an integer.
Ezrample 4.56. Let n > 2 be an integer. Prove that there are infinitely many
primes p such that 77. does not divide p — 1. In particular (by taking 77. = 3
and n = 4), there are infinitely many primes of the form 3k + 2 and infinitely
many primes of the form 4k + 3.
Proof. We will imitate Euclid’s argument. Note that 2 is such a prime. Next,
assume that p1, ..., pk are all primes p for which 77. does not divide p - 1. Then
N = npl...p;c — 1 is an integer greater than 1 and so it is a product of primes
N = q1...q,.. Since N is relatively prime to m, ..., pk, none of q1, ..., qr is equal to
one of the numbers p1, ...,pk, thus we must have q, E 1 (mod n) for 1 S 2' S r.
But then
N = q1...q, E 1
(mod n),
and since N E —1 (mod n), we obtain that n | 2, a contradiction.
III
Example 4.57. (Romania TST 2003) Let .9” be the set of all primes, and let
M be a subset of .9”, having at least three elements. Suppose that for any
proper subset A of M, all prime factors of —1 + HpeAp belong to M. Prove
that M = 5’.
Pmof. Taking an odd element p of M and considering p— 1, we see that 2 E M.
We will prove below that M is infinite, so let us take this for granted for a
moment and see how we can finish the proof. Suppose that there is an odd
prime p 9? M. Let p1, p2,
be the increasing sequence of elements of M and
consider the numbers p1 — 1,p1p2 — 1, p1p2p3 — 1,
Two of them must give
the same remainder when divided by p, and so we can find i < j such that
p divides p1...p¢ —p1...pj. Since p is not p1,...,p,- (as p g! M), 1) must divide
162
Chapter 4. The fundamental theorem of arithmetic
pi+1...pj — 1. But by assumption all prime factors of this last number belong
to M, contradiction. Hence M = .93.
Let us prove now that M is infinite. Assume the contrary and let p be
the smallest odd element of M, and let a: be the product of the elements of
M \ {2, p} (we are using here that M has at least three elements). All prime
factors of a: are greater than p and all prime factors of :1: — 1 and 2a: — 1 belong
to M, by assumption. It follows that 21: — l = p“ and :1: — 1 = 2p for some
a 2 1, b,c 2 0. Since an — 1 and 2a; — 1 are relatively prime, we must have
c = 0 and a; = 2” + 1, then p“ = 2"+1 + 1. If a is even, say a = 2k, then
(pk — 1)(pk + 1) is a power of 2, thus pk — 1 and pk + 1 are powers of 2 differing
by 2, so pk = 3 and p = 3. If a is odd, then (p — 1)(1 +p+
is impossible, since 1 + p +
+pa‘1) = 2"+1
+ p ‘1 is odd and greater than 1. Thus p = 3
and3 E M. We deducethat2-3—1 =5must bein M, and7 | 3.5—1
must divide a: = 2" + 1. This is impossible, since 7 does not divide 2" + 1 for
any b. This contradiction shows that M must be infinite and the problem is
solved.
III
Remark 4.58. A very similar problem was proposed at the USA TST in 2015:
let M be a nonempty set of primes such that for any nonempty subset N C M,
all prime factors of 1 + HpeN p are also in M. Prove that M is the set of all
primes.
Example 4.59. Let (001121 be a sequence of pairwise distinct positive integers.
Suppose that there are positive integers k, e such that an S 071'“ for all n 2 1.
Prove that there are infinitely many primes p dividing at least one of the
numbers a1,a2,
Proof. Suppose that there are only finitely many such primes, call them
p1,p2, ...,ps. Choose a large integer N > c and consider the positive integers in {1,2, ...,c2Nk}. There are at least 2N terms of the sequence among
these numbers, namely a1, ...,a2N. On the other hand, all these terms have
prime factors among p1, p2, ..., 1),, so can be written uniquely as pi” ...p? for an
s—tuple (:61, ..., m3) of nonnegative integers. Since pfl...p§3 S c ~ 21‘"6 < 2N<k+1)
and pfl...p§ 2 23" for all 72, we deduce that x,- < (k+ 1)N for all 75. Thus there
are at most ((k + 1)N)3 such s—tuples and consequently at most ((16 + 1)N)‘s
4.3. Infinitude of primes
163
numbers between 1 and c - 2N7“ all of whose prime factors are among p1, ..., p5.
Since a1, ..., a2N are such numbers, we deduce that
((k + 1)N)s 2 21".
This certainly does not hold if N is big enough: the left-hand side is smaller
than a constant times N3, but for N large enough 2” > N3+1 using the
inequality 2N > (8112) and the fact that (8112) is a polynomial expression of
degre s + 2 in N. The result follows.
El
Remark 4.60. As the proof clearly shows, it suflices to ensure that there is M
such that each integer occurs at most M times in the sequence (11, a2,
If f
is a nonconstant polynomial with integer coefficients, the sequence an = f(n)
has this property, so the previous result shows that infinitely many primes
divide at least one of the numbers f(1), f(2),
This gives an alternative
proof of theorem 4.67 below.
The existence of infinitely many primes is a very useful tool in constructive problems. Here are a few typical examples of problems whose statement
has nothing to do with primes and whose solution crucially depends on the
existence of infinitely many primes:
Example 4.61. (Tournament of the Towns 2006) For each positive integer n let
bn be the denominator of 1 + % + + ,1, when written in lowest terms. Prove
that bn+1 < bn for infinitely many n.
Proof. We will prove that n = p2 — p — 1 is a solution of the problem for
each odd prime p.
First, we claim that p does not divide bn+1.
Indeed,
the only fractions among %, ...,% whose denominator is a multiple of p are
1%, zip, ..., m, but their sum is a fraction whose denominator is not a multiple
ofp, since %+(p71155=1fi, 2ip+ZpT12E=flplT25’ etc.
Next, let an be the numerator of 1 + % +
+ i, so that
an+1 = _
an + —_
1
__
bn+1
bn
p(p _ 1)
Thus
% = PCP — 1)an+1 — bn+1
bn
P(P — 1)bn+1
164
Chapter 4. The fundamental theorem of arithmetic
H d = n(P(P — 1)an+1 - n+1,P(P — 1)bn+1), then d diVideS P20) — 1)2an+1
and p(p — 1)bn+1, hence d divides p2(p — 1)2. But p does not divide d, since it
does not divide bn+1. Hence d | (p — 1)2 and so
1009-1)
(P - 1)2
bin 2 bn+1— > bn+1~
The result follows.
Cl
Example 4.62. (IMO Shortlist 2011) Let n 2 1 be an odd integer. Find all
functions f : Z —) Z such that f (11:) — f (y) divides z” — y” for all integers ac, y.
Proof. It is clear that all functions of the form f(2:) = exd +c with e 6 {—1,1}
and d a positive divisor of n are solutions. We will prove that these are all
solutions of the problem. Note that if f is such a function, then f + c has the
same property for any integer 0, hence we may assume that f (0) = 0.
If p is a prime, then f(p)— f(0) divides p”, thus f (p) I p” and so f(p) = :tpd
for some sign i and some 0 g d S n. We deduce that there is a sign 5 and
some fixed 0 S d S n such that f(p) = epd for infinitely many primes, call
them 191 < p2 <
We may assume that 6 = 1, by replacing f with —f. Now
p‘li — pg divides p’f — p? by hypothesis, hence d divides n (by corollary 3.36).
Write n = kd.
We will now prove that f (2:) 2 ad for all :3. Fix an integer as. Then
f (as) — pf divides cc” — p? and it also divides f (3)“ — pg!" = f (33)" — 12?. Thus
f(:c) — pf divides f (33),“ — a)", and this for all i Z 1. Note that d gé 0, since
(1 divides n. Hence d > 0, and since f(51:) — pg divides f(w)k — 9:" for all i, it
follows that f (513),“ — as" has infinitely many divisors, thus it must be 0, and
then f (so) = (rd (since 72. is odd).
El
Example 4.63. (USA TST 2010) Let P be a polynomial with integer coefficients
such that P(O) = 0 and
gcd(P(0), P(1), P(2), . . .) = 1.
Prove that for infinitely many n
gcd(P(n) — P(O), P(n + 1) — P(1),P('n, + 2) — P(2), . . .) = n.
4.3.
Infinitude of primes
165
Proof. Let us try to study first
(1,, = gcd(P(n) — P(0), P(n + 1) — P(l), ...)
for any polynomial P with integer coefficients. Let q be a prime factor of dn,
so that P(n + k) E P(k) (mod q) for all k, i.e. P is n—periodic modulo q. But
P is also q—periodic modulo q. Thus, if gcd(q,n) = 1, then P is l—periodic
modulo q (by Bézout’s theorem) and so q divides P(n + 1) — P(n) for all n.
Then q divides P(n) — P(O) for all n, so if P(O) = 0, then q must divide
gcd(P(0),P(1), ...). In particular, for our polynomial we must have qln for
any prime factor q of dn.
The previous paragraph suggests taking for n a power of a prime, say
17. = pN. Then we saw that dn is also a power of p. Note that dn is a multiple
of 17., since 17. divides P(n + k) — P(k) for all Is. It remains to see if we can have
pN+1|P(k +pN) — P(k) for all k. Since1
P(k +pN) 5 P06) +pNP'(k)
(mod pN+1),
this would imply that p divides P’ (k) for all Is. Now we see how to choose our
numbers n: pick and fix once and for all a value k such that P’ (k) 75 0. If p is
sufliciently large, then p does not divide P’ (Is) For any such p, the previous
arguments show that dn = n for all n = p” . The conclusion follows.
El
Example 4.64. (Erdos) Let A be a set of n nonzero integers. Prove that A
contains a subset B with more than % elements, such that the sum of any two
elements of B (not necessarily distinct) is not an element of B.
Proof. Let the elements of A be a1,a2, ...,an and let p = 3k + 2 be a prime
number greater than max |ai| (such a prime exists thanks to example 4.56).
For any 75 E {1, ...,n} the numbers 04,204, ...,pa,‘ form a complete system of
residues modulo p (since a; aé 0 and kid < p). It follows that for each 1 S
i S 77. one can find 1:: + 1 numbers among (15, 2a,, ..., no”; which are congruent
to k + 1,k + 2, ...,2k + 1 modulo p.
1We recall that P' is the derivative of P.
166
Chapter 4. The fundamental theorem of arithmetic
For each 1 S j S p let Bj be the set of those a, for Which the remainder of
jai modulo p belongs to {k + 1, ..., 2k + 1}. It follows from the first paragraph
that
p
Z |l = (k + 1)n,
j=1
hence we can find 3' with Il Z fin > g. It remains to check that the
sum of two elements of Bj is not in Bj. Suppose that ac,y,z E B satisfy
:0 + y = 2. By definition the remainders of jx, jy, jz when divided by p are
in {k + 1, k + 2, ..., 2k + 1} and one of them is the sum of the remaining two.
This is clearly impossible, since no two elements of {k + 1, ..., 2k + 1} add up
to a third element of this set. Thus Bj satisfies all desired conditions.
III
Example 4.65. (Iran 2011) Find all sequences (an)n of positive integers such
that nan + mam + 2mn is a perfect square for all positive integers m, n.
Proof. The key is to prove that ap = p for sufficiently large primes p. Assume
that this is the case for a moment, and fix a positive integer 71.. By assumption
nan + 2111) + p2 is a square for all sufliciently large primes p, hence there is a
prime p0 and a sequence of positive integers (bp)1,,>p0 such that nan+2np+p2—
—
(p+bp)2. Then 2pbP+b2 = 2np+nan and so bp < n+nan. Hence the sequence
(bp)p>p0 is bounded and since p divides b2 — nan for all p > p0, it follows that
b%—
— nan for p large enough. But then the relation 2pbp + b2—
— 277.1) + nan
yields bp— n and finally an—
— 71.. Hence, modulo the initial claim, we find that
there is a unique sequence, namely an = n for all n.
Now, let us prove that ap = p for all large primes p. Since 2pap + 2p2 is a
square and a multiple of p, it must be a multiple of p2, hence p divides ap if
p > 2.
Next, we prove that nan is a square for all n. Indeed, fixing n and choosing
= (nan)2, we see that nan + mam + 2mn = nan(1 + man) for some integer
cc. Since nan and 1 + man are relatively prime positive integers and their
product is a perfect square, nan must be a perfect square.
Finally, by the previous two paragraphs we can write pap = (pa'p)2 for some
positive integer mp, and this holds for all primes p > 2. Since pap + 2p + a1 is
a square, it can be written as (pap + yp)2 for some positive integer yp. Now
4.3. Infinit'ade of primes
167
2pxpyp+yg = 2p+a1. If 2p > a1, then necessarily xpyp < 2, hence mp = 3],, = 1
and so (117 = p whenever 2p > a1 and p > 2. This finishes the proof.
El
Example 4.66. For any integer n > 1, let P (n) denote the largest prime divisor
of n. Prove that there are infinitely many positive integers n for which
P(n) < P(n+1) < P(n+2).
Proof. We will prove that for each prime p > 2 we can find k 2 1 such that
Pu?" — 1) < Pa”) =p < Pa?" + 1),
which will be enough to conclude. The numbers (p2k + 1)k are pairwise rel-
atively prime2 and not divisible by 4, so the sequence (P(p2k + 1))k21 is unbounded. Hence there is a smallest k for which P(p2k + 1) > p. We will
prove that P(p2k — 1) < p. Otherwise, there is a prime q 2 p such that
q | p22" — 1—
- (p— 1)(p+ 1)(p2+ 1).. (1)2k_1 + 1). Clearly q #1) and sincep is
odd and q > p, q does not divide p + 1. Thus q divides one of the numbers
172 + 1 with 1 < j < k, and P(p2j + 1) > p, contradicting the minimality of
k.
III
Here is yet another very short proof of the existence of infinitely many
primes. Consider the number 13,, = n! + 1. Since 23,, > 1, an has at least one
prime divisor, say 1)”. Since pn cannot divide 1, 2, ..., n (as otherwise pn divides
both n! and n! + 1, impossible), we must have 1),, > 17.. Hence the sequence
(pn)n21 has infinitely many distinct terms and the result follows. The proof
of the following very useful result is a variation on the previous argument:
Theorem 4.67. {Schur} Let f be a nonconstant polynomial with integer coefficients. There are infinitely many primes dividing at least one nonzero term
of the sequence f(l),f(2),f(3),
Proof. Let f(X) = a0 + a1X + +anX”, with an aé 0 and n 2 1. If a0 = 0,
then any prime p divides f (p) and f(p) aé O for all sufliciently large p, thus
the result is clear in this case. Assume that a0 aé 0 and observe that
f(aoX) = a0 + aoalX +
+ aganX" = a0(1 + a1X +
2This can be proved in the same way as for Fermat numbers.
+ ao‘lanX“).
168
Chapter 4. The fundamental theorem of arithmetic
The polynomial g(X) = 1 + a1X + + a3‘1anX'” is nonconstant, hence there
is an integer k0 such that for all a: 2 k0 we have lg(a:)| 2 2. Pick any prime pk
dividing g(kl), for k 2 k0. Then pk divides 906!) and k! | g(k!) — 1, thus pk is
relatively prime to k! and so pk > k. Moreover, pk divides f (ads!) for k 2 Ito
and since pk > k, the result follows.
[I
The following examples illustrate the previous theorem.
Example 4.68. (Iran 2004) Find all polynomials f with integer coefficients
such that f (m) and f (n) are relatively prime whenever m and n are relatively
prime positive integers.
Proof. Note that the polynomials :ls, with k 2 0 are solutions of the problem. We will prove that these are the only solutions. Let f be a solution and
write f(X) = Xkg(X) with k 2 0 and 9(0) aé 0. If g is constant, then clearly
this constant must be :|:1. Suppose that g is not constant, hence for infinitely
many primes p the congruence g(n) _=. 0 (mod p) has solutions. Choose such
p and n, with p relatively prime to g(O) aé 0 (since g(O) 9E 0, this holds for
all but finitely many primes p). Then p does not divide n, hence n and n + p
are relatively prime. But then f (n) and f (n + p) are relatively prime, which
contradicts the fact that p divides both of them (since p divides g(n), it also
divides g(n + p)). Thus 9 is constant and we are done.
El
Example 4.69. (Taiwan TST 2014) Let k be a positive integer. Find all polyno-
mials f(X) with integer coefficients such that f(n) divides (n!)’“ for all positive
integers n.
Proof. Replacing f with — f we may assume that the leading coefficient of f
is positive. If f is constant, then since f (1) | 1 we must have f (X) = 1, which
is a solution of the problem. Assume now that f is not constant, and write
f(X) = a0 + a1X +
+ adXd with ad > 0 and d 2 1. Let 9’ be the smallest
nonnegative integer such that aj aé 0, thus a0 =
= aj_1 = 0 and aj aé 0.
Then f(X) = n(X) with g(X) = aj + aj+1X + + adXd_j. Assume that
j < d, so that g(X) is nonconstant. By hypothesis g(n) | (n!)k and so for any
prime p | g(n) we have p | n! and p S 72.. Since 9 is nonconstant, theorem
4.67 yields the existence of infinitely many primes p dividing at least one of
4.3. Infinitude of primes
169
the numbers 9(1), 9(2),
Let p be such a prime and let n be the smallest
positive integer for which p | g(n). If r is the remainder of 71 when divided
by p, then p | g(n) — 9(1') and so p | g(r). If r > 0, then since 9(7‘) | (14)" we
must have p S r, impossible. Thus 7' = 0 and so p l 9(0). Thus g(0) = 11,- is
divisible by infinitely many primes and is nonzero, which is impossible. Hence
our assumption that j < d was wrong and f (X) = adXd. Since ad > 0 and
f(1) | 1, we obtain ad—
—— 1. Then nd | (n!)’° for all n > 1. Choosing n—
—pa
prime, we see that (n!)k—
— pk m with m not a multiple of p, thus pd | (p!)’°
forces d < k. Conversely, if d < k then clearly 71“ | (n!)k for all 71. Hence the
solutions of the problem are f(X) :|:Xd with d S k.
Here is a slightly different argument: assume that f is not constant and
has positive leading coeflicient. Thus if p is a large enough prime, we have
f (p) > 1. Let q be a prime factor of f (p) and assume that q 75 p. Write
p = qk +1" with 0 < r < q. Since q | f(p) = f(qk+ r), we have q | f(r) | 71’“.
This is impossible, since q is a prime greater than 7'. Thus q = p and so
p | f(p) It follows that p I f(0) for all large enough primes, thus f(0) = 0.
Thus we can argue like in the previous solution.
[I
Example 4.70. a) (Saint Petersburg 2001) Prove that there are infinitely many
positive integers n such that the largest prime divisor of n4 + 1 is greater than
211.
b) (IMO 2008) Prove that the largest prime factor of n2 + 1 is greater than
271 + \/ 2n for infinitely many positive integers 12..
Proof. a) By theorem 4.67 there are infinitely many odd primes p dividing at
least one of the numbers n4 + 1 with n 2 1. Let p be one such prime and let
n be the smallest positive integer such that p | n4 + 1. If r is the remainder
of 71 when divided by p, then r < p and p | r4 + 1. By minimality of n (note
that r > 0) we have n S 7', thus 71 S p — 1, and actually 71. < p — 1, since p
does not divide (p — 1)4 + 1 (as p is odd). Next, p | (p — 1 — 'n)4 + 1 and again
by minimality of n we have p— 1— n > n, that is p > 217.. Thus to any prime
p as above we associated a positive integer 11,, < 2 such that p | n; + 1. Since
714 > p— 1, as p varies the numbers 71,, form an unbounded sequence, and the
largest prime factor of n4 + 1 is at least p > 211p, solving the problem.
170
Chapter 4. The fundamental theorem of arithmetic
b) As above, start with an odd prime p dividing one of the numbers n2 + 1,
with n 2 1. Let n be the smallest such positive integer. As above, we obtain
17. S %1. Now writep= 2k+1 ands = [6—11 2 0. Thenp I 4n2+4=
(2k—2s)2 +4, hence p | (2.5+ 1)2+4. It follows that (23+ 1)2 +4 2 p = 2k+ 1,
thus 25 + 1 2 \/2k — 3. Now
p=2k+l=2n+2s+122n+V2k—3.
Let us prove that if p is large enough, then \/ 2k — 3 > \/2_n, which is enough
to conclude. The inequality x/2k — 3 > m is equivalent to k — 2 Z n or
s 2 2. Since p | (23 + 1)2 + 4, it suffices to take p > 32 + 4 = 13 for the
I]
argument to work.
Remark 4.71. We suggest the reader to try the following problem, proposed
for the USAMO in 2006: let P(n) be the largest prime divisor of n (with
P(:|:1) = 1 and P(0) = 00). Find all polynomials f with integer coeflicients
such that the sequence (P(f(712)) — 271),,21 is bounded above.
Example 4.72. (Romania TST 2013) Prove that infinitely many prime numbers
can be written as
(a%+a1 — 1)(a§+a2 — 1)...(a,2,+an— 1)
(b§+b1 —1)(b§+b2—1)...(b,2,+bn— 1)
for some positive integers 17., a1, a2, . . . ,an, b1, b2, . . . , bn.
Proof. Let 121,122,
be the prime numbers dividing at least one of the numbers
12 + 1 — 1, 22 + 2 — 1, 32 + 3 — 1,
We claim that p,- has the required form for
all t 2 1 and we prove this by strong induction on i. For t = 1 we have p1 = 5
(it is easy to see that 2 and 3 do not divide any n2 + n — 1) and this equals
%212%. Let S’ be the set of rational numbers of the form
(a%+a1—1)(a§+a2—1)...(afi+an—1)
(b§+b1—1)(b§+b2—1)...(b3,+b,,—1)
for some positive integers n, a1,a2,... ,an,b1,b2,...,bn and assume that
p1,...,pk_1 E S. Let us prove that pk E S. By assumption there is n 2 1
4.3.
Infinitude of primes
171
such that pk | n2 + n — 1. Let n be the smallest positive integer such that
pk | n2 +n— 1. Then n < pk — 1 and m = pk — (n+ 1) is a positive integer such
thatp;c | m2+m—1, thusn<mandn< $21. We deducethat n2+n— 1
is of the form pics for some 3 < pk. By definition, all prime factors of s are
among p1, ..., pk_1 and thus all prime factors of s are in 3. Clearly S is stable
under product, thus 3 E S and then
n2+n—1 1
=1T+Trr°ges°
Pk
4.3.3
5
Euler’s and Bonse’s inequalities
The following remarkable inequality goes back to Euler. It immediately
implies the existence of infinitely many primes, and we will see that it yields
a very strong estimate for the sum of the inverses of the primes not exceeding
n.
Theorem 4.73. (Euler) Let p1,p2, ...,pk be all primes not exceeding n. Then
101
-
101-1
p2
Pk
1
pk—l
p2—1
1
>1+-+...+—.
2
Proof. We have for all N Z 1
1
1
,-
gv
1+—+...+—=
hence
k
1—;Nl¥1‘
i
l—pl.
<
1
13%
—
p-7'
pi—l
,
k
'
1
1
>H(1+—+'"+—N)'
P1,
i=110i—1
i=1
pi
p,-
Expanding the product we obtain
k
o
>
p:
, _
11:1 pt
Z
4
(11
1
a]:
a1,...,ak€{0,l,...,N} p1 "'pk
On the other hand, by the fundamental theorem of arithmetic, all numbers
j E [1, n] can be written as a product of powers of primes. If j = q‘l"1...q$‘r is
172
Chapter 4. The fundamental theorem of arithmetic
the prime factorization of j, then max(q,') S j g n, hence q1,...,qr are among
p1, ...,pk. Moreover, n 2 j 2 2"“ > oa- for all i. Hence if we take N = n we
conclude that
_
> 1 + —1 +
1
fl
Z
2
a1,...,ake{0,1,...,N} pl "-171:
1
+ —.
n
y yields the desired result.
combining this With the first inequalit
|:|
Theorem 4.74. (Euler) For all n > 1 we have
1
z — > lnlnn — 1,
1751:
the sum being taken over all primes not exceeding n. In particular,
z — = 00,
1
p
p
i. e. the sum of the inverses of all primes diverges.
Proof. The inequality 3: 2 ln(1 + It) holds for all :1: 2 0. Using it, we obtain
11.
1
n
1
n
k; E 2 gm (1 + E) = gum“ 1) — ln(k)) = ln(n+ 1).
On the other hand, letting p1, ..., pk the primes not exceeding 71., we have (using
the inequality :1: S e3 — 1)
k
H
pi
i=1 pi _ 1
k
k
=H(1+
i=1
1
pi _ 1
k
1
>SHem+1=eEi=1pi——T_
i=1
Combining these inequalities with the one obtained in the previous theorem
we obtain
k:
MPH
((
))
>lnlnn+1.
4.3.
Infinitude of primes
173
It suffices therefore to prove that
or equivalently
’“
1
21MB
- 1) S 1'
«1:1
But since 1),- 2 i+ 1 we have
i 1 <2 1 4(1)“
,=1p¢(pi—1)',=lz'(i+1)
i=1 i
i+1
’
[3
asdesired.
Remark 4.75. The inequality established in the previous theorem is remarkably
strong. More precisely, one can prove (with quite a lot of work) that
,
1
131930 (E 5 — lnlnn) = 0.2614...,
19311
so in terms of growth the inequality is essentially optimal!
It will be convenient for the next examples and results to have a notation
for the nth prime.
Definition 4.76. If n is a positive integer, we let pn be the nth prime number,
thus p1 = 2 < 172 = 3 < p3 = 5 < 124 = 7 <
is the increasing infinite sequence
of primes.
Example 4.77. Prove that for all n 2 1 we have
2“: 1 < 49
—2
_[6:11)]:
100
174
Chapter 4. The fundamental theorem of arithmetic
Proof. For k 2 4 we have pk 2 2k — 1 hence pfi > 41606 —- 1) and so
i<l(;_l)
p%
4
[9—1
h
'
We deduce that
i1<1+1+1+i1(1
—2
k=1pk
_
4
—
9
—‘
25
_
16:44
_
k—l
1)<1+1+1+1
—
_
k
—
4
—
9
_
25
—-
12
The last expression is equal to 3+ fi and so we are reduced to checking that
g < 147% = 2%, which in turn is equivalent to 81 > 80.
III
Remark 4.78. The phenomena appearing in the last two examples are very
similar to the behavior of the sequence of positive integers: we have
n
1
Z —2 < 2
k=1 k
for all n 2 1, but there is no real number M such that
n
1
E E < M
k=1
for all n. In other words 2,321 % = 00.
Example 4.79. Let 1),, be the nth prime. Prove that
a)pn>2nforn25.
b) 1),, > 3n for n 2 12.
Proof. a) We prove this by induction. For n = 5 we have 105 = 11 > 2 - 5, so
assume that 1),, > 2n and let us prove that pn+1 > 2(n + 1). But pn+1 is odd
and greater than pn, which is also odd, hence pn+1 2 pa + 2 > 2n + 2, and the
result follows.
b) Again, we prove this by induction. A direct computation shows that
1012 = 37 > 3-12, so assume that pn > 3n and let us prove that pn+1 > 3(n+1).
As before, pn+1 2 p,,+2 2 3n+1+2 = 3(n+1). Since 3(n+1) is not a prime,
the previous inequality cannot be an equality and so pn+1 > 3(n + 1).
III
4.3.
Infinitude of primes
175
Remark 4.80. It is true, but not easy to prove that for any positive integer Is
there is my, such that for all n > 714, we have pn > kn. We will see a proof of
this result later on.
The next example uses a similar argument to Euclid’s one, but it is techni—
cally more involved. We will use it to give a very elementary proof of a famous
inequality of Bonse, and then give some interesting arithmetic applications of
this inequality.
Example 4.81. Prove that if n 2 4 then
P1P2---Pn _>_ ppn+n—2 + P1P2---Pn—1 + PnProof. Write the inequality as
P1---Pn—1(Pn - 1) — Pn Z ppn+n—1
and consider the numbers sch = kplpg...pn_1 — pn for 2 S k < pn. We need to
prove that xpri Z ppn+n—2.
First, note that p1...pn_1 — 1 is greater than 1 and is relatively prime
to p1,p2, ...,pn_1, so all of its prime divisors are at least pn, in particular
p1...pn_1 2pn+1 and so ark 2 2(pn+1) —pn =pn+1 for 2 S k <pn.
Next, we claim that the numbers wk are pairwise relatively prime. Indeed,
if a prime q divides wk and wj for some 2 S j < k < pn, then it divides
xk — acj = (k: — j)p1...pn_1. Now q 7E p1, ...,pn_1 since none of these primes
divide wk (as they don’t divide pn), so q | k — 3'. But then q < pn and so
q 6 {p1, ..., pn_1}, a contradiction.
Now, let qk be the smallest prime factor of 1:1,, then q2, ..., qpn_1 are pn — 2
pairwise distinct prime numbers by the previous paragraph, and they are all
larger than pn, since clearly 33k is relatively prime to p1...pn. Thus
ma-X(q2a ..., Qpn—l) 2 pn+pn—2
and thus
xpn—l 2 Ina-X012, ..., qpn—l) 2 pn+pn—2)
as desired.
El
176
Chapter 4. The fundamental theorem of arithmetic
Example 4.82. (Bonse’s inequality) For n 2 4 we have
P1P2---Pn > pi+1and for n 2 5 we have
p1p2-"pn—l > P12144-
Proof. One can check the first inequality for n = 4 without any problem, so it
suffices to prove the stronger inequality p1...p.n_1 > p3,+1 for n 2 5. Assume
first that n 2 12 and let k: [g] so 2k 3 n S 2k+1. Then k 2 6 and
P1---Pn—1 > Pin-P2134 > (P1---Pk—1)2Using the previous example, the last quantity is greater than P;k_1+k—3 and
so it suflices to check that pk_1 + k — 3 2 n + 1, or the stronger inequality
1016-1 + k — 3 2 210 + 2. This reduces to pk_1 Z k + 5 and is easily checked for
k 2 6. Hence the result is proved for n 2 12. Next, Note that
pi, = 412 < 2000 < 2 - 3 - 5 . 7- 11 =p1p2p3p4p5
hence the result holds for 5 S n S 12 too.
III
We illustrate the usefulness of Bonse’s inequality with two examples:
Example 4.83. a) Find the largest integer n > 3 such that any integer (strictly)
between 1 and n and relatively prime to n is a prime number.
b) Determine the largest odd integer n > 3 such that any odd integer
(strictly) between 1 and n and relatively prime to n is a prime number.
Proof. a) Let n be such an integer and let p1, p2, be the increasing sequence
of primes. Let m be the largest positive integer such that 132,, < n, so n S p12n+1.
Assume that m 2 4, then p1...pm > 19%,+1 2 n by Bonse’s inequality, hence n is
relatively prime to one of the primes p1, ..., pm, say with pj. Then p; 3 p3,, < n
is relatively prime to n and not a prime, contradiction. Thus m S 3 and so
n S P2 = 49. Assume that n > 25. Then n cannot be relatively prime to
4,9,25, hence n must be a multiple of 2,3 and 5 and so a multiple of 30.
Since 17. S 49, this yields 12. = 30. Conversely, the smallest composite number
4.3. Infinitude of primes
177
relatively prime to 30 is 49, so 30 has the desired property and so it is indeed
the solution of the problem.
b) The argument is similar: if n is such an integer and 17%, < n _<_ 10%;“,
then we cannot have m _>_ 5: otherwise 112.. .pm > pm+1 by Bonse’s inequality
and as above n is relatively prime to some p2- with 2 < j < m, contradicting
the hypothesis. Thus m < 4 and n < p5 = 121. Assuming that n > 49, we
see that n cannot be relatively prime to 9, 25, 49 and so n is a multiple of
3 . 5 - 7 = 105. Since n S 121, this yields n = 105. Conversely, the smallest
odd composite number relatively prime to 105 is 121, so 105 is the solution of
the problem.
III
Example 4.84. (Kolmogorov Cup) Find all odd primes p such that 1 + k(p — 1)
is prime for all k 6 {1,2, ..., g}.
Proof. One checks that p = 3 is a solution of the problem, so assume that
p 2 5. Suppose that q S g is a prime and that q does not divide p — 1.
Then we can find k 6 {1, ...,q} C {1,..., 13—1} such that q | 1 + k(p — 1), since
the numbers p — 1, 2(1) — 1), ..., q(p — 1) give pairwise distinct remainders when
divided by q. But then 1 + k(p — 1) is not prime, since it is divisible by q and
greater than q.
The previous paragraph shows that p — 1 must be a multiple of all primes
not exceeding PE—l. Let p1 = 2, p2 = 3,
be the sequence of primes and let m
be the largest positive integer for which pm 3 L31. Then p1...pm | p — 1 by
the above discussion, hence
p — 1 2 P1p2---PmIf m 2 4 Bonse’s inequality yields
p_1>p?n+1>(
10 —2 1 )1
2
which contradicts the assumption that p 2 5. Thus m S 3 and since %1 <
pm+1 we obtain p < 15. A tedious check shows that p = 3 and p = 7 are the
solutions of the problem.
[I
178
Chapter 4. The fundamental theorem of arithmetic
4.4
4.4.1
Arithmetic functions
Classical arithmetic functions
We will discuss in this section a few properties of some classical arithmetic
functions, such as the number of divisors of a given integer, its sum of divisors, the number of prime factors of that integer, Euler’s totient function, the
Mobius function, etc. Before saying anything more about specific arithmetic
functions, let us make clear what we mean by that:
Definition 4.85. An arithmetic function is a map f : N ——> C defined on the
set of positive integers, with complex values.
Readers not confortable with complex numbers can very well assume that
all arithmetic functions take real values (as will be the case in practice). Actually, most of the time we will deal with integer-valued arithmetic functions,
but it is useful to include more general functions as well (for instance, since
we will often consider the quotient of two integer-valued arithmetic functions,
or the square root of an arithmetic flmction).
From time to time it is more convenient to think of an arithmetic function
f is being defined on [1,oo), by defining f(a:) = f(La:_|) for a: 2 1. We will
always take this convention when writing f(as) for some x 2 1 (not necessarily
an integer) and some arithmetic function f. Note that we could have also
included 0 in the domain or f, or allowed negative integers, etc.
Let us give a few classical examples of arithmetic functions, which will also
allow us to introduce notation that will be used from now on constantly when
dealing with arithmetic functions.
1. One of the most important arithmetic functions is Euler’s totient function (,0, defined by letting <p(n) be the number of integers between 1 and
77. (inclusive) that are relatively prime to n. This fundamental function
will be studied in more detail later on in this section.
For example,
<p(12) = 4, since the numbers relatively prime to 12 between 1 and 12
are 1,5,7,11.
2. We define the arithmetic function ’1' by letting T(n) be the number of
4.4. Arithmetic functions
179
positive divisors of n. For instance 7(12) = 6 since the divisors of 12 are
1,2, 3,4,6, 12.
3. The function a is defined by letting 0(n) be the sum of the positive
divisors of n. For example 0(12) = 28.
4. The functions w and Q are defined by: w(n) is the number of different
prime factors of n (with the convention that w(1) = 0); 9(n) is the
number of prime factors of n, counting multiplicities, and deciding that
0(1) = 0. In other words, if n = pinup? is the prime factorization of
n, then
w(n) = s,
9(n) = 161 +
+ 163.
For instance w(12) = 2 and 9(12) = 3, since the prime factors of 12 are
2 (withmultiplicity 2) and 3 (with multiplicity 1). Note the very useful
identity
9(ab) = (2(a) + 9(b)
which holds for any integers a, b 2 1. On the other hand, the equality
w(ab) = w(a) + w(b) does not hold in general, but it does hold when a
and b are relatively prime.
5. One of the most important arithmetic functions is 7r, that counts primes
not exceeding n, in other words
7r(n) = Z 1
PSI
is the number of primes between 2 and n.
6. A very important function (studied in more detail in a later section) is
the Mobius function ,u. This has a rather exotic definition: “(1) = 1,
”(n) = 0 if n is not squarefree (i.e. if there is a prime p such that p2 | n)
and “(p1p2...pk) = (—1)’° for distinct prime numbers 121, ...,pk. In other
words
p(n) = (—1)“’(")
if w(n) = 9(n), ”(n) = 0 otherwise.
180
Chapter 4. The fundamental theorem of arithmetic
7. For any prime p one can define an arithmetic function 1),, by letting up (n)
be the exponent of p in the prime factorization of n. These functions
play a key role in the study of primes and congruences, and chapter 5
will be devoted to them.
. For each It 2 2, define a function r;c by setting rk(n) to be the number
of k-tuples of integers (m1, ...,:z:k) such that n = x? +
+ xi. These
functions also play a very important role in arithmetic, and we will find
later on an explicit formula for r2(n). Finding r3(n) is a much more
difiicult problem.
. If f is an arithmetic function, one can create two new arithmetic functions by setting
n
F(n) = Z f(k), GUI) = 21%)k=1
dln
Many difl'icult problems and theorems in analytic number theory are
concerned with the behavior of the functions F and G when f is one of
the functions introduced above.
10. More generally, if f and g are arithmetic functions, we can define a new
arithmetic function f * 9 (called the convolution product of f and g) by
f * g<n> = 2mg (3) ,
dln
the sum being taken over the positive divisors d of n. For instance
7' = 1 * 1, where 1 is the arithmetic function sending every n to 1, and
or = 1 * id where id is the identity function, sending every n to n. We
leave it to the reader to check that f*g = g*f and (f*g)*h = f* (g*h)
for any arithmetic functions f, g, h.
Before moving on to more theoretical results, let us discuss a few problems
that involve some of the previously introduced functions. The simple obserVation that when d runs over the positive divisors of n, so does 73 is a source
of many identities in number theory. We invoke this very simple but rather
useful observation to give a few more practical examples.
4.4. Arithmetic functions
181
Example 4.86. Prove that for all n > 1 we have
Hd=nfl2fl.
dln
Proof. If 1 = (11 < d2 <
< dk = n are the positive divisors of n, then so are
= dkdl = n, and multiplying
< %. Hence dld;c = d2dk_1 =
a < —_ <
these equalities yields
calculi,»2 = nk = nfin).
The result follows, since Hdln d = d1d2...dk.
El
Example 4.87. Show that if n + 1 is a multiple of 24, then 0(n) is a multiple
of 24.
Proof. First, we observe that n is not a square, since otherwise n + 1 would
not even be a multiple of 3. Thus the positive divisors of n can be partitioned
into pairs (a, b), with ab = n. Since 0(n) is the sum of the elements of these
pairs, it is enough to prove that a + b E 0 (mod 24) whenever ab = n. Now,
ab E —1 (mod 24), hence a and b are odd and relatively prime to 3. But if
a: is an odd integer relatively prime to 3, we have :32 E 1 (mod 24). Indeed,
x2 E 1 (mod 3) is immediate and m2 E 1 (mod 8) is classical. Thus ab E —1
(mod 24) implies a E ab2 5 -b (mod 24), which is the desired result a+ b E 0
(mod 24).
El
Example 4.88. (IMO 2002) Let n 2 2 be a positive integer with divisors
1 = d1 < d2 <
< dk = n. Prove that d1d2 + d2d3 +
than 712, and determine when it is a divisor of n2.
+ dk_1dk is less
Proof. Since d,- - dk+1_,- = n, we can write
n
n
n
d1d2+d2d3+u-+dk_1dk=d—km
n
It suflices therefore to prove that
1
l
d1d2
d2d3
—+—+ +
'n.
n
mm+u.d—2d—l.
die—Idle
<1.
182
Chapter 4. The fundamental theorem of arithmetic
However, we have d,- 2 11, since the sequence d1, ...,dk is strictly increasing.
Hence
1
—-
1
1
—
1
1
<—
——
1
——
d1d2+d2d3+ +dk_1dk—1-2+2-3+ +(k—1)k
1 1 1
1
1
1
—1—§+§—§+H.+kT—E—l-E<l
Now, suppose that S’ = d1d2 +
+ dk_1dk divides n2 and observe that
n2
n2
n
K S S die—Idle ‘E—‘b'
Now by definition d2 is the smallest prime divisor of n, which is also the
smallest prime divisor of n2. On the other hand, the above inequality shows
that "g2 is a proper divisor of n2 which does not exceed d2. It follows that
"g = d2 and S = dk_1dk, that is k = 2. Hence n = d2 is a prime. Conversely,
if n is a prime, then S = n divides n2. Thus S divides n2 if and only if n is a
prime number.
U
The next problems are related to the function (2.
Example 4.89. (China TST 2013) For a positive integer N > 1 with prime
factorization N = 19$”n - ~ - 1):", we define 9(N) = a1 + a2 +
+ ak. Let
a1, a2, . . . ,an be positive integers and let f(:t:) = (a: + a1)(a: + a2) - - - (a: + an).
Prove that if (2(f 06)) is even for all positive integers k, then n is even.
Proof. Since 9(ab) = (2(a) + 9(b) for all integers a, b > 1, it follows from the
hypothesis of the problem that 9(f(11:1) f(5%)) is even for all positive integers
11:1, ..., xk. One easily checks that
n
f(1) - fif(a,; + 2): 2" - fl(a.- + 1)2
i=1
We deduce that (2(2") = n is even.
i=1
H
(at- + aj + 2)2
lgi<j5n
El
4.4.
Arithmetic functions
183
Example 4.90. (Romanian Masters in Mathematics 2011) Given a positive
8
integer n with prime factorization n = H pf", let Mn) = (—1)°‘1+'"+°‘8. Prove
i=1
that:
a) There are infinitely many positive integers n such that
Mn) = Mn + 1) = 1.
b) For infinitely many n we have Mn) = Mn + 1) = —1.
Proof. We start by observing that a) = Mm) oMn) for all positive integers
m, n, and that Mn2) = 1 for any positive integer n.
a) Note that M9) = M10) = 1, so there are certainly positive integers n
such that Mn) = Mn + 1) = 1. Assume that there are only finitely many such
n, so there is N > 1 such that if n > N then one of the numbers Mn) and
Mn + 1) is different from 1. If a > N + 1, then Ma2 — 1) cannot be 1, since
Ma?) = 1. Thus Maz— 1) = —1 and so Ma—1)+Ma+ 1) = 0 for a > N+1.
In particular Ma) = —Ma + 2) = Ma + 4) for a > N + 1. If a: > N + 1, we
deduce that
1 = M4332) = M4532 + 4) =
= A(4$2 + 4x) = M(2z + 1)2 — 1) = —1,
a contradiction.
b) It is again not difficult to find explicitly one such n, since M2) = M3) =
—1. Assume that there are only finitely many such n, thus there is N > 1 such
that for n > N at least one of the numbers Mn) and Mn + 1) is not —1. Take
k > N + 1 such that M219 + 1) = —1, for instance k = g with p > 2N + 3
a prime. Then )‘(2k) = 1 and so Mk) = —1. But then Mk + 1) = 1 and so
M2k + 2) = —1 = M2k + 1), a contradiction.
D
Remark 4.91. The problem can be also easily solved using the Pell equation.
The equation x2 — 6y2 = 1 solves part a): if (:13, y) is a solution of the equation,
then clearly
I = M322) = M6312) = M332 —— 1).
For the second part, we use the equation 3:52—23;2 = 1, which also has infinitely
many solutions.
184
Chapter 4. The fundamental theorem of arithmetic
Example 4.92. (IMO Shortlist 2009) A positive integer N is called balanced if
N = 1 or if N can be written as a product of an even number of not necessarily
distinct primes. Let a, b be positive integers and let P(x) = (ac + a) (a: + b) for
each positive integer x.
(a) Prove that there exist distinct positive integers a and b such that all
numbers P(1), P(2),. . ., P(50) are balanced.
(b) Prove that if P(n) is balanced for all positive integers n, then a = b.
Proof. Let 9(n) be the number of prime divisors of n, counted with multiplicities. Then 72 is balanced if and only if 9(n) is even. We have already seen
that 9(ab) = 9(a) + (2(b) for all positive integers a, b. Thus, (2(a) and 9(b)
have the same parity if and only if ab is balanced.
a) Our aim is to prove the existence of a, b such that 9(a + 2') and 9(b + 72)
have the same parity for all 1 S 2' S 50. This is a simple application of
the pigeonhole principle: for each positive integer a consider the sequence
(:51 (a), ..., x5o(a)), where xi(a) is the remainder of 9(a + i) when divided by
2. Since there are infinitely many positive integers and only finitely many
sequences of length 50 with entries in {0,1}, two positive integers a,b will
have the same associated sequence. This is just another way of saying that
9(a + 2') and 9(b + i) have the same parity for all 1 S 2' g 50, so we are done.
b) Suppose that a aé b and, without loss of generality, that a < b. By
assumption Q(n+a) E Q(n+b) (mod 2) for all n _>_ 1, thus (2(k) E Q(k+b—a)
(mod 2) for all k 2 1. It follows that 9(k) E 9(k + j(b — a)) (mod 2) for all
19, j 2 1. In particular
Q(b(b—a)) E Q(b(b—a)+b(b—a)) = Q(2b(b—a)) = 1+Q(b(b—a))
which is certainly absurd.
4.4.2
(mod 2),
I]
Multiplicative functions
A very important class of arithmetic functions is that of multiplicative
(respectively totally multiplicative) functions, which we define as follows:
Definition 4.93. An arithmetic function f is called multiplicative (respec-
tively totally multiplicative) if f(mn) = f (m) f (n) for all relatively prime
positive integers m, n (respectively for all positive integers m, n).
4.4.
Arithmetic functions
185
Let us make a few simple remarks about multiplicative functions. First,
note that any totally multiplicative function is multiplicative, but the converse
is false. Also, note that if f is a multiplicative function, then
f(n) =f(n-1) =f(n)f(1)
for all positive integers n, thus either f vanishes identically or f (1) = 1. Thus
all interesting multiplicative functions f satisfy f (1) = 1. Secondly, if f is a
multiplicative function, then f is uniquely determined by its values on prime
powers, since any positive integer can be written as a product of powers of
primes, and
f ’1‘1-~p§")= f(P'f‘)-~f(p§")
for all pairwise distinct primes p1, ..., pn and all nonnegative integers k1, ..., kn.
A very useful consequence of this observation is that if we are asked to prove
that two multiplicative functions f, g are equal, then it suffices to check that
they agree on prime powers (which is usually much easier to check in practice!).
Many important arithmetic functions are multiplicative. The next simple
theorem establishes the multiplicative character of the functions 7' and a, by
giving explicit formulae for r(n) and 0(n) in terms of the prime factorization
of n. These formulae are very important when dealing with these functions.
Theorem 4.94. If n = p‘f‘lpgz...pg,m is the prime factorization of n > 1, then
r(n) = (a1 + 1)(a2 + 1)...(am + 1)
and
m
=||1+ -+...
.
9" =
(1+1
p11
—1
pg?" +1 —1
i=1
Proof. The fundamental theorem of arithmetic allows us to describe all positive
divisors of n = p‘l"1pg‘2...pg,m. Namely, they are exactly all numbers pfl ...n
for some fll 6 {0,1,...,a1},..., flm E {0,1,...,am} (and two such divisors are
equal if and only if the corresponding m—tuples (31, ..., fim) and (,Bfi, ..., 3;”) are
equal). Since ,6,- can take a,- + 1 possible values, the formula for r(n) is clear.
For 0(n) we obtain
0(n)=
Z
Z
03131501 03/323012
Z
OSfimSam
pfl...p§,m
186
Chapter 4. The fundamental theorem of arithmetic
=( 2 pg).....( 2 p51,“)
OSfi1Sai
OSflmSam
and the result follows using the identity
n+1 _ 1
1+x+...+xn=$—.
:1: — 1
III
The next problems illustrate the use of the previous explicit formulae for
the 7' function.
Example 4.95. Prove that r(n) is odd if and only if n is a perfect square.
Proof. If n = p‘l‘1 mpg" is the prime factorization of n, then
r(n) = (a1 + 1)(a2 + 1). . . (a;c + 1)
is odd if and only if each factor a; + 1 is odd, that is if and only if each a; is
even. This is of course equivalent to n being a square.
El
Example 4.96. (Belarus 1999) Let a, b be positive integers such that the product of all positive divisors of a equals the product of all positive divisors of b.
Prove that a = b.
Proof. By assumption and example 4.86 we have a"'(“) = bf“). This immediately implies that a and b have the same prime factors, call them p1, ..., pk. Let
a = pfkpfi" and b = pinup? for some positive integers 1:1, ...,:ck,y1, ...,yk.
The equality of”) = 57(1)) forces xir(a) = yi7'(b) for all 2'. Let
T(a)
7(1))
u = ‘gcd(T(a),T(b» and ” = gcd<T(a>,T<b))’
so that gcd(u,v) = 1 and um = vyi. We deduce that yi = uzi and ca; = 1221for some positive integers 2i. Thus
a = (pfl...pz")",
b .= (pfl...p:")”.
Clearly, if u > 1) then
7(a) = (1 + uzl)...(1 + uzk) > (1 + vzl)...(1 + 122k): r(b)
4.4. Arithmetic functions
187
and so of“) > b7“). Similarly we cannot have u < '0, thus u = 12, xi = yi for
all i and finally a = b.
1:]
Example 4.97. Prove that for all n > 1 we have
'r((n—1)!)_> ”’(g')
Proof. If n is a prime, then it and (n — 1)! are relatively prime and so the
proposed inequality is an equality. Assume from now on that n is composite
and write
pal:
n=p11...p
for its prime factorization (note that pi < n for all i). Write
b -qf1...q§’,
(n — 1)! = p21...pk’°
where qz- are the primes not exceeding n — 1 and not belonging to {p1, ..., pk}.
k
k
Then
7'02!)
_
ai+bi+1_
T((n—1)!)_g
bi+1
_£‘[(
bi+1)
We need to prove that this expression is S 2. Note that since pi | n, the
numbers pg, 213,-, ..., (1% — 1) pi appear in the product defining (n — 1)!, thus
“2'
fl: aipi
b +1" 3%
n
Letting x,- = pg“, we have xi 2 2 for all i, n = 301...:131c and 9:1, ..., ark are pairwise
distinct integers. Moreover, we clearly have
=p¢ pa‘ 1>pr2““1>a¢pi.
It is thus sufficient to prove that
188
Chapter 4. The fundamental theorem of arithmetic
This is clear if k = 1. For k 2 2 it follows by an easily noting that the
inequality
(1+E)
(1+g)
31+fl
n
n
n
rearranges to %+ 5 +% S 1. Since for k 2 2, we have 11:1 _>_ 2, x2 2 3,
and n 2 6, this inequality holds for :1: and y any nonempty product of mi’s.
Iterating this gives
k
H(1+fl)gl+w=2.
i=1
n
III
n
Example 4.98. (China TST 2015) For n > 1 define
f(n) = T(n!) — T((n — 1)!).
Prove that there are infinitely many composite numbers n such that for all
1 < m < n we have f(m) < f(n).
Proof. We try some of the simplest possible composite numbers, namely 'n, =
2p with p > 2 a prime. We will prove that they are all solutions of the problem.
Let us compute first f (2p) = r((2p)!) — 7((2p — 1)!). Note that (2p — 1)! is
divisible by p exactly once, so we can write (219 — 1)! = pa: with at relatively
prime to p. Then (2p)! = 2p% and so
f(210) = T(2p2x) — T0006) = 7(102)T(2w) - T(P)T(x) > 3T(m) - Mm) = 7(96),
the inequality being a consequence of the fact that 7'(2:1;) > r(x). It is thus
enough to prove that for each m E {2, 3, ..., 2p — 1} we have f(m) g r(a:). By
example 4.97 we know that
T(m!)
“"03
thus we are done.
2
T((2p—1)!)_T(px)
S
2
_
2
= re),
El
4.4. Arithmetic functions
189
We will give now another argument for the multiplicative character of the
functions ’7’ and 0, since this argument applies in many other situations. Note
that
’r(n) = 21,
0(n) = 2d
d|n
dln
and that the constant function 1 and the identity function are obviously multiplicative. The next theorem immediately implies that 7' and o are multiplicative. Before stating this theorem, we recall that if f, g are arithmetic
functions, the convolution product f * g of f and g is defined by
(f*g)(n)= (12%d—)
Theorem 4.99. The convolution product of two multiplicative functions is a
multiplicative function. In particular, if f is multiplicative, then the function
F defined by
F(n) = X: f(d)
dln
is also multiplicative.
Proof. Suppose that f and g are multiplicative and let m, n be relatively prime
positive integers. Then each positive divisor d of mn can be uniquely written
d = d1d2, with d1, d2 positive divisors of m and n respectively. This follows
easily from the fundamental theorem of arithmetic and from Gauss’ lemma.
Hence we can write
f*g(mn)= :ruuC—Z—”)= z f(d1d2)g<— 0%)
dlmn
d1|m,d2|n
Now, note that since gcd(m, n) = 1, we also have
— 1 and gcd (d—1,d—2) = 1.
gcd(d1,d2)-
Thus using the fact that f and g are multiplicative we obtain
f*g(mn)=
Z f(d1)f(d2)g(';£ )9 (6%)
d1|m,d2|n
190
Chapter 4. The fundamental theorem of arithmetic
=Zf(d1)g(—1d) Zf<d2)g(d3)=f*g(m)-f*g(n),
d1|m
proving that f * g is multiplicative.
El
Example 4.100. (Liouville’s theorem) Prove that for all positive integers n,
2
Z T(d)
= Z T(d)3.
dln
dln
Proof. Both sides are multiplicative fimctions of n by the previous theorem,
hence it suffices to prove the equality when n is a power of a prime p, say
n = pk. Then
“I. (k+1)(k+2)
27(d)= ZTWP Zr =f
and
j=1
j=0
dln
k 1
+
.3_(k+1)2(k+2) 2
3_
211d) — A: J — —4
.
dln
J—l
The result follows.
III
We end this section with some miscellaneous problems in which the concept
of multiplicative function plays a crucial role.
Example 4.101. (Balkan Mathematical Olympiad 1991) Prove that there is no
bijection f : N —> {0,1,2,...} such that for all m,n E N
f(mn) = f(m) + f(n) + 3f(m)f(n)Proof. Assuming that such a bijection f exists, define g(n) = 3f (n) + 1 and
let S be the set of positive integers congruent to 1 mod 3. Then 9 : N —> .S'
is a bijection such that g(mn) = g(m)g(n) for any m, n E N, i.e. g is totally
multiplicative, in particular g(l) = 1. Let p, q,r 6 N be such that g(p) = 4,
g(q) = 10 and g(r) = 25. Since any of the numbers 4, 10 and 25 is not a product
4.4. Arithmetic functions
191
of two numbers from the set S \ {1} and since 9 is totally multiplicative, it
follows that p, q and r are distinct prime numbers. On the other hand,
90”) = 9(1))90") = 102 = 92(q) = 9(42)
and so pr = q2, a contradiction.
El
Example 4.102. (Turkey 1995) Find all surjective functions f : N —> N such
that for all m, n E N we have m | n if and only if f(m) | f(n).
Proof. Note that f is injective, since f(m) = f(n) forces m | n and n | m,
thus m = n. Next, f (1) | f (n) for all n 2 1 and since there is n such that
f(n) = 1, we deduce that f(1) = 1.
Let m,n be relatively prime positive integers. Then f (m) and f (n) are
relatively prime: if they had a common divisor d > 1, then d = f (k) for
some k > 1 and then k divides both m and n, a contradiction. Next, since
f(m) and f(n) both divide f(m'n), We deduce that f(m)f(n) | f(mn) On
the other hand, f (m) f (n) = f (c) for some 0 2 1, and c is a multiple of m and
n, thus a multiple of mm. But f(c) I f (mn), thus 0 | mn and finally 0 = mn.
In other words, f (mn) = f (m) f(17.) when m,n are relatively prime and so if
n = plfl...p,'3' is the prime factorization of n, then
f(n) =f ’fl)~.f(p§").
It remains thus to understand f (pk) when p is a prime and k: 2 1. Note
that f (p) > 1 = f (1), since f is injective, and f (p) has no proper divisor:
if d was such a divisor, then d = f(c) and c would be a proper divisor of p,
impossible. Thus f (p) is also a prime. Conversely, if f (n) is a prime for some
n, then n is a prime (same argument as above). Thus the restriction of f to
the set of prime numbers is a permutation of this set.
Finally, we will prove that f (pk) = f (p)k for any prime p and any 19 '2 1,
by induction on k. Assume that f(p7 ) = f(1))? for 1 g j S k — 1. Then f(pk)
is divisible by f(p)’°"1 and its divisors are precisely f(c) with c I pk, that
is the numbers 1, f(p), ...,f(p)k‘1,f(pk). We deduce from this that f(pk) =
f (p)""1 - f(p) = f (12),“ and the inductive step is finished.
192
Chapter 4. The fundamental theorem of arithmetic
The previous discussion shows that there is a permutation (ap)p of the set
of prime numbers such that
f(n) = H a;p(n)_
pln
Conversely, it is clear that any such function is a solution of the problem.
III
Example 4.103. (IMO Shortlist 1996) Find a bijection f: {0,1,2,...} —>
{0, 1, 2, ...} that satisfies
f(3mn+m+n) = 4f(m)f(n) + f(M) +f(n)
for all m,n 2 0.
Proof. Note that the condition can be written
f ((3m+ 1)(3n+ 1) - 1) _ (4f(m) + 1)(4f(n) + 1) — 1
3
_
4
'
Letting A = {3k + 1] k 2 O}, the previous relation suggests defining a function
h: A —> {1,2,...} by
h(x) =4f (9:1) +1.
The problem is then equivalent to constructing a bijection h between A and
the set B = {4k + 1| 1:: 2 0} such that h(mn) = h(m)h(n) for all m, n E A.
We set h(1) = 1 and consider the set U of all primes of form 3k — 1, the
set V of all primes of form 3k + 1, the set X of all primes of form 4k — 1 and
finally the set Y of all primes of form 4k + 1. By Dirichlet’s theorem each
of the sets U, V,X,Y is infinite. (An elementary proof of this for U and X
was given in example 4.56. For V and Y an elementary proof will be given in
example 5.31.) Thus we can construct a bijection h1 between U and X and
a bijection ’12 between V and Y (to do so, enumerate in increasing order the
elements 11.1 < uz <
and 11:1 < 51:2 <
of U, respectively X, and map 11.1 to
$1,119 to $2,...) Ifn e A and
k
l
n=Hu?‘-v‘
i=1
i=1
4.4.
Arithmetic functions
193
is the prime factorization of n, define
k
l
h(n) = II h1('u,,;)“" - II h2('v,-)b".
i=1
i=1
Note that h(n) E B, since 219:1 a,- is even (because n E 1 (mod 3) and U, E —1
(mod 3), while 1;,- E 1 (mod 3)) and h1(u,-) E —1 (mod 4), while h2('v,-) E 1
(mod 4) for all 1'. One can construct an inverse h‘1 of h using the inverses
of h1 and h2 on X and Y, using exactly the same recipe and arguments as
above.
El
Example 4.104. (IMO 1998) Consider all functions f : N —> N such that
f(n2f(77%)) = "#002
for all m, n e N. Find the least possible value of f (1998).
Proof. Let f be such a function and define a = f (1) Since f (f (m)) = azm
and f ((1712) = f ('n)2 for all m,n (set 77. = 1 and m = 1 in the given relation),
we obtain
f(m)2f(n)2 = f(m)2f(an2) = f(m2f(f(¢m2)))—
— f(m27103 2)—
— f(amN)2,
i.e. f (m) f (n) = f (amn). In particular, f (am) = af (m) and therefore
af(mn) = f(m)f(n)An immediate induction then shows that f (n)’° = ak‘1f(n’°) for all k, thus
ak—1 | f (n)k for all k. If p is a prime factor of a and if a, ,8 are the exponents
of p in the prime factorization of a, respectively f (n), we obtain (k — 1)a S k3
for all k 2 1, thus a S ,B. It follows that a divides f (n) for all n E N, hence
the function
g:N——>N,
g(n)= f_(n)
is well-defined and satisfies
9(mn) =g(m)g(n) and g(9(m)) =m
194
Chapter 4. The fundamental theorem of arithmetic
for all m,n E N. In particular, 9 is bijective, and moreover 9 maps prime
numbers to prime numbers. Indeed, if p is a prime and 9(1)) = ab for some
integers a,b > 1, then p = 9(9(p)) = g(a)g(b), thus 9(a) = 1 = 9(1) or
g(b) = 1 = 9(1), contradicting the injectivity of 9. Letting P be the set of
prime numbers, we obtain that g : P —) P is an involution, i.e. 9(9(p)) = p.
Conversely, given an involution 9 of P and a E N, one obtains a map f as in
the statement of the problem by defining f(n) = a9(n), where 9(1) = 1 and
k
902) = H 9(a)“
i=1
if n = [Ii-L11)? is the prime factorization of n > 1.
Finally, observe that since 9(2), 9(3) and 9(37) are different prime numbers,
we have
9(2)g(3)39(37) 2 3 - 23 - 5 = 120,
hence
f(1998) = f(2 - 33 ~37) = f(1)9(2)y(3)3g(37) 2 120.
In order to see that this lower bound is attained, set
a = f(1) = 1, 9(2) = 3, 9(3) = 2, 9(5) = 37, 9(37) = 5
and g(p) = p for all prime numbers 1) 75 2,3, 5, 37. Then g(g(p)) = p for
all p e P and as we said above these data determine uniquely a function
f : N —-> N with the desired properties. Thus the answer of the problem is
120.
III
4.4.3
Euler’s phi function
In this section we study in more detail the fundamental totient function
(,0 : N ——> N. Recall that <p(n) is the number of integers between 1 and n
(inclusive) that are relatively prime to n. The map <p is called Euler’s totient
function or Euler’s phi function, while an integer a 6 {1,2, ...,n} which is
relatively prime to n is called a totative of n.
Clearly 90(1) = 1 and <p(p) = p — 1 for any prime p, since the totatives of p
are 1, 2, ..., p — 1. More generally, if n 2 1 and p is a prime, then the totatives
4.4. Arithmetic functions
195
of p" are the numbers in { 1, 2, ..., n} which are not divisible by p. Since there
are Ian—1 multiples of p in {1,2, ..., n}, it follows that
90(1)") =1)" -p“‘1 = pn‘1(p — 1) =p" (1 — i).
We will now explain how to find a closed formula for <p(n), using a combinatorial argument based on the following very useful result (we denote by |A| the
number of elements of a finite set A).
Proposition 4.105. (inclusion-exclusion principle) For any family of finite
subsets A1, ...,Ak of a set X we have
I:
k
UAz'
= Z|Ai| —
i=1
i=1
Z
|A¢uAj| +
+ (—1)k‘1|A1 n... nAk|.
igi<jsk
Proof. If B C X is a subset and a: 6 X, let 13563 be equal to 1 if a: E B
and 0 otherwise. Then clearly |B| = ZmeX 1:363 if B C X is finite and
136310”.a = 1x631 - 1$€Bd for all subsets 3,31,...,Bd of X. Let R be
the right-hand side of the equality we want to establish. Then using the above
observations we obtain
k
R= 2
136A,- — 2 136A,- '1zeA,- +
26X i=1
i<j
+ (_1)k—11$€A1 -... ' lmeAk -
Using the identity
k
+ (-1)"‘121...zlc = 1 — (1 — 21)...(1 — 2k)
2% — Zzizj +
i=1
i<j
k
we obtain
36X
i=1
On the other hand, it is clear that for all a: E X we have
In
1 _ H(1 — lzeAi) = lzeAlU...UAka
i=1
196
Chapter 4. The fundamental theorem of arithmetic
thus
R = Z 1w6A1U...UAk = [Al U
U Akl,
meX
D
as needed.
We are now ready to prove the following crucial theorem.
Theorem 4.106. For all n > 1 we have
1
<p(n)=n'H(1-p7),
pln
the product being taken over all prime divisors p of n, without multiplicities.
Thus, if n = pinup?" is the prime factorization of n, then
Mn) = pil'1---p2’°_l(m - 1)---(pk - 1)Proof. Let n > 1 and let it = pinup?" be the prime factorization of n. Then
an integer a 6 {1,2, ...,n} is a totative of n if and only if a is not divisible by
any of the numbers p1, ...,pk. Equivalently, if A,- is the set of multiples of pi
among 1, 2, ..., n, then the set of totatives of n is precisely the complement of
U121 A,. It follows that
k
<p(n) = n — U A4 .
i=1
We use the inclusion-exclusion principle to evaluate |U£°=1 Ail. For this, we
need to evaluate the number of elements of Ail n
0 Air for all 1 S r S k
and all 1 3 i1 <
< ir S k. Fortunately, this is fairly easy, since A11 0
D Air consists of those a e {1, 2, ...,n} which are multiples of p¢1,...,p,-, or
equivalently multiples of P11pi2...p,~,. Thus
IA;1 n
TL
n Airl =
i1 ...pir ‘
We conclude that
k 1
<p(n)=n—n-Z—+n-
i=1 pi
Z
1
15i<jsk pip,
which finishes the proof of theorem 4.106.
’°
1
_+...=n-H(l——),
i=1
'
El
4.4. Arithmetic functions
197
For instance, since 1000 = 2353, we obtain
<p(1000) = 22(2 — 1)52(5 — 1) = 400
and similarly 2016 = 25 - 32 - 7, hence
<p(2016) = 24 - 3 - (2 — 1)(3 — 1)(7 — 1) = 576.
Example 4.107. (Komal A 240) Prove that for all m, n 2 1
15kg]:
k=1
gcd(k,m)=1
Proof. Let p1, ..., 1),, be the prime factors of m, without counting multiplicities.
The inequality is equivalent to
3
1
H
1 '
i=1 1 _ 1?,-
Z
1gkgn
1
n 1
" Z Z _’
k
k=1 k
gcd(k,m)=1
01'
s
1
1
1+—+—+...
1
n 1
—Z
—.
H ( , p2 ) Z k E k
-
gcd(k,m)=1
Expanding brutally the expression in the left-hand side, we obtain an infinite
sum, among whose terms we have all
1
11’1“ -
-p§’ -'r
with k1- 2 0 and 1 _<_ r S n, gcd(r, m) = 1. Since any number k between 1
and n can be written k = p11cl follows.
- p33 - r with k,- and r as above, the result
E
Here is another example of a nice use of the inclusion-exclusion principle.
198
Chapter 4. The fundamental theorem of arithmetic
Example 4.108. (Putnam 2015) Let q be an odd positive integer, and let M,
be the number of integers a such that 0 < a < q/4 and gcd(a, q) = 1. Prove
that Nq is odd if and only if q is of the form pk with k a positive integer and
p a prime congruent to 5 or 7 modulo 8.
Proof. Let p1, ..., 10,, be the prime divisors of q (without counting multiplici-
ties). If Ai is the set of multiples of p,- between 0 and %, then
11.
Nq = lZJ_ IUZ‘_1Ai| = EJ ‘ZlA‘il +... + (—1)"|A1 n ...nAnl
i=1
n
5 EJ + Z |A,;| + + |A1 n n Anl (mod 2).
i=1
Note that for all 711, ...,ik we have
A. NA = J_J.
q
I
1'1
1'
I
4pi1---Pik
JJ+2J J J4; ,J
Thus
We observe next that if a, b are odd integers, then
a
b
ab
Indeed, writing a = 4q + r and b = 4q’ + r’ with r, r’ E {1, 3}, we have
b
7',
I
[C‘ZJ =4qq’ +qr’ +q’r+ [TTJ E¢1+q'+ l%J (1100012)
and it is immediate to check that [21—1 is even, yielding the claim.
We conclude that
Big-Elli q
q ."
£175
L
1__.pn)2n—1J
_ l4@
‘1 .a —
121..
( mo d 2).
4.4.
Arithmetic functions
199
If n > 1 then $3,222?- is the square of an odd integer and we deduce
immediately that Nq is even. Assume now that n = 1, so that q = p’f for
2k—1
some 16 2 1. Then Nq is odd if and only if [Eli—J = [312—] is odd. A simple
inspection shows that this happens precisely when p E 5, 7 (mod 8).
E]
The fundamental theorem of arithmetic combined with the formula for
<p(n) established in the previous theorem immediately yield the following result.
Corollary 4.109. (p is a multiplicative function, that is <p(mn) = <p(m)go(n)
for all relatively prime positive integers m,n.
Also note another immediate consequence of the previous theorem.
Corollary 4.110. If a, b are positive integers and a | b, then <p(a) | <p(b).
We end this theoretical part with an important theorem of Gauss. The
proof uses the following simple but important observation.
Proposition 4.111. For each positive divisor d of n there are precisely <p(%)
integers k 6 {1,2, ...,n} for which gcd(k, n) = d.
Proof. We have gcd(n,k) = d if and only if k = du, with u 6 {1,2,...,%}
relatively prime to %. The result follows.
El
Theorem 4.112. (Gauss) For all positive integers n we have
2 Md) = n.
dl'n,
Proof. For each k E {1, 2, ..., n}, gcd(k, n) is a positive divisor of n and by the
previous proposition each divisor d of n is equal to gcd(k, n) for precisely 90%)
integers k e {1, 2, ..., n}. We deduce that
n=2w(%)d|n
200
Chapter 4. The fundamental theorem of arithmetic
When d runs over all positive divisors of n, so does %. Thus
2 p (3—) = Z 90(d)
d|n
d|n
and the result follows.
III
Example 4.113. Prove that
2 mgj— “mg“.
d=1
Proof. Since [g] is the number of multiples of d in {1,2, ...,n} we obtain
n
:‘P(d)lll= 2m 21=Z Z Md).
lSkSn
dlk
k=1 lSdSn
dlk
By Gauss’ theorem
2 <p(d) = k
lSdSn
dlk
for all 1 S k S n and the result follows from
1 + 2 +...n+ WT“).
El
Example 4.114. (AMM E 3106) For n > 1 let S(n) be the set of positive
integers k for which the fractional part of % is at least %. Prove that
Z <p(k) = 72.2.
kES(-n)
Proof. The key observation is that for any h 2 1 we have 2—"
— 2 Ek: 6 0,1
k
and If?“ — 2 [fl = 1 if and only if k E S(n). This follows directly from the
identity
[290] - 2 [$1 = l2{$}l ,
4.4.
Arithmetic functions
201
where {1:} = a: — [at] is the fractional part of :13. We deduce that
23 ¢(k)=:¢(k)(lggj— 2%=H) :31 so(k))2_nj_2zgo( WW
k€S(n)
Since Lfij = 0 for k E {n + 1, ..., 2n} and since (by the previous example)
N(N + 1)
za) 1—j = _,
N
k=1
N
k
2
we deduce that
Z <p(k)=—22(2721—+1)—2@=n2.
I]
k€S(n)
Example 4.115. (China TST 2014) If n > 1, let f(n) be the number of ways of
factoring n into a product of integers greater than 1 (the order of factors does
not count). For instance f(12) = 4 since the corresponding factorizations are
12, 2 ~ 6,3 - 4,2 - 2 - 3. Prove that for any n > 1 and any prime divisor p of n
we have f(n) S %.
Proof. We prove this by strong induction, the base case being clear. Assume
now that if holds for all numbers less than n and let us prove it for n. Let p
be the largest prime divisor of n Clearly it suflices to prove that f (n) < ".
If n =..:1:1x2 .271, is a factorization of it into a product of integers greater
than 1, then some 11:, is divisible by 19, say sci—
— pd for some (1. Then d | g
and :71 = 171...:ci_1:r,-+1...:rk is a factorization of % into a product of integers
greater than 1. Since there are at most f (%) such factorizations, we obtain
E: f ( d) .
f(n)<_ «1|;
By the inductive hypothesis for each k < n we have f (k) 3 19—665, where P(k)
is the largest prime factor of k. We have file—7 S <p(k), since
:5—>— n<1—;>>n<— :>=—
PUG)
plk
i=2
202
Chapter 4. The fundamental theorem of arithmetic
Thus
f(n) n(%) 324%) = g
n
all;
where the last equality follows from Gauss’ theorem.
This finishes the proof.
D
The previous results are of fundamental importance, and it is crucial to
get familiar with them in order to understand some of the deeper theorems
to come. We will therefore illustrate these theoretical results with quite a few
examples.
Example 4.116. Find all positive integers n for which 90(22“ — 1) = 90(22").
Proof. Let Fk = 22k + 1 be the kth Fermat number. Since the Fermat numbers
are pairwise relatively prime and
22” —1=Fo-F1-...-Fn_1,
we can write the equation as
n—l
n
H r(Fz-) = 22 ’1,
i=0
thanks to the multiplicative character of Euler’s function. If n 2 6, we deduce
that <p(F5) is a power of 2. Since 641 | F5 (see example 2.12), 640 divides <p(F5)
and <p(F5) is not a power of 2. Thus any solution satisfies n S 5. Conversely,
if n S 5, then E is a prime for 2' S n — 1, hence
n—1
n—1
_1
n
H <P(Fi) = 110%- — 1) = 21+2+---+2” = 22 ‘1.
i=0
i=0
Thus the answer is n = 1, 2, 3,4, 5.
III
Example 4.117. Prove that for all integers n > 1 one can find integers :1: for
which g0(a:) = n!.
4.4.
Arithmetic functions
203
Proof. We will choose :1: having the same set of prime divisors as n!. In this
case the equation becomes
and is equivalent to
a:
n!
n'
(
“11...”! H) .w po—l)’
=
p.——_
It is apparent that this a: really has the same set of prime factors as n!, hence
it is a solution of the problem.
III
Example 4.118. (USA TST 2015) Let <p(n) denote the number of positive
integers less than n that are relatively prime to n. Prove that there exists a
positive integer m for which the equation <p('n,) = m has at least 2015 solutions
in n.
Proof. Let 121,112,
integer k. Define
be the increasing sequence of primes and fix a positive
N=p1p2.-.pk
wi=N(1——),
and
lgigk.
We claim that <p(a:i) = <p(N) for 1 S i S It (thus taking k = 2015 solves
the problem). Indeed, since all prime factors of pi — 1 are among 191, ..., pi_1,
it follows that the prime factors of so; are exactly p1,...,p¢-_1,p,r+1,...pk (each
appearing with a certain multiplicity). Thus
—H(> fi (14>
j=1
p1
j=i+1
p,
2.121 p» H)— N W
_k
_i_
Thus <p(a:i) = <p(N), as needed.
1
_<p(N)_
1
_<p(N)
III
204
Chapter 4. The fundamental theorem of arithmetic
Remark 4.119. A theorem of Pillai shows that limn_,oo #2 = 0, where f (n)
is the number of a: E {1, 2, ...,n} that are also in the image of Euler’s totient
function. This immediately implies the result of the previous example, but the
proof of Pillai’s theorem requires some delicate estimates for primes, which are
totally avoided by the beautiful argument (due to Schinzel) explained in the
previous proof.
Example 4.120. Prove that for all n > 1 we have:
a) a(n) < n(1 + logn);
b) n2 > 0(a) -<p(n) > ”72;
0) 90(7).) > w.
Proof. Part 0) follows directly by combining parts a) and b).
a) When d runs over the positive divisors of n, so does %, hence
o(n)=Zd=Z%=nZ$.
dln
dln
dln
Using the inequality
11
E g < 1 + log n
a=1
we obtain
0(n)
:1
n 1
n
dlnd
d=1d
—=
—SZ—<1+logn.
b) If n = p?1...p:" is the prime factorization of n, with p1 < p2 <
then
0(n)
’6
1
1
k
1
n
—=||1+—+...+—. < ||—=—,
n
i=1(
pi
p101.)
i=11—I%i
9007')
thus o(n)<p(n) < n2. Next,
a<n>-w<n)2n-fi
(1+fi)-n
-1EI(1i.),
i=1
1
i=1
1"
< pk
4.4. Arithmetic functions
205
hence it suffices to prove that
’°
1
1
2:11 (1 — 10—12) > —2-.
This follows from Bernoulli’s inequality3 and the inequality
k 1
1
.22p? < 5
that has already been seen (see example 4.77).
III
Remark 4.121. With a lot more work, one can prove the existence of a constant
c > 0 (which can be made explicit) such that for all n > 2 we have
n
<p(n) > 0
log log n '
Example 4.122. (Romania TST 2014) Let n be a positive integer and let An
(respectively Bn) be the set of integers k e {1,2,...,n} such that gcd(k,n)
has an even (respectively odd) number of prime factors (without counting
multiplicities). Prove that |An| = |Bn| for n even and |An| > IBnl for n odd.
Note: 1 has 0 prime factors.
Proof. Let w(k) be the number of distinct prime factors of k. Then clearly
w(xy) = w(x) + w(y) when a3,y are relatively prime, thus a: I—> (—1)“’("’) is
multiplicative. Next, by definition
11
IAnI — IBnI = Zenwsdw”.
k=1
For each divisor d | it there are precisely (p (fi) integers k e {1, 2, ..., n} such
that gcd(k,n) = d. Thus
lAnl — IBnl = Z(—1)w%(§) .
dln
3This says that (1 — 11:1)(1 — 2:2)...(1 — a3”) 2 1 — (2:1 +
The proof is a simple induction on n, left to the reader.
+ :5”) for all x1, ...,2n 6 [0,1].
206
Chapter 4. The fundamental theorem of arithmetic
In other words, the map 77. I—> |An| — |Bn| is the convolution product of two
multiplicative functions 17. I—> (—1)“’(") and n v—> <p(n). Thus by theorem 4.99
the function n I—> IAn| — |Bn| is itself multiplicative, and so it suffices to know
its values on prime powers. If n = pk with k 2 1 and p a prime, it is clear that
pic
IAnI _ aI : Z(_1)w(gcd(z>k,j)) = Z(_1) +
i=1
l’
Z
1
gcd(j,p)=1
= _pk—1 +pk _pk—1 = pic—1(1) _ 2).
We conclude that for all n we have
lAnl — IBnl = n11 (1 — 2)
pl"
1)
III
and the result follows.
4.4.4
The M6bius function and its applications
In this section we discuss in more detail some basic properties of the Mobius
function ,a. Recall that it is defined by u(1) = 1, ,u,(n) = 0 whenever n is not
squarefree (i.e. n is not a multiple of p2 for any prime p) and ,a(n) = (—1)“’(")
when n is squarefree. Its key property is the following relation (the reader
should be careful, the relation below only holds for n > 1, not for n = 1).
Proposition 4.123. We have 2d|n a(d) = 0 for n > 1.
Proof. Let n = pi“ -
- 19%;" be the prime factorization of n.
In the sum
Zdln p.(d), the only (1’5 giving nonzero contributions are 1, the prime factors
of n, the products of two distinct prime factors of n,..., up to p1...pm. Since
there are (3") products of 3' distinct prime divisors of n, and each such product
has contribution (—1)j, we obtain
Za(d)=1— (T) + (7;) —...=(1—1)m=o,
dIn
using the binomial theorem. The result follows.
El
4.4. Arithmetic functions
207
An important consequence of the previous proposition is the famous
Mobius inversion formula:
Theorem 4.124. (Mo‘bz'as inversion formula) If f(n) = Zdln g(d) for all n,
then
g(n)= Eng)f(d)
dln
for all n.
Proof. We compute
24%)f(d)= 243) Ego): Eye) 24%)
eln
e|d|n
On the other hand, writing d = em, we have a: | g and g = :1, thus by
proposition 4.123 we have
2 ”(E)= D (E)=0
eldln
ml”
unless e = n, in which case the sum is equal to 1. The result follows.
El
Remark 4.125. 1) There is also a multiplicative version of the Mobius inversion
formula (proved in exactly the same way): if
fl?!) = H901)
dln
for all n, then
g(n) = Hf(d)"(%)dln
2) The same argument shows that if f, g are arithmetic functions related
by
g(n) = Zn (3) ND
dln
208
Chapter 4. The fundamental theorem of arithmetic
for all n, then
f(n) = Z 9(d)
d|n
for all n. In other words, the converse of the previous theorem holds. Indeed,
we have
29(d)_ :2“
dln
dln eld
(g) f(e)= Zfle
eln
) Z ”(6 )
eldln
and
:43)=:u<x)
e|d|n
zlg
equals 1 if e = n and 0 otherwise.
3) Sometimes it can be useful to consider functions f, g which are only
defined on the set of positive divisors of a fixed number N > 1. If they satisfy
f(n) = ISM)
dn
for any n | N, then we can still deduce (using the same arguments as above)
that
g<n>= Eyeing)
dln
for any n | N. We leave the details as an exercise to the reader.
Let us apply now the previous results to Euler’s function (p. Consider
Gauss’ identity (see theorem 4.112)
n= Edd)
dln
and apply the Mobius inversion formula to it. We obtain
n: $401)
Ed: EM”
dam (1|a
M_<d_)
tp()
_n(l_;p1+;__...)=nn(1_;).
plnp
p<qlnpq
pln
4.4. Arithmetic functions
209
In other words, we recover the formula
1
(p(n) = 11.11 (1 — —)
pln
12
that we obtained in the previous section. Conversely, using the previous for—
mula and the Mobius inversion formula we recover Gauss’ theorem. Thus
Gauss’ theorem and the explicit formula for <p(n) are actually equivalent!
The following beautiful result is a nice illustration of the Mobius inversion
formula.
Example 4.126. Let (an)n21 be a sequence of positive integers such that
n(a'm’ an) = agcd(m,n)
for all positive integers m, n. Prove that there exists a sequence of positive
integers (bn)n21 such that for all n 2 1
= H bd.
dln
Proof. By the multiplicative version of the M6bius inversion formula we have
bn _
_H all“)
dln
and we need to prove that this is an integer for all n. Letting p1, ..., pd be the
(pairwise distinct) prime factors of n, we obtain
an
bn = —
”
1-1221 0;
Hi<ja 7321-
‘
Hi<j<k a P517171;
On the other hand, using the hypothesis of the problem repeatedly yields
arm
—gcd(an,a,_
—
nJ'a),
12 17:17];
— ed ( a;
a;
(LA
Pi,
Pj,
Pk),
—g
Letting x1- = 0'5""- for 1 S 2' S d, we deduce that
b
an
n=Hi=1 5L";
Hi<j nWia 17.7)
Hi<j<k gale“, $j ’ xk)
210
Chapter 4. The fundamental theorem of arithmetic
The lemma 4.127 below yields therefore
on
b" = lcm(an
31',
an )’
’ a
an expression which makes it clear that bn is an integer.
III
Lemma 4.127. For any positive integers $1, ...,xd we have
1-1221 1:,-
_
Hi<j<kg0d($i,$j,$k)
.
Hi<j ged($ia $1 ) Hi<j<k<l n($i, 563', 93k, 131)
. = lcm(a:1, ...,md).
Proof. The result is clear for d = 2 and assuming that it holds for d, we obtain
l0111(001,
,wd+1)
=10m( 10111031,
,fvd),-’Ed+1)
$d+1 ' 101110731, ---, 93d)
=—.
gcd(a:d+1,lcm(x1,...,a:d))
Inserting the value of lcm(x1, ..., zed) given by the inductive hypothesis in the
previous expression yields the desired result (after some tedious but simple
algebraic manipulations left to the reader).
III
4.4.5
Application to squarefree numbers
We want now to use the Mobius function in order to study the distribution
of squarefree numbers. We warn the reader that the remainder of this section
is rather technical, so he can freely skip what follows for a first lecture.
Let Q(n) be the number of squarefree numbers between 1 and n and let P
be the set of primes p 5 fl. Define for each p E P the set
Ap = {x E {1,2,...,n}| p2 | :13}.
Then the set of squarefree numbers between 1 and n is precisely the set
{1, 2, ..., n} \ Upep Ap, thus using the inclusion-exclusion principle we obtain
Q(n)=n—ZIAPI+ Z lApnAql‘l'upEP
p<q€P
4.4. Arithmetic functions
211
On the other hand, since there are [fl multiples of 1:: between 1 and n, we
deduce that
IAmnAm n nAk=[P1"
_P2n-kJ
for 171 <
< pk E P. We conclude that
Q(n)=n— Zffi‘kj
peP
l—zj
p<q p q
°=Z“(k)lkzj
k<f
in other words we have just proved the
Proposition 4.128. The number of squarefree numbers between 1 and n is
given by
Q(n)= Ignaz) [£2]
Noting that ,u(k) takes only the values —1,0, 1 and the distance between
[5; and F"; is at most 1, we obtain
nk<fk
This shows that in order to estimate Q(n) we need to estimate 2,63%; 5,32.
The key ingredient is the following remarkable identity, which looks very similar to Euler’s famous identity
1 +—
1 +—
1 +
22 3—2
=1r_2
6 '
Actually the proof will show that the next theorem is equivalent to this identity.
Theorem 4.129. We have
°° M06) _ 6
k=1 k2
’7'
1r
212
Chapter 4. The fundamental theorem of arithmetic
Proof. Using Euler’s identity, it suffices to prove that
:17 z_
H—(k)_
_ 1.
j>1 j2 k>1
Expanding, the left-hand side equals
Mk)
M_(k)
2(jk)2=272_:
J,k21
=ZI2Z“
“(k)=1
n>1jk—n
n>1
kln
the last identity being a consequence of the fact that Edlk n(d) equals 0 for
k>1and1fork=1.
El
We are now in good shape for proving the following beautiful result:
Theorem 4.130. The number Q(n) of squarefree numbers between 1 and
n > 1 satisfies
6
_ _
<
.
,Q(n) 7T2n _ 3w:
Proof. Using the previously established inequality
n k
Q(n)— nzk(—2 ) <\/7_3
k<fk
as well as the result of the previous theorem we reduce the proof to the in-
equality
Z Mk)
2 _ 1.
fl
k>¢fi k
Clearly, 1t suffices to prove that
:—<—
1
k>¢fi k
2
2
_
n
Letting N = [f], we obtain
2
z
z —1—— z (#1) —i
k>f 19—2: k>N+1 kl—Z< k>N+1 Mk — 1)
Since1N< %, we are done.
k2N+1
k_1
k
N
El
4.4.
Arithmetic functions
213
Example 4.131. Prove that any n > 1000 can be written as the sum of two
squarefree numbers.
Proof. We claim that
1
om — 1) > “%
Using the previous theorem it suffices to prove that
6
—1
—(n—1)
>
"——+3\/—n—1,
«2
2
which easily follows from n > 1000 and f; > 0.6. Consider now the set A of
all squarefree numbers between 1 and n — 1 and the set B of all numbers of
the form n — x, with x e A. Then A and B are subsets of {1,2,...,n —- 1},
each with more than "7‘1 elements. Thus their intersection is nonempty and
so we can find x E A suchthat n—x E A. But thenn=x+(n—x) is the
sum of two squarefree numbers.
III
Remark 4.132. Explicit computations show that any n > 1 is a sum of two
squarefree numbers.
Example 4.133. Prove that for infinitely many integers n > 1 all numbers
n, n + 1, n + 2 are squarefree.
Proof. Suppose that there is N such that for all n 2 N at least one of the
numbers n, n + 1, n + 2 is not squarefree. Then for each It 2 N at least two of
the numbers 4k, 4k + 1, 4k: + 2, 4k: + 3 are not squarefree. Dividing the numbers
4N, 4N + 1, ..., 4n — 1 into groups of 4 consecutive numbers, we deduce that
can) — 9(4N) s 2n
for all n 2 N. This is impossible, since by the previous theorem
lim M = E > 1.
n—mo
2n
71'2
El
Example 4.134. Let a1, ...,ad and b1, ...,bd be positive integers. Prove that if
there is an integer n such that a1n+b1, ..., adn+bd are all squarefree numbers,
then there are infinitely many such it > 0.
214
Chapter 4. The fundamental theorem of arithmetic
Proof. Fix an integer no such that aino + b, are all squarefree numbers, and
let 0' be a large number (we will make a final choice later on), such that any
prime factor of Hf=1 ai(a,-no + b,) is smaller than 0. Let P be the product of
all primes not exceeding 0'. We will prove that
xi(k) := a,-(no + kP2) + b,- = aino + b,- + kP2ai
are all squarefree numbers for infinitely many positive integers k, which is
enough to conclude.
Fix a large integer N > C and consider those m,(k) with 1 S i S d and
1 S k S N. Note that ic) is not a multiple of p2 for any prime p S C (as
otherwise aino + bi would be a multiple of p2). Assume that for some i S d
the number $109) is not squarefree, thus there is a prime p > C such that
p2 | m,(k). Then (if C is large enough)
p2 3 mac) < 2kP2a, s 2NP2aia
thus p < MP 3 v2MNP, where M = max(a1, ...,ad). Moreover, since
p does not divide Pai, the solutions of the congruence x,(k) E 0 (mod p2)
considered as a linear congruence in k are all congruent modulo p2, so there
are at most 1 + g; such solutions. Since there are less than v2NMP primes
below v2NMP, we deduce that 11:; (k) is not squarefree for at most
x/2NMP + N 2
1
1
p>C p2
N
k>C
values of k E [1, N]. Therefore all numbers x109), 102(k), ..., dc) are squarefree
for at least
d
N(1— E) —dP¢2M-\/N
values of k E [1,N]. Since the last quantity tends to 00 as N —> oo (fixing
once and for all C > d large enough), the result follows.
[I
Example 4.135. (IMC 2013) Is there an infinite set of positive integers A such
that for all distinct elements a, b 6 A the number a + b is squarefree?
4.4. Arithmetic functions
215
Proof. We will construct inductively an infinite increasing sequence a1 < a2 <
such that a1 = 1, a2 = 2 and ai + aj is square free whenever i aé 3'. Assume
that (11, ..., ak have already been constructed, we will try to construct ak+1 so
that ak+1+ai are square free for 1 S i S k. Consider two auxiliary big numbers
r,N and let us look for ak+1 of the form 1 + r!n for some n 6 {1,2, ...,N}.
We will choose 1' > k + maxlgiskfl + Liz-)2 to ensure that 1 + rln + (L) is of the
form (1 + a¢)(1 + y(1 + a») for some y 2 1. Thus if p2 | 1 + rln + (ii for some
1 g i S k and some prime p, then necessarily p > r (if p S r then 1) | 1 + a1;
and then necessarily p2 | 1 + a5, contradicting the fact that a,- + a1 = a) + 1
is square free, by the inductive hypothesis if i > 1 and by the choice of a1 for
i = 1). Moreover, p2 S 1 + r!n + a,- < r!(N + 1). There are at most 113V; + 1
values of n e {1, 2, ..., N} for which p2 I 1 + r!n+ (1,, thus in total there are at
most
S = k-
2
(g + 1)
r<p<‘/'r!(N+1)
numbers n 6 {1,2, ...,N} for which 1 + 1‘!n + (1,; is not squarefree for some
1 g i g k. Note that
s < k (,/1~!(N+1) +sl2) < k,/r!(N+ 1) +kNZ (jél — %)
j>r
j>r
k
l
< k,/r.(N+
1) + _TN
and the last expression is less than N — 1 for N big enough since 19 < 7". Thus
for N big enough (and with any fixed choice of r > k + maxlgskfl + ai)2)
we can choose ak+1 = 1 + rl'n, for some n 6 {1,2, ...,N} to make ak+1 + a1squarefree for 1 S i S k, finishing the inductive step.
El
Example 4.136. (Brazil 2015) If n = ping)? . . . 1):" is the prime factorization
ofn > 1, let
f (n) = 0111)?”
—1
cv2pS‘2
—1
wasp?"
—1
Prove that f (n) = f (n — 1) + 1 for infinitely many n.
.
216
Chapter 4. The fundamental theorem of arithmetic
Proof. Note that f(n) = 1 whenever n is squarefree and that f is clearly
multiplicative. Let
a=27,
b=169,
:1:=482,
y=77.
Then x,y are squarefree, ax = by + 1, gcd(a,:1:) = gcd(b,y) = 1 and
f(a) = f(b) + 1. By example 4.134 the numbers ab2n + x and a2bn + y
are simultaneously squarefree for infinitely many n 2 1, thus for such n we
have
f(a2b2n + ax) = f(a(ab2n + 53)) = f(a) = 1 + f(b)
= 1 + f(b(a2bn + y)) = 1 + f(a2b2n + aa: — 1).
Thus f (m) = f (m — 1) + 1 for m = azbzn + act: and n as above. The result
follows.
4.5
'3
Problems for practice
Composite numbers
1. Prove that if a is an integer greater than 1 and if n > 1 is not a power
of 2, then a" + 1 is composite.
2. (St. Petersburg 2004) Prove that for any integer a there exist infinitely
many positive integers n such that a2" + 2” is composite.
3. Find all positive integers n for which at least one of the numbers n” + 1
and (2702" + 1 is composite.
4. For which positive integers n the numbers 2'" + 3 and 2" + 5 are both
primes?
5. (St. Petersburg 1996) Integers a, b,c have the property that the roots
of the polynomial X3 + aX2 + bX + c are pairwise relatively prime and
distinct positive integers. Prove that if the polynomial aX2 + bX + c has
a positive integer root, then |a| is composite.
4.5.
Problems for practice
217
. (Vojtech Jarnik Competition 2009) Prove that if k > 2 then 22"-1 —2k—1
is composite.
A positive integer which is congruent 1 modulo 4 has two different representations as a sum of two squares. Prove that this number is composite.
(Moscow Olympiad) Is there an 1997—digit composite number such that
if any three of its consecutive digits are replaced by any other triplet of
digits then the resulting number is composite?
(AMM 10947) Prove that =53;l is composite for all n 2 1.
The fundamental theorem of arithmetic
10. Let n > 1 be an integer. Prove that the equation
(a: + 1)(:r + 2)...(a: + n) = y”
has no solution in positive integers.
11. Let n be a positive integer. Prove that if n divides (Z) for all 1 g k S
n — 1, then n is prime.
12. (USAMTS 2009) Find a positive integer n such that all prime factors of
(n+1)(n+2)...(n+500)
500!
are greater than 500.
13. (Russia 1999) Prove that any positive integer is the difference of two positive integers with the same number of prime factors (without counting
multiplicities) .
14. (Saint Petersburg) An infinite sequence (an)n21 of composite numbers
satisfies
an
“n+1 = an _pn+ —
pn
for all n, where p" is the smallest prime factor of an. If all terms of the
sequence are multiples of 37, what are the possible values of a1?
218
Chapter 4. The fundamental theorem of arithmetic
15 Prove that there are infinitely many pairs (a, b) of distinct positive integers a, b such that a and b have the same prime divisors, and a + 1 and
b + 1 also have the same prime divisors.
16. Let a, b, c, d, e, f be positive integers such that abc = def. Prove that
a(b2 + 62) + d(e2 + f2) is composite.
17. (Kvant M 1762) Is there a positive integer n with 2013 prime divisors
such that n divides 2" + 1?
18. (Poland 2000) Let p1 and p2 be prime numbers and for n 2 3 let 1),, be
the greatest prime factor of pn_1 +pn_2 + 2000. Prove that the sequence
(1270,21 is bounded.
19. (Italy 2011) Find all primes p for which p2 — p — 1 is the cube of an
integer.
20. (Kvant M 2145) Let :1; > 2, y > 1 be integers such that my + 1 is a perfect
square. Prove that a: has at least 3 different prime divisors.
21. (Russia 2010) Prove that for any n > 1 there are n consecutive positive
integers whose product is divisible by all primes not exceeding 2n + 1,
and not divisible by any other prime.
22. (Iran 2015) Prove that infinitely many positive integers n cannot be
written as the sum of two positive integers all of whose prime factors are
less than 1394.
23. (China 2007) Let n > 1 be an integer. Prove that 2n — 1 is a prime
number if and only if for any n pairwise distinct positive integers
a1,a2, . . . ,a.,, there exist i,j 6 {1,2, . . . ,n} such that
gcd(ai.aj) _
24. (Tournament of the Towns 2009) Initially the number 6 is written on a
blackboard. At the nth step, one replaces the number d written on the
4.5. Problems for practice
219
blackboard with d + gcd(d,n). Prove that at each step the number on
the blackboard increases either by 1 or by a prime number.
Infinitude of primes
25. (Komal) Is it possible to find 2000 positive integers such that none of
them is divisible by any of the other numbers but the square of each is
divisible by all the others?
26. A positive integer n is called powerful if p2 | n for any prime factor 1)
of n. Prove that there are infinitely many pairs of consecutive powerful
numbers.
27. Let pn be the largest prime not exceeding n and let qn be the smallest
prime larger than n. Prove that for all n > 1 we have
n
1
1
z—<§.
k=2 19k
28. (Russia 2010) Are there infinitely many positive integers which cannot
be expressed as gij—i, with :L', y integers greater than 1?
29. (Baltic Way 2004) Is there an infinite sequence of prime numbers pl, 112,
such that |pn+1 — 2pn| = 1 for each n 2 1?
30. Let a1,a2, ...,ak be positive real numbers such that for all but finitely
many positive integers n we have
gcd(n, [0,a + Lagnj +
+ Laknj) > 1.
Prove that a1, ..., ak are integers.
31. (IMO Shortlist 2006) We define a sequence a1, a2, a3,
an=;<[¥]+[;]+-~+n>
by setting
220
Chapter 4. The fundamental theorem of arithmetic
for every positive integer n.
a) Prove that an“ > an for infinitely many n.
b) Prove that an+1 < an for infinitely many n.
32. (APMO 1994) Find all integers n of the form a2 + b2 with a, b relatively
prime positive integers, such that any prime p 3 fl divides ab.
33. (Iran TST 2009) Find all polynomials f with integer coeflicients having
the following property: for all primes p and for all integers a, b, if p |
ab — 1, then pl f(a)f(b)— 1.
34. Prove that there is a positive integer n such that the interval [n2, (n+1)2]
contains at least 2016 primes.
35. (IMO 1977) Let n > 2 be an integer and let Vn be the set of integers of
the form 1 + kn with k 2 1. A number m E Vn is called indecomposable
if it cannot be written as the product of two elements of Vn. Prove that
there is r e Vn that can be expressed as the product of indecomposable
elements of Vn in more than one way (expressions which differ only in
order of the elements of Vn will be considered the same).
36. (German TST 2009) The sequence (an)neN is defined by a1 = 1 and
an+1 =afi—ai+2a,21+1
for all n 2 1. Prove that there are infinitely many primes which do not
divide any of the numbers a1, a2,
Arithmetic functions
37. Prove that for all n 2 1 we have
Za(d)=n-Z?,n 21(1): 2d (d)
dln
d|n
dln
dln
4.5.
Problems for practice
221
38. a) Let f be a multiplicative function with f(1) = 1 (this is equivalent to
f being nonzero). Prove that for all n > 1 we have
Zf(d)u(d) = H(1 - f(P)),
d|n
pln
the product being taken over the prime divisors of n.
b) Deduce closed formulae for
Zu(d)r(d), Emma) and Z#(d)<p(d)
dln
dln
dln
for n > 1.
39. Let f be an arithmetic function such that the function 9 defined by
900 = 2 f(d)
dln
is multiplicative. Prove that f is multiplicative.
40. a) Let f be an arithmetic function and let 9 be the arithmetic function
defined by
gm) = Z M)dln
For all n _>_ 1 we have
2: gas) = k=1
2 NC) [g] .
k=1
b) Prove that the following relations hold for all n 2 1
n
27(k)=1:[%],1:10(k)=1:k[%].
k=1
41. Let f (n) be the difference between the number of positive divisors of n
of the form 3k: + 1 and the number of positive divisors of the form 3k — 1.
Prove that f is multiplicative.
Chapter 4. The fundamental theorem of arithmetic
222
42. (AMM 2001) Find all totally multiplicative functions f : N —-> C such
that the function
11.
F(n) = 2 f(k)
k=1
is also totally multiplicative.
43. Find all nonzero totally multiplicative functions f : N ——> R such that
f(n+ 1) 2 f(n) for all n.
44. (Erdos) Let f : N —> R be a nonzero multiplicative function such that
f (n + 1) 2 f (n) for all n. Then there is a nonnegative real number k
such that f (n) = n’6 for all 11..
45. Are there infinitely many n > 1 such that n | 200‘) — 1?
46. An integer n > 1 is called perfect if 0(n) = 2n. Prove that an even
number n > 1 is perfect if and only if n = 2P‘1(2P — 1), with 2” — 1
prime.
47. Let n be an even positive integer. Prove that o(a(n)) = 2n if and only
if there is a prime p such that 2” — 1 is a prime and n = 2P‘1.
48. (Romania TST 2010) Prove that for each positive integer a we have
0(an) < 0(an + 1) for infinitely many positive integers n.
49. (IMO Shortlist 2004) Prove that for infinitely many positive integers a
the equation T(an) = n has no solutions in positive integers.
50. (IMO) Let r(n) be the number of divisors of a positive integer n. Find
2
all positive integers k such that k = 7:51)) for some n.
51. A positive integer a is called highly divisible if it has more divisors than
any number less than a. If p is a prime number and a > 1 is an integer,
we write vp(a) for the exponent of p in the prime factorization of a.
Prove that
a) There are infinitely many highly divisible numbers.
4.5.
Problems for practice
223
b) If a. is highly divisible and p < q are primes, then 'vp(a) 2 vp(a).
c) Let p, q be primes such that pk < q for some positive integer k. Prove
that if a is highly divisible and a multiple of q, then a is a multiple of
pkd) Let p, q be primes and let k be a positive integer such that pk > q.
Prove that if p2,“ divides some highly divisible number a, then q divides
a.
e) (China TST 2012) Let n be a positive integer. Prove that all sufficiently large highly divisible numbers are multiples of 77..
52. Let n > 1 be an integer. Compute
Z(-1)%<P(d)dln
53. (IMO 1991) Let 1 = a1 < a2 <
< awn) be the totatives of n > 1.
Prove that a1, a2, ..., awn) form an arithmetic progression if and only if
n is either 6, a prime number or a power of 2.
54. Let n 2 2. Prove that n is a prime if and only if <p(n) | n — 1 and
n + 1 | 0(n) (recall that 0(n) is the sum of the positive divisors of n).
55. Let k be a positive integer. Prove that there is a positive integer n such
that cp(n) = <p(n + k).
56. Prove that for all n 2 1 we have
<p(1)
<p(2)
<p(n) <2.
..+2n_1
21_1+22_1+.
57. a) Prove that there are infinitely many integers 'n, > 1 such that
<p(n)2<p(k)+go(n—k) foralllSkSn—l.
b) Are there infinitely many n > 1 such that 90(1).) 3 <p(k) + <p('n, — k) for
all 1 S k S n — 1?
224
Chapter 4. The fundamental theorem of arithmetic
58. (AMM 11544) Prove that for any integer m > 1 we have
m+k
2
1;:(p(2k+1) l2—k+lj= m .
59. a) Prove that for all n > 1 we have
n
n
n 2
229000 = 1+Zu(k)m .
b) Prove that for all n > 1 we have
lea) + 90(2) + + <p(n) — $712
< 2n+nlogn.
60. Let a1, ..., ad”) be the totatives of n > 1.
a) Prove that for all m 2 1 we have
m
an +a'2" + +4411") = 2mm (1m +2m + + (g) ).
dln
b) Compute a1 + a2 +.. + aim).
61. (Serbia 2011) Prove that if n > 1 is odd and 90(n), <p(n + 1) are powers
of2,thenn+1isapowerof2 orn=5.
62. (Komal A 492) Let A be a finite set of positive integers. Prove that
Z (-2)'S'_1 gcd(5) > 0,
SCA
the sum running over all nonempty subsets S of A and gcd(S) denoting
the greatest common divisor of all elements of S.
Chapter 5
Congruences involving prime
numbers
This long chapter deals with a series of key theorems concerning congru-
ences modulo prime numbers, such as Fermat’s little theorem, Wilson’s theorem and Langrange’s theorem. These are fundamental results in basic number
theory, and it is crucial to become very familiar with them before dealing With
more advanced results. Therefore we give many concrete examples illustrating
each of these results, as well as lots of applications. The second part of the
chapter deals with more advanced topics, such as quadratic residues or con—
gruences modulo powers of primes. Once the first part of the chapter is fully
understood, the proofs of these more advanced results (with the exception of
the quadratic reciprocity law) become relatively simple and natural.
5.1
5.1.1
Fermat’s little theorem
Fermat’s little theorem and (pseudo—)primality
We now reach the first fimdamental congruence in which prime numbers
play a key role: Fermat’s little theorem. While both the statement and the
proof of this theorem are fairly simple, the result itself is incredibly useful, as
it will be clear in the sequel.
226
Chapter 5. Congruences involving prime numbers
Theorem 5.1. (Fermat’s little theorem) For all primes p and all integers a
we have
ap E a
(mod p).
Equivalently, for all primes p and all integers a relatively prime to p we have
a1’_1 E 1
(mod p).
Proof. It is clear that the two statements are equivalent, so it suffices to
prove the second one. So let a be an integer relatively prime to p. Then
0, a, 2a, 3a, ..., (p — 1)a is a complete residue system modulo p by theorem 3.32,
hence
a-2a-...-(p—1)aE 1-2-...-(p—1)
(modp).
This can also be written as
(p — 1)!(ap_1 — 1) E 0
(mod p).
Since p is a prime, we have gcd(p, (p — 1)!) = 1 and so ap‘l E 1 (mod p),
finishing the proof.
D
We would like to explain a second proof of Fermat’s little theorem, which
is based on a very useful property of binomial coefficients. The reader will find
a whole section devoted to congruences between binomial coefficients later on,
thus for now we will stick to the simplest one.
Let us recall the classical identity, valid for all n 2 k 2 1
n
n—1
kill-”(1H),
which follows from
k<n> -k-
k
_
n!
_
n!
—n-
k!(n—k)!_(k—1)!(n—k)!—
(n—l)!
_n.<n—1)
(k—l)!(n—k)!_
[9—1-
We are now ready to state and prove the most fundamental congruence for
binomial coefiicients:
Theorem 5.2. p is a prime and 1 S k S p — 1, then p divides (g).
5.1.
Fermat’s little theorem
227
Proof. The equality 19(2) = p(fi:i shows that p divides k - (g) and since
gcd(k, p) = 1, we conclude that p | (i), as desired.
El
We can now explain the second proof of Fermat’s little theorem. By theorem 5.2 and the binomial formula we have
—1
(93 +11)" - av" - y” = p: (aw—k2!” E 0 (mod 20),
19:1
that is
(93 + y)? E ftp + 9" (mod p)
(1)
In particular, for any integer a we have
(a + 1)? E up + 1
(mod p).
It is now immediate to prove by induction on a Z 0 that a? E a (mod p) for
all primes p. Similarly (or using that (—a)P E —aP (mod p)) we obtain the
result when a S 0.
Note that Fermat’s little theorem and the validity of congruence (1) for
all integers m,y are equivalent. Indeed, it is clear that Fermat’s little theo—
rem yields congruence (1), since both sides are congruent to a: + y modulo p.
Conversely, if congruence (1) holds for all integers x, y then a simple inductive
argument shows that
(931 +
+ (an)? E 9311’ +
+ :53,
(mod p)
for all integers x1, ..., 11:”. In particular, if a is a positive integer then
ap=11+...+1)pE1+...+1=a
a.
(modp)
a
and Fermat’s little theorem follows (the case a < 0 follows from the case a. Z 0
using that (—a)7’ E —ap (mod p)).
A very important observation concerning Fermat’s little theorem is that
its converse does not hold, in other words there are composite numbers n such
that a” E a mod n for all integers a. Such numbers are called Carmichael
228
Chapter 5. Congrnences involving prime numbers
numbers, and the first few are given by n = 561, 1105, 1729, 2465. It is known
(this is a deep theorem of Alford, Granville and Pomerance) that there are
infinitely many Carmichael numbers. The next example explains why the
previous numbers are Carmichael numbers.
Example 5.3. Let n be a composite squarefree integer such that p — 1 | n — 1
for any prime p dividing n. Prove that n is a Carmichael number.
Proof. We need to prove that a E a (mod n) for any integer a. Since n is
squarefree, it suflices to prove that a” E a (mod p) for any prime p dividing n.
If p I a, we are done, otherwise by Fermat’s little theorem ap'l E 1 (mod p)
and since p — 1 I n — 1 we obtain an.1 E 1 (mod p) and then a” E a (mod p),
as desired.
El
For instance, 561 = 3- 11 - 17 satisfies the conditions imposed in the previous
example, since 560 is a multiple of 2,10 and 16. Thus 561 is a Carmichael
number. The argument is similar for 1105 = 5 - 13 - 17, 1729 = 7- 13 - 19,
2465 = 5 ~ 17 - 29. We will see later on that the converse holds in the previous
example, i.e. any Carmichael number n is squarefree (this is fairly easy to see,
since by assumption n | p" — p for any prime p | n, hence p2 cannot divide n)
and for any prime p | n we have p — 1 | n — 1 (this is difficult to establish using
only the tools we have so far).
Example 5.4. Prove that there are infinitely many composite integers n for
which n | a’“1 — a for any integer a.
Proof. We claim that n = 2p with p an odd prime is a solution of the problem.
Since (In—1 — a is clearly even, it suffices to prove that p | a2!"1 — a for all a
and all odd primes p. This follows from
a23"_1 — a = a(a21"2 — 1) = (a? — a)(al""'1 + 1)
and Fermat’s little theorem.
I]
Numbers 11. for which 2‘" E 2 (mod n) are also historically very important. One
can show that the first composite number n with this property is 341 = 11 - 31.
5.1.
Fermat’s lz'ttle theorem
229
Definition 5.5. A composite integer n such that 2” E 2 (mod n) is called a
pseudo-prime. More generally, if a > 1 is an integer, a composite integer n
such that a“ E a (mod n) is called a pseudo-prime in base a.
Thus Carmichael numbers are precisely those numbers which are pseudoprimes in any base. The first pseudo-primes are 341, 561, 645, 1105, 1387,
1729, 1905, 2047,.... Combined with the fact that 561 (or 341) is a pseudoprime, the next example proves the existence of infinitely many pseudo-primes.
Example 5.6. Prove that if n is odd and pseudo-prime, then so is 2” — 1.
Proof. Since n is composite, so is 2" — 1 (for if d is a proper divisor of n, then
2“ —— 1 is a proper divisor of 2" — 1). We need to prove that 2" — 1 | 22”—2 — 1,
or equivalently n | 2" — 2. But this is clear, since n is a pseudo—prime.
El
The next example gives different proofs of the existence of infinitely many
pseudo-primes using explicit constructions.
Example 5.7. a) (Erdos, 1950) Prove that if p > 3 is a prime then 72. = £311 is
a pseudo-prime.
b) (Rotkiewicz, 1964) Prove that if p > 5 is a prime then 77. = 4—19—31 is a
pseudo-prime.
Proof. a) Note that n = % - (2P + 1) is composite. Next, since n | 4? — 1,
in order to prove that n | 2'” — 2 it sufl'ices to prove that 41’ — 1 | 2'”—1 — 1,
or equivalently 2p l n — 1. This is further equivalent to 6p | 4” — 4. Clearly 2
and 3 divide 41’ — 4 and by Fermat’s little theorem p | 41’ — 4. Since 2, 3, p are
pairwise relatively prime, the result follows.
b) Write p = 2k + 1, then
n _ 24k+2 + 1 _ 4 , (2k)4 + 1 _ (22k+1 _ 2k+1 + 1)(22k+1 + 2k+1 + 1)
_
5
_
5
_
5
and 22”1 — 2"+1 + 1 > 5 when p > 5, hence n is composite. Next, it suffices to
prove that 41’ + 1 | 2"“‘1 — 1 and since 41’ + 1 | 241’ — 1 we are further reduced to
4p | n — 1 and then 201) | 41’ — 4. This follows from Fermat’s little theorem and
the fact that 4, 5, p are pairwise relatively prime and each divides 4p — 4.
III
230
Chapter 5. Congmences involving prime numbers
The reader has already noted that all pseudo—primes presented in the above
discussion are odd. What about even ones? These are much harder to find:
only in 1950 did D.H. Lehmer find the smallest even pseudo—prime, the number
n = 161038 = 2 - 73 - 1103. To see that n is a pseudo—prime, one uses again
Fermat’s little theorem and the fact that n— 1 = 32 - 29 - 617 with 29 — 1 = 7-73
and 229 — 1 = 233 - 1103 - 2089. Beeger proved in 1951 that there are infinitely
many even pseudo-primes.
5.1.2
Some concrete examples
We continue with many illustrations of Fermat’s little theorem, destined
to better grasp the power of this result. We start with a series of interesting
congruences that can be derived rather easily using Fermat’s little theorem.
The trick of considering the smallest prime factor of 11. when dealing with
divisibilities of the form n | a” — b" is a standard tool which turns out to be
very effective in practice. The next two examples illustrate this plainly.
Example 5.8. a) Prove that if n > 1, then 77. does not divide 2" — 1.
b) Find all odd positive integers n for which n l 3" + 1.
Proof. a) Suppose that n | 2'” — 1 and let p be the smallest prime divisor of
n. Then p | n | 2‘” — 1 and by Fermat’s little theorem p | 21"1 — 1. Hence
p | gcd(2” — 1, 21”—1 — 1) = 25°d("’1’_1) — 1. Since p is the smallest prime divisor
of n, we have gcd(p — 1,77.) = 1, hence p | 1, a contradiction.
b) The answer is n = 1. Suppose that n > 1 is a solution and let p be
the smallest prime divisor of n. Then p | 3" + 1 | 32" — 1 and p | 31"-1 — 1.
Thus p | gcd(32" — 1, 3"—1 — 1) = 3g°d(2"’p_1) — 1. Since 77. is odd, so is p, and
since p is the smallest prime divisor of n we have gcd(2n,p — 1) = 2. Thus
p | 32 - 1 = 8, a contradiction.
1:]
Example 5.9. (China TST 2006) Find all positive integers n and all integers
a such that n | (a + 1)” — a".
Proof. Clearly (n, a) = (1, a) is a solution for any integer a. Assume now that
n > 1 and consider the smallest prime divisor p of n. Then p | (a + 1)” — a".
Note that p cannot divide a or a, + 1, as otherwise p would divide both a and
5.1.
Fermat’s l'lttle theorem
231
a + 1. Thus by Fermat’s little theorem p I (a + 1)”‘1 — cup—1. We deduce that
p | (a + 1)g°d("’P_1) — agwmm—l) and since gcd(n, p — 1) = 1 it follows that
p | 1, a contradiction. Thus we have already found all solutions.
El
For the next example, we recall that 'vp(n) denotes the exponent of p in
the prime factorization of 17..
Example 5.10. a) Let n be a positive integer and let p be a prime factor of
2” + 1. Prove that 122(1) — 1) > v2(n).
b) Find all prime numbers p, q such that pq | 2? + 2‘1.
Proof. a) We have p | 22" — 1 and p | 21"1 — 1, thus p | gcd(22" — 1,21"1 — 1) =
2g°d(2”’p_1) — 1. Suppose that v2(p — 1) S 0201.), then gcd(2n, p — 1) | n and we
conclude that p | 2" — 1. Since p | 2" + 1, it follows that p | 2, a contradiction.
Hence v2(p — 1) > 12201).
b) If p = 2 then 2q I 4 + 2‘7. Since 4 + 2‘1 E 6 (mod q) by Fermat’s little
theorem, we deduce that q | 6 and so q = 2 or q = 3, both of which are
solutions of the problem. By symmetry if q = 2 then p = 2 or p = 3. Assume
now that p, q > 2 and without loss of generality assume that p > q. Then by
assumption pq | 210—4 + 1. It follows from part a) that 112(1) — 1) > 122(1) — q)
and '02 (q — 1) > 212(1) — q). This is impossible, since
we — q) = we» — 1) — (q — 1» 2 min<v2(p — 1mm — 1)).
Thus the only solutions of the problem are (2, 2), (2, 3), (3, 2).
El
Example 5.11. Let (fn)n21 be the Fibonacci sequence, with f1 = f2 = 1 and
fn+1 = fn + fn_1 for n 2 2. Prove that for any prime p > 2 we have
fp E 5?
Proof. We use the classical formula
(mod p).
fn=t((”2“3)"-(1;c)"),
232
Chapter 5. Congruences involving prime numbers
which can be established by a straightforward induction. Expanding the expression on the right-hand side using the binomial formula yields
p (p) E
%1
1
k
1 Z
___2
52(1—(—1))=—_
P
2p1k=0 2k+1
«5H k
k
5.
Since p divides (215-1) for 0 g k S %3 we deduce that
21"1fp a 5”?
and since 21"1 E 1 (mod p) by Fermat’s little theorem, the result follows.
I]
Example 5.12. Prove that for all odd primes p we have
p—l
Z k29—1 E “PT-F12
(mod p2).
Proof. By Fermat’s little theorem we have Is:(k:1”1 — 1)2 E 0 (mod p2).
Expanding this and summing we find
p—l
p—l
p—l
Z 1629—1 E 2 Z kp — Z k
(mod p2).
On the other hand,
2:11:9—
— 21061" + (p— k)p)= 0
(mod p2)
k=1k=1
since kp + (p — k)” E 0 (mod p2) for 1 _<_ k S p — 1 (as follows directly from
the binomial formula). We conclude that
p—l
Zk2p—1__ :zik=_ P_(P__2—1)__
=P_(P+1)
k=1
(modpz).
I]
2
Fermat’s little theorem can be very efficient in establishing that certain
numbers are composite or in proving that certain sequences contain infinitely
many composite numbers, as shown in the following examples.
5.1.
Fermat’s little theorem
233
Example 5.13. Let a1, ..., an, b1, ..., bk be integers such that a1, ..., an > 1. Prove
that there are infinitely many positive integers d such that a‘f +ag +
+afi + bi
is composite for all 1 S t S k.
Proof. Since a1, ..., an > 1, there is a positive integer (1 such that
S.- :=a‘1‘+...+afi+b,- > 1
for 1 S i S k. Let pi be a prime divisor ofSi and let dj = d+j(p1—1)...(pk—1).
By Fermat’s little theorem
afj+...+agj+b¢Eaf+m+afi+biEO
for any 3' > 1 and since clearly a?!" +
1 S i S k, it follows that all" +
j 2 1.
(modpi)
+ agj + bi > Si 2 pi for j 2 1 and
+ a5? + b,- is composite for 1 S i S k and
III
Example 5.14. (China TST 2002) Are there distinct positive integers
k1, ---,k2002 such that for all integers n > 2001 at least one of the numbers
k1 ~ 271. + 1, ..., [£72002 - 2n + 1 is prime?
Proof. The answer is negative: choose a prime divisor p1- of 2kg + 1 for 1 S 'l S
2002, and let n = N(p1 — 1)...(p2002 — 1) + 1 for some large N > 2001. Then
n > 2001 and by Fermat’s little theorem k; - 2“ + 1 E 2k; + 1 E 0 (mod p.)
for 1 S i S 2002. Moreover, it is clear that ki - 2" + 1 > pi, hence k1- - 2" + 1 is
composite for 1 3 z' 3 2002.
El
Example 5.15. Let k > 1 be integer and define an = 22” + k. Prove that there
are infinitely many composite numbers in the sequence a1, a2,
Proof. The solution is short, but fairly tricky.
We may assume that k is
odd, since otherwise all terms of the sequence are even. Let r = 122(k — 1)
(where '02 (as) is the exponent of 2 in the prime factorization of :c) and assume
that an is prime for all large enough 17., say n > N. In particular there is
n > max(r, N) such that an is a prime number, say an = p. Since 77. > r
we have 122(1) — 1) = 112(22" + k — 1) = r. Write p — 1 = 2r - s for some odd
number s and choose a positive integer j such that 2j —=‘ 1 (mod .9) (to see
234
Chapter 5. Congruences involving prime numbers
that this is possible, follow the proof of corollary 4.15 or use Euler’s theorem
in _chapter 6). Then 2“” E 2‘” (mod p — 1) and so by Fermat’s little theorem
221+” + k E an E 0 (mod p). Thus aj+n is divisible by p and since clearly
aj+n > an = p we deduce that aj+n is composite, a contradiction.
III
The next examples are concerned with various divisibility properties that
can be deduced from Fermat’s little theorem, with a special emphasis on polynomials.
Example 5.16. (Poland) Find all polynomials f with integer coefficients such
that f (n)|2" — 1 for all positive integers n.
Proof. Clearly the constant polynomials 1 and —1 are solutions of the problem.
Conversely, let f be a solution of the problem and suppose that f (n) is not :|:1
for some n. Then f (72) must have a prime factor p. Then p divides f (n + p) I
2'”? - 1 and p divides f (n)|2" — 1. We conclude that p I 21’ — 1, contradicting
Fermat’s little theorem. Thus f (n) = :|:1 for all n, which immediately implies
that f is a constant polynomial, equal to 1 or —1.
I]
Example 5.17. (ELMO 2016) Let f be a polynomial with integer coefficients
such that n | f (2”) for all n 2 1. Prove that f = 0.
Proof. If p,q are distinct odd primes, then by assumption pq l f(21"1), thus
f(2“) E 0 (mod p). On the other hand, Fermat’s little theorem yields 21"? E
2‘1 (mod p), thus f(21"1) E f(2‘1) (mod p). We conclude that p | f(2‘1) for
any distinct odd primes p, q. Fixing q > 2 and letting p vary, it follows that
f (2‘1) = 0. We conclude that f has infinitely many zeros and so f = 0.
El
Example 5.18. Let p 2 5 be a prime and let a, b be integers such that p divides
a2 + ab + b2. Prove that
(a + b)? E a? + bp
(mod p2).
Proof. If p | a, then p | b and the result is clear. So assume that p does not
divide ab. Let a: be an integer such that bar: E a (mod 112), then 1) | 11:2 + a: + 1
and so p | x3 — 1. Using the binomial formula
m3p—1=(r3—1+1)p—1=(x3—1)p+...+p(:r3—1)
5.1.
Fermat’s lz'ttle theorem
235
we deduce that p2 | 11:31" — 1 and so p2 I (as? — 1)(:1:2p + 11:" + 1). On the other
hand, p does not divide mp — 1, since otherwise, by Fermat’s little theorem, p
would divide so — 1. Since it also divides x2 + :1: + 1, we would have p | 3, a
contradiction. Thus p2 | 9321" + mp + 1. On the other hand, since a: + 1 E —a:2
(mod p), we have (a: + 1)? E —a:2p (mod p2). Combining these results yields
(:1: + 1)? E sup + 1
(mod p2).
The result follows by multiplying this congruence by bp and using that boy E a
(mod p2).
El
Remark 5.19. A stronger result holds: the congruence holds modulo 193, but
the proof is different. One proves that p(X2 + X + 1)2 divides the polynomial
(X + 1)? — X? — 1 in Z[X].
The last series of examples concerns exponential sequences and congru-
ences.
Example 5.20. a) Prove that for any prime p > 2 there are infinitely many
positive integers n such that n - 2“ + 1 E 0 (mod p).
b) (IMO 2005) Which positive integers are relatively prime to all numbers
of the form 2" + 3” + 6" — 1, with n 2 1?
Proof. a) We choose n= k(p— 1) +7‘ with k 2 1 and'r 2 0. Then
n-2”+1E(r—k)2""+1
(modp)
by Fermat’s little theorem. It is thus enough to ensure that p l (r — k)2r + 1.
Simply choose 7' = 0 and k E 1 (mod p).
b) We will prove that 1 is the unique solution of the problem, by showing
that for any prime p there is n 2 1 such that p | an. Note that 2 and 3 divide
a2 = 48, hence we may assume that p > 3. Then using Fermat’s little theorem
we obtain
6ap_2=3-2p_1+2-3p_1+6p’1—6E3+2+1—6E0 modp.
Since gcd (6,p) = 1 it follows that ap_2 E 0 mod p, thus p | ap_2 and the
problem is solved.
El
236
Chapter 5. Congruences involving prime numbers
Example 5.21. (IMO Shortlist 2005) Let a,b be positive integers such that
a” + n divides b” + n for all positive integers n. Prove that a = b.
Proof. Pick a large prime p > max(a, b) and let us look for n such that p I
a." + 17.. Choosing n = (p — 1)k + r for suitable k, 'r, we have by Fermat’s little
theorem on + n E or — k+r (mod p), so it suffices to take any positive integer
r and k = of + r. With this choice we have p | a" + n | b” + n and again by
Fermat’s little theorem
bn+nEbr+r—k=b’—a"
(modp).
We deduce that p | b’" — r for any prime p > b and any positive integer 7'.
Choosing r = 1 we obtain a = b.
III
Example 5.22. (Komal) Let p1 = 2 and pn+1 be the smallest prime divisor of
the number npilpgl...pzl + 1. Prove that every prime number appears in the
sequence p1, p2, . . . .
Proof. To simplify notations, write 92,, = npihmfil. Since pn+1 I as" + 1 and
p1...pn | sun, it is clear that pn+1 is different from any of p1, ..., pn and so the
terms of the sequence are pairwise distinct. It remains to prove that any prime
appears in the sequence. Suppose that this is not the case and let p be the
smallest prime number which does not appear in the sequence. Take 77. > 1)
large enough so that all primes less than p are among p1, ..., pn. Then for any
k 2 1 we have
mn+k E (n + k)pi!...p1(fl-22)!
(mod 1))
since p— 1 | j! for j 2 p— 1 and by Fermat’s little theorem p3! E 1 (mod p) for
such j (note that by assumption p aé pj so gcd(p, pj) = 1). Since p is relatively
prime to 12?... 31—22”, we can choose k such that (n + k)p}!...pz(fl_22)! + 1 E 0
(mod p), thus p | $714.5, + 1. Any prime less than p already divides mn+k + 1,
so p is the smallest prime factor of xn+k + 1. It follows that p = pn+k+1, a
contradiction.
III
Example 5.23. (Romanian Masters in Mathematics 2012) Prove that there are
infinitely many positive integers n such that n divides 22""'1 + 1 but it does
not divide 2” + 1.
5.1.
Fermat’s little theorem
237
Proof. For each k 2 1 let a], = 23" + 1. Observe that
ak+1 = (ak — 1)3 + 1 = 0,1,,(ai — 304‘, + 3),
which immediately yields by induction that 3""‘1 | 04, and so the number
2
oh —- 3a;c + 3
ak
bk: ——
= ak - —
3 - a k; + 1
3
is an integer greater than 1 (since ak > 3) and relatively prime to ah. Let pk
be a prime divisor of bk. Note that pk | ak+1 but pk does not divide ak.
Define nk = 3’“ - pk. Then by Fermat’s little theorem
2’“ + 1 = (23k)p'° + 1 5 23k + 1 = Gk (mOd Pk),
thus pk does not divide 2"'° + 1, in particular 11.], does not divide 2””c + 1.
Next, we claim that nk | 22%“ + 1. Since 71.], | ak+1, it suffices to prove that
ak+1 | 22””1 + 1, or equivalently that 3k+1 l 2’"c + 1. But 2""6 + 1 is a multiple
of 23k + 1 = (1],, which in turn is a multiple of 3"“, so we are done.
III
Remark 5.24. We leave it as an easy exercise for the reader to prove that if n
has the given property then so does 2" + 1. This gives an alternative solution
as soon as we are able to exhibit at least one such n. It is not difficult to check
that n = 57 is such a number.
Example 5.25. (Russia 2013) Find all positive integers k for which there exist
positive integers a and n > 1 such that a" + 1 is the product of the first k odd
primes.
Proof. We will prove that no such k exists. Assume by contradiction that
a” + 1 = p1p2...pk, where p1 = 3,112 = 5,
is the increasing sequence of odd
primes. Clearly k > 1. Note that since 3 divides a" + 1, n must be odd. Next,
we will prove that a 3 pk. Suppose that a > pk, then since a” + 1 < 19%, we
must have n < k and in particular n < 12],. Let p be a prime factor of n, then
p 6 {p1, ...,pk}. Moreover, p divides a” + 1, hence if we let b = an/p, we have
p | bp + 1. Fermat’s little theorem yields p I b+ 1. But then p2 I bp + 1 = a” + 1
since (JP—1 — b19—2 + + 1 E 0 (mod p). This contradicts the fact that a" + 1
is square free and finishes the proof of the claim that a 3 pk.
238
Chapter 5. Congruences involving prime numbers
Next, assume that a > 2 and let p be a prime factor of a — 1.
Then
a" + 1 E 2 (mod p), hence p ¢ {p1,...,pk} and so a > pk, a contradiction.
Thus a = 2. Since 5 | 2” + 1, n must be even, contradiction again!
El
Example 5.26. (China TST 2008) Let n be an integer greater than 1 such that
n divides 2‘P(") + 3‘P(”) +. .+ n‘P("‘). If p1,1.. ., k are all the prime divisors of n
(without multiplicities), prove that 1,111,1+2+. ‘p_+1k+
P1p21-Pk
is an integer.
Proof. Fixi E {1, 2, ..., k}. By assumption p, divides 299W +3‘P(”) +. . .+ni°('”).
If a E {2, 3, ..., n}, then either a is a multiple of pi, and then p,- | a‘P("), or not,
and then a‘PW E 1 (mod pi) (by Fermat’s little theorem and the fact that
p,- — 1 divides <p(n)). Hence 29““) + 399W + . . . + n‘PW is congruent modulo p,
to the number of a E {2, 3,. .,n} which are not multiples of pi. This number
is n — 1 — 1 and since pz | n, it follows that p, Ip” + 1. In particular pf
does not divide n, and so n—
— p1p2.. ..pk Moreover, pi divides 1—11-95 p,- + 1 for
all i. It follows that p2” pk + p1p3.. .12]; +.. .+ m. .pk_1 + 1 is a multiple of
1111,” .,pk, thus also a multiple of p1p2...pk. But this is precisely saying that
—+—2.+ .+—
1k+
is an integer.
El
P1P:- Pk
5.1.3
Application to primes of the form 4k + 3 and 3h + 2
After this series of examples, we come back for a while to more theoretical
issues. The first result shows that nth powers modulo p are solutions to the
congruence art—1 E 1 (mod p) whenever n [ p — 1. We will see later on that
all solutions of this congruence are nth powers modulo p.
Proposition 5.27. Let p be a prime and let n be a positive integer dividing
p— 1. If a is an integer such that the congruence as" E a (mod p) has solutions
(in other words a is an nth power modulo p), then p | a or aPZ—l E 1 (mod p).
Proof. This is an immediate application of Fermat’s little theorem: if p does
not divide a, then
aLIE(x")n =a;1"_1_
=1
and we are done.
(modp)
El
5.1.
Fermat’s little theorem
239
The previous proposition easily yields the following result, which is very
useful in practice. We will see later on that it characterizes primes of the form
4k + 3.
Corollary 5.28. Let p be a prime of the form 4k + 3. If p | a2 + b2 for some
integers a,b then p | a and p | b.
Proof. If p | a then clearly p | b2 and so p | b. Assume now that p does
not divide a and let c be an integer such that ac E 1 (mod 1)). Since p |
(ac)2 + (bc)2, we obtain (be)2 E —1 (mod p) and by the previous proposition
(—1)P;—1 E 1 (mod p). Since p E 3 (mod 4), the last congruence reads —1 E 1
(mod p), plainly absurd.
III
The following theorem is also very useful in practice.
Theorem 5.29. Let p be a prime and let n be a positive integer relatively
prime to p — 1. Then the remainders of 1”,2”, ..., (p — 1)” when divided by p
are a permutation of 1, 2, ...,p — 1.
Proof. Clearly none of these numbers is a multiple of p. It suffices therefore
to prove that the numbers are pairwise incongruent modulo p. Suppose that
p | a" — b” for some a, b 6 {1,2, ...,p — 1} and note that we may assume that
gcd(a, b) = 1 (since p does not divide gcd(a,b)). Then using Fermat’s little
theorem we also have 19 I a?"1 — bl"_1 and so (using proposition 3.35)
p I n(CLn _ bn, ap—l _ bp—l) ___ agcd(n,p—1) _ bgcd(n,p—1) = a _ b,
the last equality being a consequence of our hypothesis. Since p | a — b and
a,b E {1, 2, ...,p — 1}, we must have a = b and we are done.
III
Corollary 5.30. Let p be a. prime of the form 316 + 2. Then
a) The remainders of the numbers 13, 23, ..., (p — 1)3 when divided by p are
a permutation of 1, 2, ...,p — 1.
b) p | a2 + ab + b2 for some integers a, b, then pl a andp | b.
c) If p 7E 2 then there is no integer a: such that 11:2 E —3 (mod p).
240
Chapter 5. Congmences involving prime numbers
Proof. a) This follows directly from theorem 5.29 for n = 3.
b) If p | a then p I b, so assume that p does not divide ab. Then p |
(a — b)(a2 + ab + b2) = a3 — b3 and by part a) we deduce that p I a — b. But
since p I a2 +ab+b2, it follows that p I 3oz, a contradiction. The result follows.
0) Suppose that an is such an integer. Since p 75 2, there is an integer y such
that 2y+1 E a: (mod p), then 4y2+4y+4 E 0 (mod p) and so y2+y+1 E 0
(mod p). But this contradicts part b).
El
Example 5.31. Prove that there are infinitely many primes of the form 4k +1
and infinitely many primes of the form 616 + 1.
Proof. By Schur’s theorem 4.67 there are infinitely many primes p dividing a
number of the form n2 + 1 with n 2 1. Corollary 5.28 shows that any such
p is either equal to 2 or of the form 4k + 1. We deduce the first part of the
problem. For the second part consider similarly prime divisors of numbers of
the form n2 + n + 1 with n 2 1. Corollary 5.30 shows that such primes are of
the form 3k + 1 (thus of the form 6l + 1) or equal to 3. The result follows. El
Example 5.32. Find all integers a and b such that a2 — 1 I b2 + 1.
Proof. Clearly (a, b) = (0,77,) works or all integers n, and we will prove that
these are all solutions. So, suppose that (a, b) is a solution with a 75 0. Then
clearly a 7E :|:1, hence a.2 — 1 > 1. If a is odd, then 8 divides a2 — 1, hence
8 I b2 + 1, which is impossible. Hence a is even, thus a2 — 1 E 3 (mod 4).
Since a2 — 1 > 1, it follows that a2 — 1 has a prime factor p of the form 4k + 3.
But p cannot divide b2 + 1, a contradiction. This finishes the proof.
III
Example 5.33. Prove that if a is an integer, then 20.2 — 1 has no divisors of the
form b2 + 2 with b E Z.
Proof. Suppose that b2 + 2 I 20.2 — 1 for some integers a, b. Then clearly b is
odd, thus b2 + 2 E 3 (mod 4). It follows that b2 + 2 has a prime factor p of
the form 4k + 3. Then p I b2 +2 and p I 2a2 — 1, thus
p l b2 +2+2(2a2 — 1) = b2 + (2a)2.
It follows that p I b and p I 2a, which is clearly impossible.
III
5.1.
Fermat’s little theorem
241
Example 5.34. (Iran 2004) Find all primes p, q, 'r such that p3 = p2 + q2 + T2.
Proof. If p,q,r are not multiples of 3 then p2 + q2 + r2 E 1 + 1 + 1 E 0
(mod 3) and so 3 | p3, a contradiction. Hence one of p, q,r is 3. If p = 3 then
q2 + r2 = 18, which easily yields q = r = 3. Assume that p > 3 and without
loss of generality that r = 3, hence p3 = p2 +q2 + 9, that is p2(p — 1) = q2 + 9.
If p E 1 (mod 4), we deduce that 4 | q2+9, thus 4 | q2+ 1, which is impossible.
Thus p E 3 (mod 4). But since p | q2 + 32, we obtain p | q and p | 3, thus
p=q=3andthenr=3.
III
Example 5.35. (Brazil 1996) Let P(x) = x3 + 14.732 — 253+ 1 and let PM be the
composition of P with itself 77. times (so Pl3](:z:) = P(P(P(a:)))). Prove that
there is a positive integer n such that P[”](a:) E a: (mod 101) for all integers
10.
Proof. Letp = 101. Define the function f : {0, 1, ...,p—1} —> {0, 1, ...,p—1} by
setting f (z) the remainder of P('£) when divided by p. We need to prove that
there is n 2 1 such that f ["1 is the identity map. This is equivalent to saying
that f is bijective: indeed, it is clear that the existence of n forces f being
bijective, so suppose that f is bijective. Since there are finitely many maps
9 : {0,1, ...,p — 1} —> {0,1,...,p — 1}, the sequence of iterates f,f[2],f[3l,
cannot consist of pairwise different functions. So there are 0 S t < j such that
fli] = fU] and we can choose n = j — 2'.
Now, in order to prove that f is bijective, it suffices to prove its injectivity
(since the source and target of f have the same number of elements). But if
N) = f0) then
p I Pa) — P0) = (2' —j)(z'2 +27 +j2 + 140' +1) — 2).
Assume that i # 3' then p I i2 + ij + j2 + 14(z' + j) — 2. Choose a such that
3a E 14 (mod p) and note that
(z'+0z)2+(z'+oz)(j+01)+(j+a)2 a i2+ij+j2+14(i+j)+3a2 E 3a2+2.
But 90:2 E 142 = 196 E —6 (mod p) and so p | 3012. It follows that
(i+a)2+(i+a)(j+a)+(j+a)220 (modp)
242
Chapter 5. Congruences involving prime numbers
and sincepE 2 (mod 3) we deduce thatp I i+a andp | j+a. Thusp | i—j
and then i = j, a contradiction.
[3
Remark 5.36. One can replace 1) = 101 with any prime congruent to 2 modulo
3 and P with any polynomial of the form P(a:) = m3 +aar:2 +bx+c with a2 E 3b
(mod p).
Example 5.37. (IMO Shortlist 2012) Find all triples (x, y, z) of positive integers
such that
93%,,3 + 23) = 2012(xyz + 2).
Proof. Note that 2012 = 41), where p = 503 is a prime of the form 3k + 2. If
p I as, then p2 divides the left-hand side, while the right-hand side is congruent
to 8p modulo p2, a contradiction. Thus p does not divide a: and so p I y3 +23 =
y3 — (—z)3. Since p E 2 (mod 3), it follows that p | y — (—2) = y + 2. Next,
:33 l 4p(a:yz + 2), thus a: | 81) and since gcd(p,x) = 1 we obtain a: | 8. If 4 | x,
then the left-hand side is a multiple of 16, while the right-hand side is not.
Thus a: 6 {1,2}.
Suppose first that :1: = 1, so y3 + 23 = 4p(yz + 2). Clearly 2 l y + 2, so
2p l y + 2. Write the equation as
y_+z . (y2 —yz+z2) = 2(yz+2).
2p
If 93'?” = 1 then y2 — 3yz + 22 = 4 and so (y + z)2 — 5yz = 4, yielding p2 E 1
(mod 5), a contradiction. Thus 92:; 2 2 and then yz + 2 2 y2 — yz + 22, that
is (y — z)2 s 2. Since moreover y E 2 (mod 2), we deduce that y = z and
then y3 = 2p(y2 + 2). Since 1) | y, taking the last equation modulo 102 yields a
contradiction. Hence the case :1; = 1 is impossible.
Assume now that :1: = 2, then the equation becomes
313.
p (yz—yz+z2)=yz+1Sincep | y+z, we obtain yz+1 2 yz—yz+z2 and so (y—z)2 S 1. Ify = 2 we
obtain 2?? - y2 = y2 + 1 and so 312 | 1, giving no solution. Thus, by symmetry,
we may assume that y — z = 1 and then the equation becomes y + z = 10, that
5.1.
Fermat’s little theorem
243
is z = 93—1 = 251 and y = 252. Hence the only solutions are (2,251, 252) and
(2, 252, 251).
El
Example 5.38. (Turkey TST 2013) Find all pairs of positive integers (m, n)
such that
m6 =nn+1 +n— 1.
Proof. If n = 1 then m = 1, which gives a solution of the problem. One easily
checks that n = 2 does not yield any solution, so assume that n > 2 and that
we can find m > 0 such that m6 = 11"“ +n— 1. Let k = n+ 1 > 2 and write
the equation as
mfi=w—1W+k—2
If k is even, then m6 > (k — 1)!“ yields m3 2 (k — 1)% + 1 and then
k—22flk—D§+1>Mk—D+L
a contradiction. A similar argument (using that m6 is a third power) shows
that 3 does not divide k.
Suppose that k E 1 (mod 3), then m6 E —1 (mod 3), a contradiction.
Hence 1:: E 2 (mod 3) and since 1:: is odd it follows that there is a prime p > 2
of the form 33' + 2 dividing k. Taking the equation mod p yields m6 E —
(mod p). However this contradicts corollary 530(0), and so the equation has
[I
no solution except (m, n) = (1,1).
Example 5.39. (Kolmogorov Cup) Let a, b,c be positive integers such that
:—:% is an integer. Prove that this integer is not a multiple of 3.
Proof. Suppose that a2 + b2 + c2 = 3n(a.b + be + co) for some positive integer
n, then
(a + b+ c)2= (3n + 2)(ab+ bc+ ca).
Dividing a, b, c by their greatest common divisor, we may assume that
gcd(a, b, c) = 1. Let 3n + 2 = p‘f‘l...pg" be the prime factorization of 3n + 2
and note that there is t such that pi:
_ 2 (mod 3) and a,- is odd, otherwise
pa‘ —
:1 (mod 3) for all i and 3n + 2E 1 (mod 3), absurd. Fix such 2', then
p,- | a+b+c and since the exponent of p,- in the prime factorization of (a.+b+c)2
244
Chapter 5. Congruences involving prime numbers
is even and that in the prime factorization of 3n + 2 is odd, it follows that
p,- | ab + be + co. But then
OEab+bc+caEab+c(a+b) Eab—(a+b)2=—(a2+ab+b2)
(modpi)
and since p; E 2 (mod 3), we deduce that p,- | a and pi | b, then p,- | c. This
contradicts the relation gcd(a, b, c) = 1 and finishes the proof.
III
5.2
5.2.1
Wilson’s theorem
Wilson’s theorem as criterion of primality
While Fermat’s theorem gives a result that is true for all primes, it does
not provide a conclusive test of primality. Wilson’s theorem gives an exact
criterion for the primality of an integer. The reader is strongly advised to
carefully study the proof of the following theorem, since variations on this
idea will be encountered several times later on.
Theorem 5.40. (Wilson’s theorem) a) For all primes p we have
(p— 1)!+1 E0
(modp).
b) Conversely, if an integer n > 1 satisfies (n —- 1)! + 1 E 0 (mod n), then
n is a prime.
Proof. a) For each i 6 {1,2, ...,p— 1} let i‘1 be the inverse ofi modulo p (recall
that this is the unique number a; between 1 and p — 1 which satisfies is: E 1
(mod p)). We can make a partition of {1, 2, ..., p — 1} into pairs and singletons
as follows: pair each i with i‘l, if i 7E i‘l, otherwise put i in a singleton. The
product of elements in each pair is 1 modulo p, hence (p— 1)! = 1 - 2-
- (p— 1)
is congruent to the product of the numbers in the singletons. However, saying
that i lives in a singleton is the same as saying that i2 E 1 (mod p), which is
the same as (i — 1)(i + 1) E 0 (mod p). Since p is a prime, this is equivalent
to i E :l:1 (mod p). Hence there are only two singletons, and the product of
their elements is —1. The result follows.
b) Suppose that n is composite and write n = ab with a,b > 1. Then
ab— 1 2 a, hence a | (n— 1)!. By hypothesis a | n | (n— 1)! + 1, hence a | 1, a
contradiction. Hence n is a prime.
El
5. 2.
Wilson’s theorem
245
We illustrate the previous theorem with a few examples.
Example 5.41. (Baltic Way 2014) Is 712! + 1 a prime number?
Proof. One easily checks that 719 is a prime number, thus Wilson’s theorem
yields 718! + 1 E 0 (mod 719). Since 718! E 712! - 6! (mod 719) and 6! =
720 E 1 (mod 719), we obtain 719|712! + 1, which shows that 712! + 1 is
composite.
El
Example 5.42. (USAMO 2012) Find all functions f z N —-> N such that for all
positive integers m, n we have m — n I f(m) — f (n) and f (n!) = f (77.)!
Proof. The only solutions in positive integers of the equation n = n! are
n = 1, 2, so the only constant functions which are solutions of the problem are
1,2. Let f be a nonconstant solution. Since f(1) = f(l)! and f(2) = f(2)!, we
deduce that f (1), f (2) 6 {1,2}. If p is an odd prime, then Wilson’s theorem
combined with the hypothesis yield
p l (11—2)! - 1 | f((P-2)!) -f(1) = f(P-2)! -f(1)Since f(l) 6 {1,2} we deduce that p does not divide f(p—2)! and so f(p—2) S
p — 1 for all odd primes p. Suppose that f(p — 2) = p — 1 for some p > 2, then
p | (p — 1)! — f(l) and by Wilson’s theorem again p | f(1)+ 1 thus p | 6. We
deduce that if p > 3, then f(p — 2) g p — 2. Since moreover (p — 2)! — 1 g
f(p—2)!—f(1), it follows that f(1) = 1 and f(p—2) = p—2 for all primesp > 3.
Now, if n is any positive integer then 11— (p—2) | f(n) —f(p—2) = f(n) — (p-2)
andn—(p—Z) I n— (p—2), thusn—(p-2) | f(n)—nfor allprimesp>3.
Thus f (n) — n has infinitely many divisors and so f (n) = n. It follows that
the solutions of the problem are the constant functions 1, 2 and the identity
function.
E!
Example 5.43. Let n > 1 be an odd integer and let S be the set of integers
a: 6 {1,2, ...,n}, such that both a: and a: + 1 are relatively prime to n. Prove
that
{[562 1
2:63
(mod 71.).
246
Chapter 5. Congruences involving prime numbers
Proof. Let a: E S, then since gcd(:1;,n) = 1 there is a unique y 6 {1,2, ...,n—l}
such that my E 1 (mod n). We claim that y E S. Indeed, since n | my — 1 it
is clear that gcd(n, y) = 1. On the other hand, n | $(y + 1) — (a: + 1), thus
gcd(n,y + 1) | gcd(n,x + 1) = 1 and so gcd(n,y + 1) = 1, proving the claim.
Next, we argue as in the proof of Wilson’s theorem: we create a partition of
S into singletons and pairs, by putting a: and y in a pair if :1: 5A y (x,y as
above) and putting :1: in a singleton if a: = y. Then 11,565 a: is congruent to the
product of the elements of S living in singletons. These elements are those
elements of S satisfying 9:2 E 1 (mod n), that is n | (:1; + 1)(:z; — 1). Since
gcd(:c + Ln) = 1, we deduce that n | :1: — 1 and so 1 is the only element of S
living in a singleton. The result follows.
CI
The next example is fairly challenging.
Example 5.44. (Lerch’s congruence) Prove that for all odd primes p we have
11"—1 + 29—1 +
+ (p — 1)1"‘1 E p+ (p - 1)!
(mod p2).
Proof. By Fermat’s little theorem we can find integers x1, ..., xp_1 such that
jp‘l = 1 + my for 1 S j < p. Taking the product, expanding and reducing
modulo p2, we obtain
(p—l)!1"_1 E (1+px1)(1+pa32)...(1+pa:p_1) E 1+p(a:1+...+zp_1)
(mod p2).
Next, Wilson’s theorem allows us to write (p — 1)! = kp — 1 for some integer
k. Then
(p— 1)!1"‘1 = (—1+kp)p‘1 E (—1)j"—1 +(—1)P'2(p— 1)pk E 1+pk
(mod p2).
We conclude that
1”—1 + 21"-1 +
+ (p — 1)“"1 = p — 1 +p(:1;1 +
+ xp_1)
Ep— 1+kp+ (p-l)! (modp2),
which is the desired result.
We can refine a little bit the second part of Wilson’s theorem:
II]
5.2.
Wilson’s theorem
247
Proposition 5.45. For any integer n > 1 the following statements are equivalent:
a) n 94 4 and n is composite.
b) n | (n — 1)!.
Proof. Wilson’s theorem easily yields that b) implies a). Assume now that a)
holds and let us prove b). Write n = ab with a 2 b > 1. If a 7E b then both
factors a. and b appear in the product (ab— 1)! = 1 - 2 - - b- - a- - (ab— 1),
since ab — 1 2 a. Thus in this case n = ab I (ab — 1)! = (n — 1)!. Suppose
that a = b, then since n aé 4 we have a > 2. But then ab — 1 = a2 — 1 > 2a
and so the factors a and 2a appear in the product (11. — 1)! = (a2 — 1)!, thus
n | 2a2 | (n — 1)! and we are done again.
I]
We continue with some illustrations of the previous proposition:
Example 5.46. (Komal B 4616) For which n > 1 do the numbers 1!, ...,n! give
different remainders mod 7;?
Proof. One easily checks that n = 2, 3 are solutions of the problem, so assume
that n > 3 is a solution. Then precisely one of the numbers 1!, 2!, ...,n! is a
multiple of n and since n | n!, it follows that (n — 1)! is not a multiple of n.
Thus by proposition 5.45 either n = 4 or n is a prime. One easily checks that
n = 4 is not a solution, since 2! E 3! (mod 4). So n is a prime and n 2 5. But
Wilson’s theorem yields (n — 2)! E 1 = 1! (mod n), a contradiction. Hence
the only solutions of the problem are 2 and 3.
El
Example 5.47. Find all positive integers n, k such that (n — 1)! + 1 = nk.
Proof. Note that n > 1 and that n | (n — 1)! + 1, thus 77. must be prime
by Wilson’s theorem. One easily checks that (n,k) = (2, 1), (3,1), (5,2) are
solutions of the problem. We will prove that these are all solutions. Suppose
that n > 5, then n — 1 > 4 and n — 1 is not a prime (since n is a prime), thus
by proposition 5.45 we have n — 1 | (n — 2)!. Taking the relation (17. — 2)! =
nk‘1+nk_2+...+n+1 modulo n—l gives n—l l k and so k 2 11—1.
But then (12. — 1)! + 1 2 n ‘1 and since (n — 1)! < (n — 1)"‘1 we deduce that
Tin—1 S (n — 1)“’1, a contradiction. Hence the solutions of the problem are
(n, k) = (2’1)a(3)1)a(5a2)
El
248
Chapter 5. Congruences involving prime numbers
Example 5.48. Find all integers n > 1 for which there is a. permutation
a1,a2,...,an of 1,2,...,n such that {a1,a1a2,...,a1a2...an} is a complete
residue system modulo n.
Proof. If a,- = n for some i < n, then both a1a2...a.,; and a1a2...a,-+1 are multi—
ples of n, a contradiction. Hence an = n. Then a1a2...an_1 = (n — 1)! is not a
multiple of n and by proposition 5.45 n is either 4 or a prime number. Con—
versely, if n = 4 we can take the permutation a1 = 1, a2 = 3, a3 = 2, a4 = 4,
while if n is a prime number, we can consider the permutation defined by
a1 = 1, an =nanda,- = 1+(i—1)'1for2 Sign—1, where (i—l)‘1 isthe
inverse modulo n of i — 1, in {1, ...n — 1}. For 2 S i < n we have
i
a1a2...a,- E Hj(j — 1 '1 E i
j=2
(mod n),
and clearly a1, a2, ..., an E {1,2, ...n} are pairwise distinct, hence they form a
permutation of 1, 2, ...,n. Therefore the answer of the problem is n = 4 and
n = p for some prime p.
III
Yet another slight but useful refinement of Wilson’s theorem is the following.
Theorem 5.49. For all primes p and all 0 S k S p — 1 we have
k!(p — k — 1)! + (—1)’° s 0 (mod p).
Proof. Note that (p — 1)! = k!(k + 1)(k + 2)..(p — 1) and
p— 1 E —1
(modp),...,k+1 E —(p—k—1)
(modp).
Multiplying these congruences and using Wilson’s theorem yields
—1 E (p — 1)! E k!(—1)p_1_k(p — k — 1)!
(mod p).
Taking into account that (—1)1"_1 E 1 (mod p), the result follows.
We continue with several illustrations of the usefulness of theorem 5.49:
D
5. 2.
Wilson’s theorem
249
Example 5.50. Prove that for all odd primes p we have
1l2l...(p — 1)! E (—1)"28;1(%1)! (mod p).
Proof. One can easily check the result for p = 3, so assume that p > 3.
By theorem 5.49 we have
k!(p — 1 — k)! E (—1)’“‘1
(mod p)
for 0 g k S p - 1. Taking the product for 1 S k S %3 yields
’34
93—3
16:1
16:1
I] k! . H (p — 1 — k)! E (—1)°+1+~--+'E—5 (mod p).
Rearranging the factors in the left-hand side and using the identity
:02-1
———=
0+ 1 + u. + 10-5
2
8 —p+2
yields
2
H
2
k! E (—1)P3;1'p+2 E —(-—1)198—_1
(mod p).
lgkaéPg—lgp—2
Multiplying this last congruence by (V71) ! - (p—l)! and using Wilson’s theorem
finally yields the desired result.
El
Example 5.51. (China TST 2010) Prove the existence of an unbounded sequence a1 3 an S
of positive integers having the following property: for all
sufficiently large integers n such that n + 1 is composite, all prime divisors of
n! + 1 are greater than n + an.
Proof. Suppose that p | n! + 1 and n > 2, then clearly p > n since otherwise
p I n!. On the other hand, by theorem 5.49 we have (p — n — 1)!n! E (—1)”—1
(mod p) and since n! E —1 (mod p) we deduce that (p — n — 1)! E (—1)"
(mod p). By assumption n + 1 is composite so p — n — 1 > 0. We cannot have
p — n — 1 = 1 since otherwise we would have n = p — 2 and 1 E (—1)" E
250
Chapter 5. Congruences involving prime numbers
(—1)?"2 = —1 (mod p), a contradiction with p > 2. Hence p — n — 1 2 2 and
since (p — n — 1)! E (—1)” (mod p), we deduce that (p — n — 1)! 2 p — 1 2
n. Thus, if an is the smallest positive integer m for which m! 2 n, then
p — n — 1 2 an for all n > 2 and all prime factors p of n! + 1. It is clear that
an is a nondecreasing unbounded sequence of positive integers.
I]
Example 5.52. (JBMO TST 2013 Turkey) Find all positive integers n such
that 2n+7 | n!— 1.
Proof. Since n = 1 is a solution, we assume in the sequel that n > 1. Note
that ifp is a prime divisor of 2n+7 thenp | n! — 1 and sop 2 72+ 1. If 2n+7
is composite, we deduce that 2n+7 2 (72+ 1)2 and then n2 S 6, forcing n = 2,
which is not a solution of the problem.
Thus 2n + 7 = p is a prime and the hypothesis becomes (%7)! E 1
(mod p). Now theorem 5.49 with k = %7 combined with the previous con-
gruence yield (#y E (—1)? (mod p). Thus
_ 2:9:
10-7,
(1)2
_(—2).1'[
p—j=
—-—2 _.
J€{_5)_3y_1)1’315}
H
p-j
2
(modp).
J€{_5v_3v_1a1)3)5}
Noting that p — j E —j (mod p) and simplifying the above expression, we
obtain
_7
64(—1)% a 152 = 225 (mod p).
If p E 1 (mod 4) then p I 225 +64 = 289 thus p = 17, which gives the solution
n = 5, while if p E 3 (mod 4) then p | 225 — 64 = 161 which then implies
p = 23 and n = 8, another solution of the problem. So 1, 5, 8 are the solutions
[I
of the problem.
Example 5.53. (Saint Petersburg 1996) Prove that for any prime p the numbers
1!, 2!, .., (p — 1)! give at least [fl] difierent remainders when divided by p.
Proof. The key idea is again the congruence
k!(p — 1 — k)! E (—1)'“_1
(mod p)
5.2.
Wilson’s theorem
251
established in theorem 5.49. Multiplying it by p — k yields k!(p — k)! E (—1)’%
(mod p), for 1 S k S p—l. Now let a1, ..., as be the distinct remainders modulo
p given by the numbers 1!, 2!, ..., (p— 1)!. Then the previous congruence shows
that each of the numbers 19 — 1, 2, p — 3, 4,
is congruent to a product of two
elements among a1, ..., as. There are %1 different remainders mod p among
p — 1, 2, p — 3, 4,
and there are at most (g) + s = # possible remainders
given by products of two numbers among 04, ..., (1,. Thus 53%) 2 %1 and we
easily deduce from this that s 2 W15].
[I
We end this section with a beautiful but challenging problem.
Example 5.54. (IMO Shortlist 2005) Let f be a nonconstant polynomial with
integer coefficients and positive leading coeflicient. Prove that f (n!) is composite for infinitely many integers n 2 1.
Proof. Write f(X) = adXd + ad_1Xd‘1 +
+ cm for some integers a0, ..., ad
with ad > 0. If a0 = 0, the result is clear, so assume that a0 aé 0. Given a
prime p, the congruence f ((p — 19)!) E 0 (mod p) is equivalent (by theorem
5.49) to :3], E 0 (mod p), where
(L'k = a0(k — 1)!d + 0.106 — l)!d_1(—1)k +
+ ad(—1)kd.
If k is large enough, say k 2 k0, then a3 | (k — 1)! and k| > 2oz. Choose,
for such k, a prime factor pk of ‘33. Since E: E (—1)“l (mod ad), we have
gcd(pk,ad) = 1. If pk S k — 1, then pk divides 9%:2’ which combined with
at E 0 (mod pk) gives pk | (—1)“, a contradiction. Thus pk 2 k for k 2 k0.
Suppose now that the conclusion of the problem fails, so there is N 2 k0
such that f (n!) is not composite for n 2 N. By increasing N, we may assume
that the function a: —> f (x') — :1: is increasing and positive on [N, 00). By the
previous two paragraphs we know that pk Z k for k 2 N and pk | f ((10,c —— k)!).
Choose now k = ka = a(N+ 1)!+2 for a 2 1, so that k,k+ 1,...,k:+N— 1
are composite and so pk — k 2 N. We conclude that f ((p;c — 16)!) = pk for
these k. Letting 30,, = pka — ka, we obtain f(a:a,!) = ma, + a(N + 1)! + 2 for
all sufliciently large (1. Since the numbers (5a,) are pairwise distinct (by the
previous equality), for infinitely many a we have xa+1 2 .11, + 1 and so
f($a!) _ 37a + (N + 1)! = f(xa+l!) _ $a+1 2 f((33a + 1)!) _ (ma + 1)-
252
Chapter 5. Congraences involving prime numbers
This implies that
f((a:a + 1).’Ba!) — fora!) S 1 + (N + 1)!,
which is impossible since f 23:21:54! —> 00 for a —> 00. The result follows.
5.2.2
III
Application to sums of two squares
We have already seen (an easy consequence of Fermat’s little theorem) that
if p is a prime dividing a number of the form x2 + 1 with a: E Z, then p = 2 or
p E 1 (mod 4). The next important result establishes the converse.
Theorem 5. 55. Let p be a prime. Then the congruence 2:2
has a solution if and only if p 2 or p is of the form 4k + 1.
—1 (mod p)
Proof. We have already seen one implication, so assume that p = 2 or p E 1
(mod 4). We need to prove the existence of an integer a: such that p | 11:2 + 1.
If p = 2 pick m = 1, so assume that p > 2. Taking k: = g in theorem 5.49
and observing that k is even, we obtain
(1%)!2 E _(_1)k = -1 (mod
p),
thus a: = (%)! is a solution of the congruence x2
—1 (mod p).
E!
Remark 5.56. The proof shows that
(ll—El)? E 1
(mod p)
when p E 3 (mod 4), so (%1)! E :|:1 (mod p). Deciding for which primes p
we have (Pg—1)! E 1 (mod p) is a rather delicate problem.
The following example is a refinement of the previous theorem.
Example 5.57. (Iran TST 2004) Let p E 1 (mod 4) be a prime number. Prove
that the equation x2 — py2 = —1 has solutions in positive integers.
5. 2.
Wilson’s theorem
253
Proof. Let (x, y) be the smallest positive solution of the Pell equation x2 —
py2 = 1. Then 3:2 E y2 + 1 (mod 4), which forces a: being odd and y being
even. Next, we havep | 932—1 = (a:+1)(a:—1),thusp| x+1 orp | x—l.
If p | a: — 1, then ”T? and "’7“ are relatively prime numbers whose product is
x—l
the square (3292, thus 712‘
= a2 and 274-1 = b2 for some positive integers a, b
such that ab = 321. Then b2 — pa2 = 1 and by minimality of the solution (x, y)
we must have a 2 y and so x = 1 + 2pc.2 Z 1 + 2py2, obviously impossible.
Thus p | a: + 1 and a similar argument gives the existence of positive integers
a,b such that $101 = a2 and ”’74 = b2. Then b2 - pa2 = —1 and the result
follows.
E]
We can now prove the following beautiful theorem.
Theorem 5.58. (Fermat) Any prime p E 1 (mod 4) can be written as the
sum of two squares.
Proof. This follows immediately from the previous theorem and theorem 3.70.
As the proof of theorem 3.70 is rather delicate, we provide now an alternative
simple (but rather tricky) argument based on infinite descent. Choose an
integer a such that p | a2 + 1, which is possible by the previous theorem.
Replacing a by its remainder when divided by p, we may assume that 0 < a <
p. Then a2 + 1 = kp for some positive integer k, with k < 13.
Let r be the smallest positive integer for which rp is the sum of two squares,
say rp = m2+y2, with as, y nonnegative integers. The previous paragraph shows
that r S k < p. If r = 1, we are done, so suppose that r > 1. Let $131,341 be
integers such that |:1:1| S g, |y1| S g and a: E 51:1 (mod 7'), y E yl (mod r).
Since r | 51:2 + 312, we can write (1:? + y? = ru for some nonnegative integer u.
If 'u. = 0, then r I gcd(a:, y), hence r2 I :62 + y2 = rp, which is impossible, since
1 < r < p. Thus u > 0. Moreover, ru 3 2 - (r/2)2 = r2/2, hence u < 1'.
Finally, we have
rzup = (av2 + y2)(wi + yi) = (M1 + 11211)2 + ($111 - 311302,
and mm +yy1 E ar,'2+y2 E 0 (mod r), wyl —ya:1 E wy—yzz: E 0 (mod r). Thus
the previous equality exhibits up as the sum of two squares. Since u < r, this
contradicts the minimality of r and finishes the proof.
El
254
Chapter 5. Congrnences involving prime numbers
We will give two more proofs of the previous theorem in the sequel. The
first one uses the following very simple yet very powerful result, known as
Thue’s lemma.
Theorem 5.59. (Thae’s lemma) If a and n are relatively prime integers with
n > 1, then there are integers :r,y, not both 0, satisfying 0 S m,y 3 [fl] and
:1: E :|:ay (mod n) (for a suitable choice of the sign :|:).
Proof. Let k = [fl], so that k2 S n < (k + 1)2. Consider all pairs (.73, y)
of integers with 0 S x,y S k. There are (k + 1)2 > n such pairs, thus by
the pigeonhole principle there are two different pairs (x1,y1) and (m2,y2) for
which x1 — ayl and :02 —— ayg give the same remainder when divided by n.
If x1 = 332, then ayl E ayg (mod n) and so y1 = 312 since gcd(a, n) = 1, a
contradiction. Thus x1 75 x2 and, by symmetry, we may assume that :31 < x2.
Setting a: = x2 — 9:1 and y = |y2 — y1| yields the desired result.
El
Fermat’s theorem 5.58 is a simple consequence of theorems 5.55 and 5.59,
as follows. Let p be a prime congruent to 1 modulo 4 and pick an integer a
such that p | a2 + 1. Choose integers w,y as in Thue’s lemma (theorem 5.59
above) with n = p. Then a: E iay (mod p), thus 3:2 E a2y2 E —y2 (mod p).
It follows that x2 + y2 is a positive integer which is divisible by p and smaller
than p + p = 2p (since 0 S at,y S [V13] < (/5). Thus necessarily p = x2 + y2
and the result follows.
Finally, we give yet another beautiful proof of Fermat’s theorem, due to
Zagier. Consider a prime p E 1 (mod 4) and the set
S = {(9641, z) E N3| $2 + 4yz = P}.
We will see below that we can define a map f : S —> S such that f (f (3)) = s for
all s E S and the equation f (x) = a: has exactly one solution {to in S. It follows
that |S| (the number of elements of S) is odd, since we can partition S into
pairs of the form (5, f(3)) (for s 75 x0) and the singleton {:30}. Consider now
the map g : S —> S sending (x,y, z) to (:1), z,y). Then clearly g(g(s)) = s for all
s E S. If the equation g(:1:) = :1: had no solution in S, then the same argument
as above would imply that |S| is even, a contradiction. Thus we can find
(3:, y, z) E S such that g(ac, y, z) = (ray, z) and then p = x2 +4y2 = x2 + (2y)2
is a sum of two squares.
5. 2.
Wilson’s theorem
255
We still need to construct the map f : S ——> .3 above. For (x, y, z) E 8'
define f (11:, y, 2) as follows. First, note that :1: 9E y — 2 (otherwise p = (y + z)2
is a perfect square, a contradiction) and a: aé 2y (otherwise 19 is even). Next, if
x < y—z set f(x,y,z) = (a:+2z,z,y—x—z), ify—z < a: < 23; set f(a:,y,z) =
(2y—m, y, x—y+z) and finally, ifx > 23/ set f(:v, y, z) = (m—2y,x—y+z, y). A
simple, yet tedious computation shows that f (3:, y, z) E S and that f (f (3)) = s
for all s E 5. Moreover, the equation f (cc, y, z) = (3:, y, z) is easily seen to have
exactly one solution: for such (.73, y, z) we must have y—z < a: < 2y and :1: = y,
thus :62 + 4x2 = p and then x = 1 = y and z = 22—1. The theorem is therefore
proved.
Using Fermat’s theorem, we can finally answer the question: which positive
integers are sums of two squares? Recall that if p is a prime, then '01,, (n) is the
exponent of the prime p in the factorization of n, i.e. the largest nonnegative
integer k for which pk | n.
Theorem 5.60. An integer n > 1 is the sum of two squares if and only if
vp(n) is even for all primes p E 3 (mod 4) dividing n.
Proof. Suppose that vp(n) is even for all primes p E 3 (mod 4) dividing n.
Thus we can write n = 2“ - m2 - p1...pk, where p1, ..., pk are primes congruent to
1 mod 4 (not necessarily distinct) and m is a positive integer. Since 2, m2 and
each of 121,...,p;c are sums of two squares (by Fermat’s theorem), and since
the set of sums of two squares is stable under multiplication by Lagrange’s
identity
(a2 + b2)(c2 + d2) = (ac + bd)2 + (ad — bc)2,
it follows that n is a sum of two squares.
To prove the converse, suppose that n = a2 + b2 for some integers a, b.
If p E 3 (mod 4) and k = vp(n) 2 1, then pk | a2 + b2. By corollary 5.28,
we obtain p I gcd(a, b). Write a = pa1,b = pbl. Then 12pm? + b?) = k — 2.
If k — 2 = 0, we are done, otherwise we repeat the argument and we have
a1 = pag, b = pbg and vp(a§ + b3) = k — 4. Continuing in this way we decrease
k at every step by 2. At some moment we must reach 0, hence k is even.
Example 5.61. (USA TST 2008) Solve in integers the equation x2 = y7 + 7.
El
256
Chapter 5. Congruences involving prime numbers
Proof. Since there are no solutions for y < —1, we may assume that y + 2 > 0.
It is not difficult to see that y E 1 (mod 4). We rewrite the equation as
m2 + 112 = y7 + 27 or equivalently
51:2 + 112 = (y + 2)(y6 — 2y5 +4y4 — 8y3 + 16y2 — 32y + 64).
Since y E 1 (mod 4), we have y + 2 E 3 (mod 4), thus there exists a prime q
such that 22.1 (y + 2) is odd. Note that q does not divide y6 — 2y5 + 4y4 — 8y3 +
16y2 — 32y+64, as otherwise q would divide 7- 64 and x2 + 112, a contradiction.
Thus vq (y7+27) is odd, which is impossible, as it equals vq(a:2 + 112) and q E 3
(mod 4). The result follows.
E
Example 5.62. Find the least nonnegative integer n for which there is a nonconstant function f : Z —) [0, 00) such that for all integers w, y
a) f (661/) = f($)f(y);
b) 2f($2 + yZ) _ f0”) _ f(y) E {0, 1:2, “'an}
For this n find all functions with the above properties.
Proof. Note first that for n = 1 there are functions satisfying a) and b).
Indeed, for any prime p with p E 3 (mod 4) define fp : Z —> [0, 00) by fp(x) =
0 if p|m and fp(:r) = 1, otherwise. Then 3.) follows from the fact that if p|my
then p|as or ply. On the other hand pla:2 +y2 ifi'p|x and ply (by corollary 5.28),
and this implies b).
Suppose now that f is a nonconstant function that satisfies a) and b) with
n = 0. Then 2,]"(x2 + 312) = f(a:) + fly) and hence
2f(96)2 = 2f($2) = 2f(~’v2 + 0) = f0?) + f(0)In particular, f (O)2 = f(0) If f(0) = 1 then a) implies that f is the constant
function 1, so f(0) = 0. Consequently 2_/"(a:)2 = f(x) for every :1: E Z. This
together with a) imply that f (1:)2 = f(:32) = 2f(.’1,'2)2 = 2f (x)4. In particular,
2f(:1r:)2 7E 1 for all a: and therefore f is the zero function, a contradiction. So
n = 1 is the least integer with required properties.
We will prove now that if n = 1, then each nonconstant function f satisfying a) and b) is of the form fp, or the function equal to 1 at nonzero integers
5. 2.
Wilson’s theorem
257
and 0 at 0. We already know that f(0) = 0. Since f(1)2 = f(1) and f(1) = 0
would make f identically zero and therefore constant, we have f (1) = 1. Also,
21%?)2 - f(x) = 2f(332 +0) - f(x) - f(0) 6 {0, 1}
for all a: E Z, thus f (x) 6 {0,1} for all :13. (The third possibility f(x) = %
is excluded since it would make f (.732) = i, an excluded value.) We have
f(-1)2 = f(1) = 1, SO f(—1) = 1- Then f(-w) = f(-1)f($) = flat) and it
follows from a) that it suffices to find f (p) for any prime 1). Suppose there is
a: > 0 with f (x) = 0. Since a: 75 1 it follows that for some prime divisor p of a:
we have f (p) = 0. Suppose that there is another prime q for which f (q) = 0.
Then 2f(p2 + q2) E {0, 1} shows that f(p2 + q2) = 0. Hence for all integers a
and b we have
0 = 2f(a2 + b2)f(p2 + 112) = 2f((ap + bq)2 + (aq — bp)2)On the other hand 0 S f(x) + f(y) S 2f(x2 + 3/2) and the above identities
show that f (ap + bq) = f(aq — bp) = 0. But p and q are relatively prime and
by Bézout’s lemma there are integers a and b such that aq — bp = 1. Then
1 = f (1) = f (aq — bp) = 0, a contradiction. So, there is only one prime p
for which f(p) = 0. Suppose that p = 2. Then f (x) = 0 for as even and
2f(az:2 + y2) = 0 for x,y odd. Hence f(w) = f(y) = O for all odd :3 and y,
a contradiction since f is not constant. Suppose that p E 1 (mod 4) and
write 1) = a2 + b2 for some positive integers a, b (which is possible by Fermat’s
theorem). Then f (a) = f(b) = 0, but max(a, b) > 1 and there is a prime q
that divides it. Therefore f (q) = 0, a contradiction since q < p. Hence p E 3
(mod 4) and we have that f(:13) = 0 if :1: is divisible by p and f (so) = 1 if not.
Hence f = fp.
III
Example 5.63. Find all functions f : N —> Z with the properties:
i) f (a) 2 f (b) whenever a, divides b;
ii) f(ab) + f(a2 + b2) = f(a) + f(b) for all a, b e N.
Proof. By considering the function f (x) — f (1), we may assume that f (1) = 0,
so f (n) S 0 for all n by the first condition. The second condition with b = 1,
then reads f (a.2 + 1) = f (1) = 0 and in particular f (2) = 0.
258
Chapter 5. Congruences involving prime numbers
We prove next that f(p) = 0 for all primes p E 1 (mod 4). Indeed, take
such a prime p and consider a positive integer a such that pla2 + 1 (it exists
by theorem 5.55). Then f(p) 2 f(a,2 + 1) = f(1) = 0. Since f(p) g 0, we
deduce that f (p) = 0.
Next, we observe that if f(a) = f(b) = 0, then f(ab) + f(a2 + b2) = 0 and
f (ab), f(a2 + b2) S 0, hence f (ab) = 0. It follows immediately from this and
the previous paragraph that f (n) = 0 whenever n is a product of primes (not
necessarily distinct) congruent to 1 mod 4.
Suppose now that gcd(a, b) = 1. Then a2 + b2 is a product of primes
congruent to 1 mod 4, except for a possible power of 2.
Since we saw that f(2) = 0, the same argument as in the previous paragraph shows that f(a2 + b2) = 0 and so f(ab) = f (a) + f (b)
We compute next f(pk) for a prime p. We saw that if f(a) = f(b) = 0
then f(ab) = 0, so f(p") = 0 ifp = 2 or ifp E 1 (mod 4), so we may assume
that p E 3 (mod 4). By taking b = ak in the second relation and using
that f(ak) 2 f(ak‘H) and f(a) 2 f(a2 + am“), we deduce that both of these
inequalities are equalities and so f(ah) = f(ak‘l'l) for all a and k. We conclude
that f(p’“) = f(p)Putting everything together we deduce that if n = plfl...p£,cr for some dis-
tinct primes p1, ..., p,. and k1, ..., k, positive integers, then f (n) = f(pl) + +
f (pr) and each f (1),) is 0 if pi = 2 or pi = 1 (mod 4). This determines f
uniquely if we fix the values of f(p) for all primes p E 3 (mod 4). This gives
us a family of solutions and we will check now that we can allow arbitrary
values at these primes.
So, choose any function 9 defined on the set of primes p E 3 (mod 4) and
define f(1)= f(2) = 0 and f(p) = g(p) ifp E 3 (mod 4), f(p) = 0 for the
other primes p and extend f to all positive integers by
mil-up?) = f(m) + + f(pr).
We have to check that f is a solution. But the first relation is clear and
the second one follows by considering the prime factorization of a, b, gcd(a, b)
and using the fact that for gcd(a, b) = 1 the prime factors of a2 + b2 are all
congruent 2 or 1 (mod 4), on which f vanishes.
El
5.3. Lagmnge’s theorem and applications
5.3
5.3.1
259
Lagrange’s theorem and applications
The number of solutions of polynomial congruences
Fermat’s little theorem has the striking consequence that for any prime p
the polynomial Xp — X has p different zeros modulo p, namely 0,1, ..., p — 1.
There is another polynomial having such zeros, namely X (X — 1)...(X —p+ 1).
Of course, X? —X and X (X — 1)...(X — p+1) are not equal as polynomials. In
this section we will define a congruence relation for polynomials with integer
coeflicients and we will prove that X? — X and X (X — 1)...(X — p + 1) are
congruent modulo p. Using this, we will study the map a: I—> md (mod p) when
d is a positive integer and p is a prime. This study will play a key role in the
last chapter.
Let us start by introducing a congruence relation between polynomials. We
denote by Z[X] the set of polynomials with integer coefficients. The following
definition should not be a great surprise for the reader.
Definition 5.64. Let n be an integer and let f, g E Z[X]. We say that f and
g are congruent modulo n and write f E 9 (mod n) if all coefficients of the
polynomial f — g are multiples of n, in other words, if there is h E Z[X] such
that f — g = nh.
We note straight away one common mistake: if f E 9 (mod n) then clearly
f(x) E g(:c) (mod n) for all integers 1:. However, the converse does not hold:
take f = X2 + X and g = 2, then f (:12) E g(:r) E 0 (mod 2) for all integers x,
however f is not congruent to g modulo 2, since the coefficients of X2 + X — 2
are not all even.
As an example, the polynomials X (X -1)(X —2) and X3—X are congruent
modulo 3 since the coefficients of their difference
(X3 — X) — X(X — 1)(X — 2): 3X(X — 1)
are multiples of 3. On the other hand, X3 — X and X (X — 1)(X — 2) are not
congruent modulo n for any n > 1 different from 3.
Just as for integers, one can immediately prove the following formal properties of congruences for polynomials. We leave the simple proofs to the reader.
260
Chapter 5. Congruences involving prime numbers
Proposition 5.65. For all polynomials f, g, h, k e Z[X] and all n we have
a) fEf (mod n).
b) Iff E 9 (mod n), then g E f (mod n).
c) Iff E g (mod n) andg E h (mod n), then f E h (mod n).
d) Iff Eg (mod n) andh E k (mod n), then f+hE g+k (mod n) and
fh E gk (mod n).
Example 5.66. Prove that for all f, g E Z[X] and all primes p we have
(f + g)” E f? + 9" (mod p) and f(X)p a f(XP) (mod p).
Proof. The first congruence follows directly from the binomial formula
17-1
p
(f + g)? = f" + 9" + Z (k) fp‘kgk
Ic=1
and the fact that p | (£) for 1 S k _<_ p — 1. For the second congruence, write
f (X) = a0 +a1X + +anX". Applying repeatedly the first congruence yields
f(X)p = (a0 + a1X +
+ anX")P E a8 + (a1X)p +
+ (anX")p
(mod p).
Using Fermat’s little theorem we obtain af E ai (mod p), and the result follows.
III
The next very useful result extends the usual property of primes (if p
divides ab then p divides a or b) to polynomials.
Theorem 5.67. (Gauss’ lemma for polynomials) Let p be a prime and let
f, g be polynomials with integer coefl‘icients such that f - g E 0 (mod p). Then
f E0 (modp) org E0 (mod p).
Proof. Assume that this is not the case and write
f(X) = ao + a1X +
+ adX“,
g = be + l +
+ bexe
for some integers a0, ..., ad, b0, ..., be. Let i be the smallest nonnegative integer
for which p does not divide a.- (i exists since by assumption f is not congruent
to 0 modulo p). Similarly, let j be the smallest nonnegative integer for which
5. 3. Lagrange ’s theorem and applications
261
p does not divide bj. The coeflicient of X{H in f (X)g(X) is Zu+v=i+j aubv
and by assumption it is divisible by p. On the other hand, if u + v = 'l+ j and
(u, 22) 7e (1', j), then u < i or v < j, thus aubv is divisible by p. It follows that
0E
Z
aubv E aibj
(mod p),
u+v=i+j
which contradicts the fact that a,- and bj are not divisible by p. The result
follows.
E
The fundamental link between congruences of polynomials and solutions
of polynomial congruences is the following
Theorem 5.68. Let a be an integer and let f E Z[X]. Then f(a) E 0
(mod n) if and only if there is g 6 Z[X] such that f(X) E (X — a)g(X)
(mod n). Moreover, if this is the case then we can choose 9 of degree less than
or equal to deg(f) — 1.
Proof. Suppose first that such 9 exists. By definition there is a polynomial h
with integer coefficients such that f(X) = (X — a)g(X) + nh(X). Plugging in
X = a yields f (a) = nh(a) E 0 (mod n). Suppose conversely that f (a) E 0
(mod n). Write f(X) = co + 01X +
note that
+ cd for some integers co, ..., cd and
f(X) — N») = c1(X — a) + c2(X2 — a2) + + cd<Xd — a") = (X — a)g(X),
with
g(X) = c1 + 02(X + a) +
+ c.1(X‘l—1 +
+ a“),
a polynomial with integer coefficients of degree less than or equal to d — 1.
Since f(X) — (X — a)g(X) = f(a) and f(a) E 0 (mod n), we have f(X) E
(X — a)g(X) (mod n) and we are done.
El
We can establish now the following very important result, which is the mod
p analogue of the fact that any nonzero polynomial f with complex coefficients
has at most deg f distinct roots.
262
Chapter 5. Congruences involving prime numbers
Theorem 5.69. (Lagrange) Let p be a prime and let f be a polynomial with
integer coefi‘icients. If at least one of the coeflicients of f is not a multiple
of p (in other words if f is not congruent to 0 mod p), then the congruence
f (:13) E 0 (mod p) has at most deg f solutions.
Proof. We prove this by induction on the degree d of f. The case d = 0 being
clear, assume that the result holds for d and let us prove it for d + 1. Let
f E Z[X] be a polynomial of degree d + 1 which is not congruent to 0 mod p.
If the congruence f (re) E 0 (mod p) has no solutions, we are done, so assume
that this is not the case and pick a solution a. The previous theorem shows the
existence of a polynomial g E Z[X] such that f(X) E (X — a)g(X) (mod p)
and deg(g) S d. Note that g is not 0 mod p, since f is not 0 mod p. Thus
by the inductive hypothesis the congruence g(:c) E 0 (mod p) has at most d
solutions. Since each solution of the congruence f (x) E 0 (mod p) is either a
or a solution of the congruence g(a:) E 0 (mod p) (this crucially uses the fact
that p is a prime, contrary to all previous arguments), the result follows.
El
Remark 5.70. The result is completely false for congruences f (2:) E 0 (mod n),
where n is composite. For instance the congruence 9:3 E a: (mod 6) has 6
solutions, yet the polynomial X3 — X is certainly not congruent to 0 mod 6.
The following very useful result is an immediate consequence of Fermat’s
little theorem and Lagrange’s theorem.
Theorem 5.71. For all primes p we have
XP—l — 1 a (X — 1)(X — 2)...(X —p + 1) (mod p).
Proof. Let f be the difference between the left-hand side and the right-hand
side. Then degf S p— 2, since X?“1 — 1 and (X — 1)...(X —p+ 1) are monic
of degree p — 1. On the other hand Fermat’s little theorem yields f (i) E 0
(mod p) for 1 S i S p — 1, hence by Lagrange’s theorem f E 0 (mod p), as
desired.
El
The previous theorem encodes a large family of congruences, among which
is Wilson’s theorem (p — 1)! + 1 E 0 (mod p). Indeed, this follows by looking
5.3.
Lagmnge’s theorem and applications
263
at the constant terms of the polynomials appearing in the previous theorem.
By looking at the coeflicient of Xp‘l"z with 1 S 12 < p — 1, we obtain
klkg...k,: a 0 (mod p).
2
ISk1<k2<m<ki<p
The following rather interesting examples illustrate the power of the previous theorems.
Example 5.72. (Romania TST 2001) Find all pairs (m, n) of positive integers,
with mm. 2 2, such that a” — 1 is divisible by m for each a E {1, 2,3, . . . ,n}.
Proof. Let p be a prime factor of m, so that p | a" — 1 for 1 S a S n. p S n,
we obtain p | p" — 1, a contradiction. Thus p 2 72+ 1. It follows that 1, 2, ..., n
are pairwise distinct solutions of the polynomial congruence x" E 1 (mod p).
Thus the polynomial congruence
x" — 1 — (a: — 1)...(:z: — n) E 0 (mod p)
has degree at most 77. — 1 and at least n different solutions. Lagrange’s theorem
implies that
X" — 1 E (X — 1)(X — 2)...(X —— n)
.
.
.
(mod p).
n_1
ngn+12
.
Cons1der1ng the coefiiCIents of X
, we deduce that p |
2 . Slnce p > n,
the only possibility is p = n + 1. In particular, n + 1 is a prime p > 2 and
m has a unique prime factor, namely p. We wfll show that p2 cannot divide
a1"‘1 — 1 for all 1 S a S p — 1, establishing therefore that m = p. Indeed, note
that
(p - 1)?‘1L - 1 E (-1)1"‘1 + (-1)”’2(P - 1)p - 1 E -p(p - 1) (mod p2)
and so p2 does not divide (p — 1)?"1 — 1.
El
Example 5.73. (Iran TST 2011) Let p be a prime, k a positive integer and let
f E Z[X] such that pk divides f(z) for all m E Z. If k: S p, prove that there
are polynomials 90,91, ...,gk 6 Z[X] such that
k
f(X) = Zp"“(XP — X)‘ . 94X)i=0
264
Chapter 5. Congmences involving prime numbers
Proof. We will prove this result by induction on k. Suppose first that k = 1
and write f(X) = (X9 — X)q(X) + 'r(X) for some polynomials q,'r E Z[X]
such that degr < p (this is possible since XP — X is monic). The hypothesis
combined with Fermat’s little theorem show that p | r(:v) for all integers :0.
Since degr < p, Lagrange’s theorem yields r E 0 (mod p) and the result
follows.
Let us prove the inductive step. Assume that the result holds for k, that
k + 1 g p and that p"’+1 divides f(x) for all :13. By the inductive hypothesis
there are polynomials g; E Z[X] such that
k
f(X) = Epic—“X? — XV ° gi(X)i=0
If as and z are any integers and if y = SET—5” (an integer by Fermat’s little
theorem), the binomial formula gives
(00 + In)” - (z + W) E p(y - 2) (mod 1’2),
therefore
k
n
k
a
f(w + 192) E 210%! - z)'gi(w + W) E 1)" ECU - Z)”gi(w) (mod 10"“)11:0
i=0
We conclude that p divides 219:0 (y — z)‘g.i (x) for any a: and z, and replacing
z with y — 2, it follows that 2L0 zigi(x) E 0 (mod p) for all integers z and (1:.
Since k < p, Lagrange’s theorem yields gi(:z:) E 0 (mod p) for all i and all 11:.
Applying the base case, we can find hi, n; e Z[X] such that
$00 = (X‘p - X)hi(X) +m(X)~
Replacing these expressions in f(X) = 219:0 pk‘i (XP — X)5 -g¢ (X) finishes the
inductive step.
El
Example 5.74. (USA TST 2009) Let p 2 5 be a prime and let a, b, c be integers
such that p does not divide (a — b)(b — c)(c — a). Let i, j,k 2 0 be integers
such that p — 1 | i+ j + k and such that for all integers a:
10|(~’c - c)(x - b)(w - C)[(w - ”(It - b)j(w - CY” - 1]Prove that the numbers i, j, k are divisible by p — 1.
5.3.
Lagrange ’s theorem and applications
265
Proof. Using Fermat’s little theorem, we may replace 2‘, j, k with their remainders mod p — 1, without afiecting the hypothesis or the conclusion. Thus we
may assume that O S 2',j,k < p — 1 and need to prove that 2' = j = k = 0.
Assume that this is not the case. Since p — 1 I z'+ j + k, we deduce that
i+j+k = p—l or 2(p—1). Ifi+j+k = 2(p—1), we replace each
ac E {i, j, k} with p — 1 — as, which does not change the hypothesis or the conclusion. Thus we may assume that i+ j + k = p — 1. Finally, we may assume
that i = max(i,j, k).
Multiplying the congruence
(a: — a)(:r — b)(z — c)[(a: — a)i(x — b)j(a: — 0),“ — 1] E 0
(mod p)
by (a: — a)j+k and using Fermat’s little theorem, we obtain
f(w) == (50 - (1)06 — b)(x - C)[($ - b)j(w — C)k - (90 - a)j+kl E 0 (mod P)for all m. Sincep 2 5, we have
2
—1
deg(f)$3+j+k—1$2+L3—Z<p
and so Lagrange’s theorem yields f (X) E 0 (mod p). Combining this with
theorem 5.67, we obtain
(X — b)j(X — c)k E (X — a)j+k
(mod p).
Sincez' < p—l and i+j+k = 12—], we have j+k aé 0, thus (X—b)j(X—c)k
vanishes at b or c. We deduce that p divides (b — a)j+k or (c — a)j+’°, which
contradicts the hypothesis. Thus 2' = j = k = 0 and the result follows.
El
Example 5.75. (China TST 2009) Prove the existence of a number c > 0 such
that for any prime p there are at most cp2/3 positive integers n for which p
divides n! + 1.
Proof. Letp>2beaprimeandlet1 <n1 <n2 <
<nm <pbea11
solutions of the congruence n! E —1 (mod p) (note that if p | n! + 1 then
Chapter 5. Cong'ruences involving prime numbers
266
n < p). We may assume that m > 1, otherwise we are done. Combining the
congruences n,-! E —1 (mod p) and ni+1! E —1 (mod p) yields
(ni + 1)(m + 2)... (n,- + 72,-4.1 — m) E 1
(mod p).
Lagrange’s theorem shows that for each 1 S k < p the congruence
(:1:+1)(x+2)...(a:+k)E 1
(modp)
has at most k: solutions. We deduce that for each 1 S k < p there are at most
k indices 1' such that ni+1 — 17., = k. This is the key point of the proof, the
remaining part of the argument being purely combinatorial.
Choose a positive integer j such that
(1+1)(J+2) >m> .7(J+1).
2
_
—
2
Since for any k 6 {1,2, ...,p — 1} the equation ni+1 — n; = k: has at most k
solutions i and since m 2 33%) =
i=1 j, we deduce that when the differences
n¢+1 —— n, are written in ascending order, the first is at least 1, the next two
are at least 2, and so on, each time the next 12 diflerences are at least 72. It
follows that
.
m-l
201241 —ni) Z 12 +22+
12:1
and so
.
1 2
.
1
+j2 = W
_ _
1 2.
1
p>nm—n1 Z30+ )6( 1+ )-
In particular, 1) > 333 and j < (312)1/3. Since m S (j + 1)2 S 4j2, the result
follows.
5.3.2
E
The congruence 56" E 1 (mod p)
After this series of examples, we come back to more theoretical issues.
An immediate consequence of Lagrange’s theorem is the following innocentlooking but nontrivial result.
5. 3.
Lagrange ’s theorem and applications
267
Corollary 5.76. Let p be a prime and let k be a positive integer such that
93" E (mod p) for all integers :1: which are not multiples of p. Then p— 1 | k.
Proof. Let d = gcd(k, p — 1), then d | p — 1 and moreover for all a: not divisible
by p we have 27d E 1 (mod p) (since xk E 1 (mod p) by assumption and
cup—1 E (mod p) by Fermat’s little theorem). Thus the congruence rd E 1
(mod p) has at least p — 1 solutions. Lagrange’s theorem yields d 2 p — 1.
Since (1 = gcd(k, p — 1), the result follows.
III
We obtain now immediately the following very important and useful congruence (which is not very easy to prove directly).
Corollary 5.77. a) If j is a positive integer, not divisible by p — 1, then
1j+2j+...+(p—1)j so (modp).
b) If f is a polynomial with integer coeflicients and deg(f) < p — 1, then
f(O) + f(1) +
+f(p — 1) E 0 (mod p).
Proof. a) By the previous corollary we can choose an integer so which is not
divisible by p and such that p does not divide m3 — 1. Let S = 17 + 27 +
+
(p — 1)j. Since the remainders of 9:, 2:13, ..., (p — 1)x when divided by p are a
permutation of 1, 2, ..., p — 1, we obtain
273' = xj + (2x)j +
+ ((p— 1)a:)j E lj +2j +
+ (p— 1)j E S (mod p),
thus p divides S'(:1:j — 1).Since p does not divide xj — 1, the result follows.
b) Write f(X) = a0 + a1X +
d < p — 1. Then
+ adXd for some integers a0, ...,ad and
f(0)+f(1)+...+f(p—1)= pao+a1(1+2+...+(p—1))+...+ad(1d+...+(p—1)d).
By part a.) each of the sums 1 + 2+
by p. The result follows.
+ (p— 1),..., 101+
+ (p— 1)d is divisible
I]
268
Chapter 5. Congrnences involving prime numbers
Before illustrating the previous results with some concrete examples, we
would like to discuss in more detail the congruence :13" E 1 (mod p) where d
is a positive integer and p is a prime. This will play a crucial role in chapter
6. For this note that we can always reduce the study to the case d | p — 1,
since the congruence {Ed E 1 (mod p) has exactly the same solutions as the
congruence a35°d(d’p_1) E 1 (mod p) (by Fermat’s little theorem and the fact
that gcd(:1:d —— 1, asp—1 — 1) = x3°d(d’p_1) — 1). Again, Fermat’s little theorem
combined with Lagrange’s theorem easily yield the following result.
Theorem 5.78. Let p be a prime and let d be a positive divisor ofp— 1. Then
the congruence acd E 1 (mod p) has exactly d solutions.
Proof. Since cl | p — 1, we can find a polynomial with integer coefficients
f(X) such that X1’_1 — 1 = (Xd — 1)f(X) (explicitly, f(X) = 1 + Xd +
+
X (PE—1‘1”). By Fermat’s little theorem the congruence mp4 E 1 (mod p) has
p — 1 solutions. Each solution of this congruence is a solution of one of the
congruences red E 1 (mod p) and f (as) E 0 (mod p). By Lagrange’s theorem,
these two congruences have at most d, respectively p — 1 — d solutions. Since
in total they have p — 1 = d + p — 1 — d solutions, we deduce that the first one
has d solutions and the second one p — 1 — d solutions. The result follows.
III
Let us illustrate the previous results with some concrete examples.
Example 5.79. A Carmichael number is a positive integer n such that nla” — a
for any integer a.
a) Prove that n is a Carmichael number if and only if n is squarefree and
p — 1 divides n — 1 for any prime p dividing n.
b) Find all Carmichael numbers of the form 3pq with p, q primes.
Proof. a) Suppose that n is a Carmichael number, then n divides p” — p for
any prime p. Thus if p | n, p2 cannot divide n (otherwise we would obtain
p2 | p“ — p and then p2 I p). Thus n is squarefree. Next, if p | n is a prime
then p | (In—1 — 1 for any a relatively prime to p and so p — 1|n — 1 by corollary
5.76. The converse follows from example 5.3.
b) By part a) we obtain that 3, p, q are distinct and that p — 1|3pq — 1 and
q — 1|3pq — 1. The first congruence implies that p — 1|3q — 1, while the second
5.3.
Lagrange ’s theorem and applications
269
yields q — 1|3p — 1. We may assume that p > q, so that 3q — 1 < 3(p — 1).
Thus either p — 1 = 3q — 1 (impossible, as p aé 3) or 2(p — 1) = 3q — 1. So
2p = 3q + 1 and since q — 1|3p + 1, we immediately obtain that q — 1|9q + 1.
This forces q — 1|10 and we easily infer that q = 11 and p = 17. Thus 17. = 561
is the only Carmichael number of the form 3pq.
El
Example 5.80. (Romania TST 2008) Let n be an integer greater than 1. Compute the greatest common divisor of the numbers 2” — 2, 3" — 3, ..., n” —— n for
given n.
Proof. For n = 2 the answer is 2, so assume that n > 2. Let
d = gcd(2” — 2, ...,n” — n)
and let p be a prime factor of d. If p > n, then the congruence of degree n m" E
:5 (mod p) has pairwise distinct solutions 0, 1, ..., n modulo p, a contradiction
with Lagrange’s theorem. Thus p S n. In particular d | p” —p and so p2 cannot
divide (1. Next, p | a"—1 — 1 for all a relatively prime to p, since 1) | a," — a for
1 S a S n and n 2 p. Corollary 5.76 gives p — 1 | n — 1. Conversely, ifp is a
prime such that p — 1 | n — 1 then p | a" — a for all integers a and so p | d. In
other words, we have just proved that
d=Hp.
El
p—lIn—l
Example 5.81. (IMO 1997 Shortlist) Let p be a prime and let f be a polynomial
with integer coefficients such that f (0) = 0, f (1) = 1 and flu.) is congruent
to 0 or 1 modulo p for all integers x. Prove that deg(f) 2 p — 1.
Proof. Assuming the contrary, corollary 5.77 yields
f(0) + f(1) +
+ f(p— 1) E 0
(mod p).
But the left-hand side is congruent to a sum of zeros and ones by assumption,
and there is at least one zero and at least one 1 in this sum. It is thus
impossible to get a multiple of p.
El
270
Chapter 5. Congmences involving prime numbers
Example 5.82. (Mathematical Reflections 0 21) Find the least degree of a
nonconstant polynomial f with integer coefficients having the property that
f(O),f(1), ..., f(p — 1) are all perfect (p — 1)th powers.
Proof. Let f be such a polynomial and write f (i) = 93f_1 for some integers
coo, ..., xp_1. By Fermat’s little theorem we deduce that f (i) is congruent to 0
or 1 mod p for all 0 S i S p — 1. Assume that deg f < p — 1, then corollary
5.77 gives
f(O) + f(l) +
+ f(p— 1) E 0 (mod p)
and since each of the numbers f(0), ..., f(p — 1) is congruent to 0 or 1 mod p
we deduce that f (0), ..., f(p — 1) are all congruent to 0 mod p or all congruent
to 1 mod p. Thus there is e 6 {0,1} such that the congruence f(w) E 5
(mod p) has at least p solutions, which contradicts Lagrange’s theorem. Thus
deg f 2 p — 1. Since f (X) = X19—1 obviously satisfies the required properties,
we conclude that the answer is p — 1.
III
Example 5.83. (Giuga) Let n be an integer greater than 1. Prove that
nl1+1n—1+2n—1+_H+(n_1)n—1
if and only if for every prime divisor p of n,
p
n
——1
I P
and
p—l
n
——1
I 11
Proof. Let p be a prime divisor of 77.. Let us see when p divides 1 + S, where
S = 1"“1 +2”—1 +
+ (n— 1)"_1. Write n = kp for a positive integer k. Then
each nonzero remainder modulo p appears exactly 16 times among 1, 2, ..., n— 1,
hence
1 + s E 1 + k(1"—1 + 2"—1 +
By corollary 5.77 the number 1"“1 + 2’“1 +
+ (p — 1)“).
+ (p — 1)"_1 is congruent to
0 modulo p if p — 1 does not divide it — 1, and it is congruent to —1 modulo
p otherwise. We conclude that p l 1 + S if and only if p — 1 divides n — 1
(equivalenttop—llg—l) andp|k—1=%—1.
This already proves one implication: if n divides 1 + S, then p — 1 | n — 1
and p | % — 1 for all p | n. Conversely, suppose that these conditions are
5. 3.
Lagmnge’s theorem and applications
271
satisfied. Since p I g —— 1 for all p | n, it follows that n is squarefree. Hence n
divides 1 + S’ if and only if p | 1 + S for any p | n. By the first paragraph, this
is true, which concludes the proof.
[I
Remark 5.84. Giuga’s conjecture is that the only numbers satisfying the previous divisibility are the prime numbers. Note that the condition p — 1 | 3 — 1 is
equivalent to p— 1 | n — 1, in other words any number satisfying the divisibility
is a Carmichael number. Let us call n > 1 a Giuga number if n is composite
and p | g — 1 for all prime divisors p of n (which implies that n is squarefree).
We can rephrase Giuga’s conjecture as saying that no Giuga number is also a
Carmichael number. The first Giuga numbers are
30,858:2-3-11-13,1722=2-3-7-41,...
and there are also monster Giuga numbers such as
2 - 3 - 11 ‘ 23 ~ 31 - 47059 - 2259696349 ' 110725121051.
It is not known if there are infinitely many Giuga numbers. An excellent
exercise for the reader is to check the equivalence of the following statements:
a) n is a Giuga number;
b) 1‘1“”) + 2900‘) + + (n — 1)‘P("‘) _=_ —1 (mod n);
c) Zpln 5} — ln 5} is a positive integer.
A beautiful exposition of these results (and many others) can be found in
the article “Giuga’s conjecture on primality', by D. Borwein, J. M. Borwein,
P. B. Borwein and R. Girgensohn, published in the American Mathematical
Monthly, vol. 103, No 1, 1996.
We give now a more conceptual proof of example 5.44, based on corollary
5.77.
Example 5.85. (Lerch’s congruence) Prove that for all odd primes p we have
1"—1 + 2"—1 +
+ (p — 1)”‘1 E p+ (p — 1)!
(mod p2).
Proof. Let us write
p—l
f(X) = H(X - z') = X19_1 + ap_2X1"‘2 +
1:1
+ a1X + a0
272
Chapter 5. Congruences involving prime numbers
for some integers a0, ..., ap_2. Since by theorem 5.71
p—l
H(X — i) E XH — 1 (mod 1)).
i=1
we have p | a1, ...,ap_2 and a0 = (p — 1)!. Next observe that
17—].
p—l
17—2
i=1
i=1
j=0
.
.
0 = Zfa) = Zip-1 + Sag-(11 +21 +
.
+ (p— 1)!).
Since lj +2j + + (p— 1)j E 0 (mod p) for 1 S j S p—2 (by corollary 5.77),
all terms aj(1j + 21 + + (p — 1)’) with 1 g j g p — 2 are multiples of p2. It
follows that
1”—1 + 2p_1 +
+ (p — 1)?"1 E —(p — 1)(p — 1)!
(mod p2).
It sufl‘ices therefore to prove that
-(P— 1)(P - 1)! EP+ (P — 1)! (mod p2),
which reduces to (p — 1)! E —1 (mod p), i.e. Wilson’s theorem.
5.3.3
III
The Chevalley-Warning theorem
We will prove now a stunningly beautiful result about the number of solutions of some systems of polynomial congruences, known as the ChevalleyWarning theorem. This will require the next result, which is a simple but
rather powerful multi—variable version of corollary 5.77.
Corollary 5.86. Let F e Z[X1,...,Xn] be a polynomial with integer coefficients in the variables X1,...,Xn and let p be a prime such that degF <
n(p — 1). Then
2
($1,...,mn)€{0,1,...,p—1}"
F(x1, ...,xn) E 0
(mod p).
5. 3.
Lagrange ’s theorem and applications
273
Proof. The polynomial F is a linear combination with integer coeflicients of
monomials of the form X?...Xf{‘ with i1 +
+ in < n(p — 1), since degF <
n(p — 1) by assumption. Thus it suffices to prove the result for each such
monomial, i.e. that
E
2:11.. x‘" —
:0
(mod p)
($1,...,$n)€{0,1,...,p—1}n
whenever i1, ..., in are nonnegative integers with i1 +
+ in < n(p — 1). Since
—(2)(z)
:
p—l
w1=0
(9:1,...,a:n)e{0,1,...,p—1}"x
wn=0
it is enough to prove that p l 2:4, 2:” for some 3' 6 {1,2, ...,,n} But since
i1 +.. .+ in < n(p — 1), there 18 some 3' for which ij < p — 1 and for this 3' we
have p | 2.5-0 3:” by corollary 5.77.
CI
We are now ready to prove the following result, which was conjectured by
Artin.
Theorem 5.87. (Chevalley- Warning) Let p be a prime and let k and n be
positive integers. Let h, ..., fk be polynomials with integer coefi‘icients in the
variables X1, ...,Xn, such that
k
n > Zdegfi.
i=1
Then the number of n-tuples (m1, ...,wn) E {0,1,...,p — 1}” such that
f1(.’1:1,...,.’1:n)E f2(a:1, ...,xn) E
E fk(a:1, ...,xn) E 0
(mod p)
is a multiple of p.
Proof. The following proof is rather magical. Consider the polynomial
= (1 - f1_1)(1 - §_1)---(1 - if.“
274
Chapter 5. Congruences involving prime numbers
and note that by assumption degF < (p — 1)n. The key observation is that
for any a: = (1:1,...,a:.,,) E {0,1,...,p — 1}” the simultaneous congruences
f1(:c) E f2(:1:) E
E fk(:1:) E 0
(mod p)
are equivalent to the single congruence F(:z:) E 1 (mod p). Indeed, by Fer-
mat’s little theorem f,(a;)p‘1 E 1 (mod p) unless fi(x) E 0 (mod p), thus
F(:z:) E 0 (mod p) unless f,(a:) E 0 (mod p) for all 1 S i S k.
Now, let N be the number of n—tuples (x1, ...,:L'n) E {0, 1, ..., p — 1}" such
that F(:1:1, ...,mn) E 1 (mod p). Then clearly
Z
F(a:1, ...,:rn) E N
(mod p),
($1,...,mn)6{0,1,...,p—1}"
thus it suffices to prove that the left-hand side is a multiple of p. But this is
the content of corollary 5.86.
III
A very useful (yet straightforward) consequence of the Chevalley—Warning
theorem is the following result, which guarantees the existence of nontrivial
solutions to systems of polynomial congruences, as long as these systems have
enough unknowns and a trivial solution.
Corollary 5.88. Under the assumptions of the Chevalley- Warning theorem,
if f,(0, . . . ,0) = O for all i then the system
f1(a:1, ...,xn) E f2(a:1, ...,wn) E
E fk(.’121,...,:l:n)_=. 0
(mod p)
has a solution (221, ...,xn) with at least one cc..- not divisible by p.
Proof. The Chevalley—Warning theorem says that the number of solutions of
the system is divisible by p. The assumption that fi(0, . . . ,0) = 0 ensures
that (0,0, ...,0) is a solution of the system. It follows that the system has a
solution different from this one, which finishes the proof.
I]
Example 5.89. Let p be a prime and let a, b, c be integers. Prove that there
are integers x, y, 2, not all divisible by p, such that p I as? + by2 + cz2.
Proof. This is an immediate consequence of corollary 5.88.
D
5. 3. Lagmnge’s theorem and applications
275
We have already proved the result below in example 4.39, but the proof
given there was not very natural. We give now a very conceptual proof based
on the Chevalley—Warning theorem (more precisely on corollary 5.88).
Example 5.90. (Erdos-Ginzburg-Ziv) Let p be a prime. Prove that among any
2p — 1 integers there are p Whose sum is a multiple of p.
Proof. Applying corollary 5.88 to
2p—1
2p—1
f1(X) = Z ai‘l, f2(X) = Z Xf'l
yields the existence of (:31, . . . ,x2p_1) E {0, 1, ...,p — 1}21"1 such that not all
:ci’s are multiples of p and
f1($1,-~-,$2p—1)E f2($1,m,$2p—1)E 0 (mOd P)Choosing I = {5| 3:, 7E 0 (mod p)}, Fermat’s little theorem yields
211,5 0 (mod p),
ieI
21 .=_ 0 (mod p).
ieI
The second congruence and the inequalities 1 S |I| 3 2p — 1 yield |I| = p.
Thus (awe; satisfy all requirements.
|I|
Remark 5.91. The result still holds without the assumption that p is a prime,
but the case of primes is the most difficult. See the reduction to the case of a
prime given in the proof of example 4.39.
Emample 5.92. (Zimmerman) a) Let p be a prime and let a1, ..., a2p_1 be integers. If I is a subset of {1, ..., 2p — 1} with p elements, let S; = 2,61 ai. Prove
that
2.5134 E 0 (mod p),
I
the sum being taken over all subsets I with p elements of {1,2, ...,2p — 1}.
b) Deduce a new proof of the Erdos-Ginzburg-Ziv theorem.
276
Chapter 5. Congruences involving prime numbers
Proof. a) Let .S’ be the left-hand side. Brutally expanding each Sfl, we see
that we can write
S =
Z:
I: _
Ck1’_u’k2p_1alf1”-0122111
k1 ,---,k2p—1 20
k1+...+kzp_1=p—l
for some integers ck1,...,k2p_1. Let us fix a monomial alfl...a’2“;"_‘11 and analyze
which subsets I contribute to this monomial. Note that at most p — 1 of the
let’s are positive, say precisely j of them are positive. Now I contributes to
this monomial if and only if it contains all the positive ki, and all such I have
the same contribution. There are (21:17].) sets I With 10 elements, containing
the positive ki’s. Note that this last binomial coefficient is a multiple of p (for
instance by Lucas’ theorem). It follows that the coefficient of each all"1 ...agz’fll
is a multiple of p, and the result follows.
b) Let a1, ..., a2p_1 be integers and use the notations of the previous exercise. We need to prove that some 5'; is a multiple of 1). Assuming that this is
not the case, it follows from Fermat’s little theorem and the previous exercise
that
(21,1:1) E 0
(mod p).
This is absurd, since (27:1) | (p + 1)(p + 2)...(p +p — 1) and so it is not a
multiple of p.
D
We end this section with a more challenging application of the Chevalley—
Warning theorem.
Example 5.93. (IMO Shortlist 2003) Let p be a prime number and let A be a
set of positive integers such that:
a) the set of prime divisors of the elements of A consists of p — 1 elements
and
b) for any nonempty subset of A, the product of its elements is not a
perfect p—th power.
What is the largest possible number of elements of A?
5.3. Lagmnge’s theorem and applications
277
Proof. It is not difficult to see that A can have (p— 1)2 elements: pick pairwise
distinct primes q1, ..., qp_1 and let the elements of A be
(11,4
1+p
1+P(P-2)
1+1)
1+P(P-2)
)'-'aqp-1)qp—1,-"aqp—1
1 ,'-',q1
-
Clearly A has (p— 1)2 elements and satisfies a). To see that A satisfies b), pick
a nonempty subset B of A and choose a prime factor q,- of [[36B :5. Suppose
that q}+p"’1,..., q§+pxk are all elements of B that are divisible by qj, then the
exponent of qj in the prime factorization of HzeB a: is
'uqJ.(H w) = k+p(a:1 +
+xk)
2:63
and this is clearly not divisible by p since 1 S k S p — 1. Thus HazeB a: is not
a. perfect pth power.
We move now to the difficult part of the problem, namely proving that any
such set A has at most (1) — 1)2 elements. Suppose that a set A satisfying a)
and b) has more than (p — 1)2 elements, and choose k = (p — 1)2 + 1 pairwise
distinct elements x1, ..., am of A. Let q1, ..., qp_1 be the different prime divisors
of Hare/19:. Write for 1 S j S k
xj = 11:” (1325.455111-
for some integers 6M and consider the polynomials
fi(X1, ...,Xk) = Xf_lei1 + Xg_le¢2 +
+ Xirlegk
for 1 giSp—l. Then
p—l
Edema: (p-l)2 < k,
i=1
thus by corollary 5.88 the system
f1(zl, ...,zk) E
E fp_1(zl, ...,zk) E 0
(mod p)
has a nontrivial solution (21, ..., zk) e {0, 1, ..., p — 1}k. Letting
I = {i E {1, ---,k}|zz' aé 0},
278
Chapter 5. Congruences involving prime numbers
Fermat’s little theorem yields
Zeij E 0
(mod p)
jEI
for all 1 S i g p — 1. It follows that HjeI 93,- is a perfect pth power, con—
tradicting the fact that A satisfies b). Thus the answer of the problem is
(12— 1)2.
5.4
III
Quadratic residues and quadratic reciprocity
We now turn to the study of the congruence 9:2 E a (mod p), where p
is a prime and a is an integer. The case p = 2 being clear (in this case
x2 E a: (mod p) for all cc, thus the congruence has exactly one solution, at E a
(mod 12)), we will assume in this whole section that p > 2. We therefore
fix an odd prime p in the sequel.
5.4.1
Quadratic residues and Legendre’s symbol
Let us introduce the following useful terminology.
Definition 5.94. If a is an integer, we say that a is a quadratic residue mod
1) if the congruence m2 E a (mod 1)) has solutions. Otherwise, we say that a is
a quadratic non-residue mod p. We say that a residue class a is a quadratic
residue class if a is a quadratic residue mod p (or equivalently if any integer
in the residue class is a quadratic residue mod p).
Since 502 E y2 (mod p) if and only if :1: E :|:y (mod p), it is clear that the
quadratic residues in {0, 1, ..., p — 1} are precisely those of 02,12,...,(P;—1)2,
and these are pairwise distinct, so there are %1 quadratic residue classes mod
p, and %1 nonzero quadratic residue classes mod p. Since this is extremely
useful in practice, let us glorify this result:
Proposition 5.95. For each odd prime p there are exactly %1 quadratic
residues mod p (and thus 13—1 nonzero quadratic residues mod p), and these
are the residues of02, 12, ..., (L31)?
5.4.
Quadratic residues and quadratic reciprocity
279
Example 5.96. Prove that if a, b, c are integers such that p does not divide abc,
then the congruence arr2 + by2 E 0 (mod p) has at least one solution.
Proof. Let A be the set of remainders mod p of the numbers as:2 when 0 S :1: 3
%1 and similarly let B be the set of remainders mod p of the numbers c — by2
when 0 S y S ’3—1. Then A and B consist each of %1 distinct remainders
mod p (since p does not divide ab and the numbers :32 with 0 S a: S %1 are
pairwise distinct modulo p). Since [Al + |B| > p, we deduce that A n B 75 (ll,
which is exactly the desired statement.
I]
We introduce now a very useful and important arithmetic function, Legendre’s symbol.
Much of this section is devoted to the study of the basic
properties of this function.
Definition 5.97. (Legendre’s symbol) Let a be an integer and let p be an
odd prime. We define (%) = 0 if p | a, (g) = 1 if a is a nonzero quadratic
residue mod p and G)
—1 otherwise.
So we obtain a map
(5) :z —> {—1,0, 1}
called Legendre’s symbol mod p. This map enjoys a certain number of remarkable properties. The first property is its p-periodicity, i.e.
(“in”) = (i)
for all integers a and all k. This is immediate from the definition.
In order to establish the second important property of Legendre’s symbol,
we will need the following analogue of theorem 5.71.
Theorem 5.98. For all odd primes p we have
Pd
X'E—l — 1 a fior 42) (mod p).
i=1
280
Chapter 5. Congruences involving prime numbers
Proof. The proof is very similar to that of theorem 5.71: the difference between
the two sides is a polynomial of degree at most %1 — 1 whose values at
12,22,..., (%1)
2
_
are divisible by p (since (122)113—1 = i9.1 E 1 (mod p) for
1 S i g %1 by Fermat’s little theorem). Lagrange’s theorem combined with
2
the fact that 12, 22, ..., (%1) are pairwise distinct modulo p yield the desired
result.
Note the following alternate and simpler argument: letting f (X) be the
difference between the left-hand side and the right-hand side, we obtain
2:1
f(Xz) = XI“ — 1 — fi(X2 — 2'2) 2 X1!"1 — 1 -pl:[1(X — z') E 0 (mod P),
i=1
i=1
the last congruence being a consequence of theorem 5.71. The result follows
immediately.
D
We are now ready to prove the following beautiful:
Theorem 5.99. (Euler’s criterion) For all a and all odd primes p > 2 we
have
(g) E a?
(mod p).
In particular, if a is not divisible by p, then a is a quadratic residue mod p,
a
i.e. (5)
= 1 if and only ifa%1 E 1 (mod p).
Proof. The result is clear when a is a multiple of p, so assume that this is not
—1
the case. Note that ((1%. )2 E 1 (mod p) by Fermat’s little theorem, therefore
-1
—1
ap2— E :|:1 (mod p). From theorem 5.98 with X = a, we see that apz— E 1
(mod p) if and only if a is a quadratic residue modulo p.
El
A very useful consequence of the previous theorem is the following result,
that we have actually already encountered when discussing Fermat’s little
theorem (see corollary 5.28 for instance).
5.4.
Quadratic residues and quadratic reciprocity
281
Corollary 5.100. For all add primes p we have
<—>=<—>L
so —1 is a quadratic residue mod p if and only if p E 1 (mod 4).
The previous theorem also implies the very important:
Theorem 5.101. For all integers a, b we have
(“-b)p - (9)p (9)p '
Proof. By Euler’s criterion, both sides are congruent to (ab)P§_1 modulo 1), in
particular the difference between the left-hand side and the right-hand side is
a multiple of p. But since this difference is a number between —2 and 2, and
since p > 2, this difference must be 0.
III
Note that the only nontrivial statement in the previous theorem is the
rather surprising fact that if a, b are quadratic non-residues mod p, then their
product ab is a quadratic residue mod p. We illustrate now the previous results
with many examples.
Example 5.102. Let p be an odd prime. Find all functions f : Z —) Z such
that for all integers m, n we have
a) if p divides m — n then f (m) = f (n),
b) f(mn) = f(m)f(n)Proof. Clearly the constant functions 0 and 1 are solutions of the problem,
so suppose from now on that f is not constant. Since f is multiplicative and
nonconstant we have f (1) = 1. Then for all n not divisible by p we have
(by Fermat’s little theorem) 1 = f(1) = f(np_1) = f (”)17—1, thus f(n) = :|:1
for such n. Also, note that f (0) = f (n) f (O) for all it, thus f (0) = 0 and so
f (n) = 0 whenever n is divisible by p. Next, note that if :1: is a quadratic
residue mod p and not divisible by p, then f (51:) = 1 (write :1; E 3/2 (mod p)
with y not divisible by p, then f(m) = f(y2) = f(y)2 = 1). Choose n not
divisible by p such that
1‘p
= —1. If :1: runs over the nonzero quadratic
282
Chapter 5. Congruences involving prime numbers
residues mod p, then m: runs over all quadratic non-residues mod p, and
f (m3) = f (n) f (as) = f (n) Thus f is constant on quadratic non—residues mod
p, and this constant is 1 or —1. We conclude that there are four solutions to
our problem: f E 1, f E O, f (n) = 1 for 71. not divisible by p and f (n) = 0 for
n divisible by p, and finally the Legendre symbol mod p.
III
The next example is fairly interesting: it gives an example of a polynomial
f with integer coefficients which has no rational root and yet which has roots
modulo any prime number, i.e. such that the congruence f (x) E 0 (mod p)
has solutions for any prime p.
Example 5.103. Let p be a prime. Prove that the congruence «:8 E 16 (mod p)
has at least one solution.
Proof. The key observation is the factorization
9:8 — 16 = (m4 — 4)(a:4 + 4) = ($2 — 2)(:1:2 + 2)((a: — 1)2 + 1)((a: + 1)2 + 1).
Thus we have to prove that at least one of the congruences
x2 E 2
(mod p),
:02 E —2
(a: — 1)2 + 1 E 0 (mod p),
(mod p),
(a: + 1)2 E —1
(mod p)
has a solution. This is clear for p = 2, so assume that p > 2. Then we need
to show that at least one of —1, 2, —2 is a quadratic residue mod p. But if —1
and 2 are quadratic non-residues, then their product —2 is a quadratic residue
and we are done.
El
Example 5.104. Prove that if p > 2, then the least (positive) quadratic nonresidue mod p is less than % + fl.
Proof. Let n be the smallest positive quadratic non-residue mod p. Write
p = qn+r with 0 S 7' < n and note that clearly r > 0, so ($) = 1 (by
minimality of 17.). Since 72. — r E (q + 1)n (mod p), we have
<—><—><—>
thus q + 1 is a quadratic non-residue mod p. We deduce that q + 1 Z n, thus
p 2 n(n + 1) + 1, which immediately yields the desired estimate.
El
5.4.
283
Quadratic residues and quadratic reciprocity
Example 5.105. a) Prove that if p > 3, then the sum of the quadratic residues
mod p in {0, 1, ...,p — 1} is a multiple of p.
b) Prove that if p:
— 1 (mod 4), then the sum of quadratic residues mod p
in {0,1.. .,p— 1} IS p—_(p4 1).
Proof. a) This follows immediately from theorem 5.98 or by using the fact
that the quadratic residues mod p in {0, 1, ..., p — 1} are the remainders mod
2
p of 0, 12, ..., (Kg—1) , thus their sum is congruent mod p to
—1
2—1
12+22+.. .+(p-—2—)2 =—%EO
(modp),
the last congruence being clear since p > 3 (thus 24 | p2 — 1).
b) Suppose that p E 1 (mod 4). Then for all k, we have that k is a
quadratic residue mod p if and only if p — k is a quadratic residue mod p
(since —1 is a quadratic residue mod p). Therefore we can create a partition
of the set of quadratic residues mod p in {1,2, ...,p — 1} in classes with two
elements, the sum of the elements in each class being p. Since there are 23—1
quadratic residues between 1 and p — 1, there will be %1 such classes and so
the total sum of quadratic residues is %1 - p = 3%).
El
Example 5.106. Let p be a prime of the form 419 + 3 and let m be the number
of quadratic residues mod p between ’23 and p (excluding p). Prove that
(p_;1)l E (—1)m
mod p.
Proof. Let a = (%1)!. A classical consequence of Wilson’s theorem (see
theorem 5.55 and the remark following it) gives a2 E 1 (mod p), thus a E :tl
(mod p). In particular we have a E (%) (mod p). On the other hand we have
284
Chapter 5. Congruences involving prime numbers
In the above product, we can restrict ourselves to those k; between 1 and
g which are quadratic non-residues (as when k is a quadratic residue the
corresponding factor (5'?) equals 1). Now, note that since p E 3 (mod 4) we
have (f) = —1, thus an integer a is a quadratic residue if and only if p—a is a
quadratic non-residue. We deduce that the number of quadratic non-residues
between 1 and Pg—l is equal to the number of quadratic residues between 123
and p (the map a: I—> p — cc establishing a bijection between the corresponding
sets), and this is m by definition. We conclude that
(E) = 11(5) =<-1>'"’
which finishes the proof.
III
Example 5.107. Let p be a prime number of the form 4k: + 1. Prove that
W1
192-1
glx/TPFT'
Proof. Write p = 4k + 1 and observe that
2k
:[x/fikiz 1=Z
i=1 523-JP
i=1>e
1:23; p
1-
As —2 is not an integer, the inequality j >— is equivalent to j > 1 + [5;2.]
Thus we can also write
2k
7:2
2
21"
2'2
Elf—12F 2(16—
l_l)=2k
-Z[—]
5—1
p
i=1 p
and the problem is reduced to
2’“ [2'2] _ 2k2 - 2k
Z
i=1
1’
3
5.4. Quadratic residues and quadratic reciprocity
285
Since the remainder of i2 when divided by p is i2 — p [g] and since
21—
2_ pk(2k + 1)
7
we only need to prove that the sum of the quadratic residues mod p is pk,
which has already been established in example 5.105.
[I
We end this section with a very beautiful and challenging problem.
Example 5.108. (USA TST 2014) Find all functions f : N —> Z such that
(m —— n) (f (m) — f (71)) is a perfect square for all m, n.
Proof. Clearly any function f of the form f (x) = a2a: +b with a, b integers is a
solution of the problem. We will prove that these are the only solutions. Let
f be a solution of the problem and assume without loss of generality that f
is not constant. Note that since f (n + 1) — f (n) is a perfect square for all n,
the number gcd(f (2) — f(l), f(3) — f(2), ...) is a perfect square, say a2, with
a a positive integer. Since a2 divides f (n + 1)— f (n) for all 72., an immediate
induction it divides f (n) f (1) for all 77.. Also, the function g(x)= M
still has the property that (m— n) (g(m)— g(n)) IS a perfect square for all m, n,
and moreover gcd(g(2) — g(1),g(3) — 9(2), ...) = 1. Thus replacing f with y,
we may assume that a = 1, i.e. that gcd(f(2) — f(1),f(3) — f(2), ...) = 1. We
will prove that f (n + 1) —— f (n) = 1 for all n, which will finish the proof.
Suppose that there is n such that f (71+ 1) — f (n) is a perfect square greater
than 1, and fix a prime factor p of f(n + 1) — f (17.) Let r be the remainder
of f (n) when divided by p and let S be the set of solutions of the congruence
f (x) E r (mod p) (thinking of S as a set of residue classes rather than a set
of integers in the following), thus n, n + 1 E S.
Now let a: be the smallest quadratic non-residue in {2, 3, ..., p — 1}, so that
m — 1 is a quadratic residue mod p. If a, b E S, we claim that (1 — cc)a + mb =
a + .7:(b - a) e S. This is clear if a = b, so assume that a aé b and let
m = a + :1:(b — a). We need to prove that f (m) E f(a) (mod p). Assume that
this is not the case and let 0 = (b—a) (f (m) — f (a)), thus 0 is nonzero mod p. On
the other hand by assumption (m — a)(f (m) — f (a)) and (m — b)(f (m) — f (b))
are perfect squares, thus :50 and (a: — 1)(b— a) (f(m) — f (b)) are perfect squares
286
Chapter 5. Congrnences involving prime numbers
and in particular quadratic residues mod p. Note that (b—a)(f(m) — f(b)) E 0
(mod p) (as f(a) E f (b) E (mod p)), thus we and (a: — 1)c are quadratic
residues mod p, while :1: is a quadratic non-residue and cc — 1 is a quadratic
residue. This is obviously impossible, proving that c E 0 (mod p), as needed.
Now let T = {s — n|s E 8'}, thus 0,1 6 T (since n,n + 1 E S) and, thanks
to the previous paragraph, ma + (1 — x)b e T whenever a, b e T. In particular
:L'T C T and (1 — x)T C T. We deduce that for all a E T we have
(1+1Ex-$p_2a+(1—$)°(l—$)p—2'1ET,
and since 0 e T, it immediately follows that T contains all residue classes and
therefore S contains all residue classes. We deduce that p | f (n) — r for all n,
thus p | f (n + 1) — f(n) for all n, a contradiction with
gcd(f(2) — f(1), f(3) - f0), ...) = 15.4.2
'3
Points on spheres mod p and Gauss sums
Let us come back for a while to our original goal: discuss the congruence
x2 E a (mod p). If a is a multiple of p, the congruence has only one solution
a: E 0 (mod p), so assume that a is not a multiple of p. If a: and y are
solutions of the congruence then x2 E a E 3/2 (mod p), thus p divides $2_y2 =
(a: + y)(a: — y) and so y E :lza: (mod p). It follows that the congruence has
exactly two solutions: if a: is a solution, then all solutions are :1: and —a: (note
that a: and —a: are different modulo p, since p > 2 and a is not divisible by
p). To summarize, the congruence has two solutions when (g) = 1 and zero
solutions when (g) = —1. In other words, we have just obtained the following
result.
Proposition 5.109. If a is an integer and p > 2 is a. prime, then the congru-
ence 3:2 E a (mod p) has exactly 1 + (fi) solutions.
The previous proposition is very useful when computing sums related to
Legendre’s symbol. Let us give one very important example. Consider an
integer a and the congruence 11:2 — y2 E a (mod p) (in two variables ac,y).
If a E 0 (mod p), this is equivalent to (ac — y) (a: + y) E 0 (mod p) and the
5.4.
Quadratic residues and quadratic reciprocity
287
solutions are given by (51:,93) and (as, —x) for a: 6 {0,1, ..., p — 1}. Note that
the solution (0,0) is counted twice, so we obtain 2p — 1 solutions. Consider
now the case a aé 0. Then the congruence is equivalent to (a: — y) (:1: + y) E a
(mod p). The substitution :1: + y = u, a: — y = 'u realizes a bijection between
solutions of this congruence and solutions of the congruence uv E a (mod 12)
(note that we can recover uniquely :13,y from u,v thanks to the fact that p
is odd). On the other hand, if uv E a (mod p), then u and u are nonzero
mod p and for each nonzero u (mod p) there is a unique '0 (mod 1)) such that
uv E a (mod p). Thus the congruence uv E a (mod p) has 12 — 1 solutions.
To summarize, the congruence
x2 — y2 E a
(mod p)
has p — 1 solutions when a is not a multiple of p, and 2p — 1 solutions otherwise. Let us count now the solutions in a different way. Namely, fix y and
consider the congruence m2 E 3/2 + a (mod p). By the previous proposition,
this congruence has 1 + (9%) solutions. Varying y, we deduce that the total
number of solutions is
p—
1
2
y=0
+a
p
Comparing the two expressions for the number of solutions, we deduce the
following result.
Proposition 5.110. For an integer a we have
12—1
2
§:(a+ k )Ep—l
P—1
if p|a
and
(a+
k2
)=—1
otherwise.
The following result is a simple consequence of the previous one, and we
leave the proof to the reader.
Proposition 5.111. Let a, b, c be integers such that 1) does not divide a. Then
E (ak2+bk+c)
p
k=0
=(p—1)<%)
if p|b2—4ac
Chapter 5. Congruences involving prime numbers
288
and
P‘1(ak2
+bk+c>
Z ——
k=0
a
= — (—)
p
,
otherwise.
p
In particular, for any integers a, b which are not congruent mod p we have
E <(k+a)(k+b)> _ _1
[9:0
p
We can use proposition 5.110 to give a very simple proof of the following
beautiful result, which is not very simple to prove directly, since 1:2 + y2 has
no simple factorization, contrary to x2 — y2.
Proposition 5.112. The nulmber of solutions of the 1congruence x2 + :y2 E a
(mod p) is p + (p — 1)(—1)PT ifp | a andp — (—1)'3_ otherwise.
Proof. Fixing y, the congruence x2 E a — y2 (mod p) has exactly 1 + (“—193)
solutions, thus, by varying y, the total number of solutions of the congruence
9:2 + y2 E a (mod p) is
On the other hand
21(7)=§<%>'<yt“)eight“)2
Since the previous proposition gives us the value of 21;}, (3%) and since
(11,!) = (-1)P;—1, the result follows by combining the previous observations.
I]
Before moving on, we give some concrete and quite beautiful applications
of the previous proposition.
Example 5.113. Given an odd prime p, prove that the congruence
932+yz+z2 EO
has exactly p2 solutions.
(modp)
5.4.
Quadratic residues and quadratic reciprocity
289
Proof. Fixing z, the number of solutions of the congruence 51:2 + y2 E —22
(mod p) is given by the previous proposition: this number is p+ (p— 1) (—1) PE—l
—1
when p | z and p — (—1)’3_ otherwise. Since there are p — 1 nonzero possible
2, we obtain that the total number of solutions is
p+(p—1)(_1)%1+(p—1)(p—(—1)%1)=p2.
D
Example 5.114. (Iran 2015) Let p > 5 be a prime. Prove that at least one of
the numbers 1 + p, 1 + 2p,1 + 3p, ..., 1 + (p — 3)p is the sum of squares of two
integers.
Proof. Suppose that the congruence x2 + y2 E 1 (mod p) has a nontrivial
solution (m,y), Le. a solution with any not divisible by p. Since (ix,:|:y)
is also a solution of the congruence, we may assume that 0 < 36,3] S %1.
Therefore
(P — 1)2
1+p2+y2s——sl+(p—3)p.
2
the last inequality being immediate for p 2 5. Therefore the problem is solved
if we prove the existence of such a solution. This is immediate if we prove
that the congruence x2 + y2 E 1 (mod p) has at least 5 solutions (since there
are only 4 trivial solutions). But proposition 5.112 shows that this congruence
has either p+ 1 or p— 1 solutions. Thus, as long as p— 1 2 5, we are done. III
Example 5.115. (Bulgaria TST 2007) Let p be a prime of the form 4k + 3.
Consider all numbers of the form (x2 +y2)2 with a: and y integers not divisible
by p. Find the number of different remainders these numbers give when divided
by p.
Proof. Clearly any such remainder is a quadratic residue mod p. Since p E 3
(mod 4), 0 is not among these remainders (for if p | (a:2 +y2)2 then p | 31:2 +312,
thus p | cc and p | y, a contradiction). Conversely, we will prove that any
nonzero quadratic residue mod p appears among these remainders. It suflices
to prove that for any a not divisible by p one of the congruences x2 + yz :— a
(mod p) and $2 + y2 E —a (mod p) has solutions with x, y not divisible by p.
Since —1 is not a quadratic residue mod p, one of the numbers a and —a is not
a quadratic residue mod p, say it is a. We know that the number of solutions
290
Chapter 5. Congruences involving prime numbers
of the congruence x2 + y2 E a (mod p) is p — (—1)P3—1 = p + 1, by proposition
5.112. For any such solution a: and y are not divisible by p (for if p | x, then
y2 E a (mod p), contradicting the fact that a is not a quadratic residue mod
p). The claim is thus proved. It follows that there are exactly %1 remainders
mod p.
El
Example 5.116. (USA TST 2016) Is there a nonconstant polynomial f with
integer coefficients such that for all n > 2 the numbers f (0), f(1), ..., f(n — 1)
give at most 0.49917. different remainders when divided by 77.?
Proof. We will prove that there is such a polynomial. First of all, note that
it suflices to check that f(0), f(1), ..., f(n — 1) give at most 0.49911. different
remainders when divided by n only for n = 4 and for odd primes 72. Indeed,
assume that this happens and let n > 2 be arbitrary. Assume that n is not a
power of 2 (the argument is similar in the other case) and pick an odd prime
divisor p of n. If f(k) E 7' (mod n) for some 16,7" 6 {0,1,...,n — 1}, then
f (E) E 7" (mod p), where E is the remainder of k when divided by p. We
deduce that F can take at most 0.499p values, which means that r can take at
most 0.499p~ % = 0.49911 values (since for any remainder m mod p there are
exactly % numbers between 0 and n — 1 that are congruent to :1: mod 1)).
We will prove now that
f(X) = 420(X2 — 1)2
is a solution of the problem. This clearly satisfies the desired condition for
n = 4, so it remains to check it when n = p is an odd prime. This is clear for
p < 11, so assume that p 2 11. It suflices to prove that (932 — 1)2 gives at most
0.499p remainders mod p when :1: varies over all residues mod p. Note that
all (m2 — 1)2 are quadratic residues, and if y2 is a quadratic residue, then 3/2
is not of the form (x2 — 1)2 when y + 1 and 1 — y are quadratic non-residues.
Letting N be the number of y E {0, 1, ..., p — 1} such that 1 :l: y are quadratic
non-residues, we deduce that the numbers (:32 — 1)2 give at most %1 — %
different remainders mod p.
We still need to estimate N. Note that
N=lz<1—<fl>>-<1—<fl>>
p—2
4 y=2
p
p
5.4.
Quadratic residues and quadratic reciprocity
291
since for 2 g y g p—2 the number i (1 — (1—;3» - (1 — (1—31)) equals 1 when
1 :l: y are quadratic non—residues and 0 otherwise. A brutal expansion gives
we:(Io-337%)Eating?)y=2
y=2
y=2
Next, we easily check that
13-2
1 —-
2
19—2
1
Z (—9)
E (—H’)
19 = -1- (-)
1? = F2
10
F2
and using proposition 5.110 we obtain
p—2
_ 2
F2
10
_1
12—1
2_
Z (1—3;) = —1 + (—) 2 (fl) = —1 + (—1)”;
p y=0
10
We deduce that
1
2
pfl
p—5
—
—
>—.
N =—
4(1) — 2+2(p>+(1)2)_
4
To conclude it, remains to check that
p+1
p—5
—___._<
_
2
8 __0499p
for p 2 11, which is immediate.
D
We are now able to prove the following beautiful result, which will play a
key role in the next section.
Theorem 5.117. (V. Lebesgue) Let p > 2 be a prime and let n be an odd
integer. The number of solutions of the congruence
x§+
pn-1+((—1)”3—1p)%
+5312: E 1
(mod p)
292
Chapter 5. Congruences involving prime numbers
Proof. If n is any positive integer and a is an integer, let N(a, n) be the
number of solutions of the congruence x? + + 13?, E a (mod p). Writing the
congruence as
1:? +
+ 53:4 E a — (93,2,_1 +93%)
(mod p),
we see that
N(a,n)=
Z
N(a—x3,_1—xi,n—2).
$n—1,$n6{0,1,-.~,P—1}
By proposition 5.112, when xn_1,:cn run over {0,1,..., p —- 1} the numbers
—1
a — $24 — x3, take each value (mod p) different from a exactly p + (—1)'T
times and take the value a (mod p) exactly p + (p — 1)(—1)PJ2r—1 times. We
deduce that
N(a,n)= (P+(-1)2m,-)ZN(bn 2)+(P+(P—1)(—1)L)N(an 2)
baéa
=<p+(—1>%)ZN(bn— 2)+p<—1)2>N<a,n— 2)
b=0
Clearly
b_0 N(b n— 2) counts (n— 2)-tuples of elements of {0,1,.
thus
—1},
p—l
z N(b, n — 2) =
b=0
We conclude that
NO} n)= p‘2(p+(-1)P2_)-+p( 1)?—
2 MW 2)Taking a = 1 in this last relation, an immediate induction on n finishes the
proof of the theorem.
III
We will explain now an alternative (and perhaps more conceptual) way of
proving the previous theorem, which has the advantage of being rather general
and which also involves a certain number of very beautiful ideas. Since the
5.4.
Quadratic residues and quadratic reciprocity
293
discussion to follow is a bit technical, the reader may safely skip this for a first
reading.
Let N be the number of solutions of the congruence
:13? +
+:z:,2l E 1
(mod p)
and let 2 = e¥. The key observation is that for any integer a, we have
1’"1 zka
1a=0
(modp)=_
’
1’ Ic=0
where the left-hand side equals 1 when a E 0 (mod p) and 0 otherwise. To
prove this identity, note that it is trivial when p | a and in the other case the
formula for the sum of a geometric progression gives
p—l
E z
lea,
k=0
=
l—Zpa'
l—z“
=0,
since 2“ aé 1 and z?“ = (z?)“ = 1.
It follows that
p—l
N=z
0331,...,$nSp—1 p 19:0
1
zk(z§+...+z,2,—1),
in other words (by interchanging the sums)
N = EE z—k
Z
zkz2+. .+k23,_
_ _12:1 z—k (:2: 2162211)
1” k=0
0521,...,mnSp—1
1’ k=0
The term for k = 0 is easy to evaluate and equals p”. The other terms lead
naturally to
Definition 5. 118. Let
p—1
p
2:0
3:0
21'"k
10—1
G'(k) = 22’“? = 2e ,, , G=G(1) = 2232
the quadratic Gauss sum associated to k.
m=0
294
Chapter 5. Congruences involving prime numbers
It turns out that all sums G(k) can be easily expressed in terms of G:
Proposition 5.119. If p does not divide k, then
G ( I.) = (_)p G.
k
Proof. If k E u2 (mod p) for some nonzero u, then the remainders of [651:2 =
(use)2 when divided by p are a permutation of the remainders of :1:2 when a:
varies. Thus G(k) = G is clear in this case. If k is not a square mod p, note
that when cc varies the numbers kxz reduced mod p cover 0 and twice each
quadratic non-residue mod p. Thus in this case
G(k) = 1 + 2 2 z”
(:>=—1
and since
G = 1 + 2 Z 2‘”,
c>=l
the relation G(k) = —G is equivalent to
1+
:2
e>=—1
zz+ Z z‘”=0.
e)=1
But this is clear since the left-hand side is just 22:, z“ = 0.
Remark 5.120. The proof also shows that we have
p-l
G = 2 (E) 2“.
z=1
P
The key identity satisfied by G’ is the following.
Theorem 5.121. (Gauss) We have
02 = p(—1)2;_1.
In particular |G| = fl.
D
5.4.
Quadratic residues and quadratic reciprocity
295
Proof. Using the previous proposition, we obtain (brutally expanding G(k)2)
(p—=1)G2
20002: 10211022k(z2+y2)__ Z 22k(w2+y2)
zy=0k=1
k=1a:,y=0
For fixed 9:,y, the sum 2%: zk(“2+y2) equals —1 when p does not divide
19(132 + 3/2) (or equivalently 9:2 + yz) and equals 1) - 1 when p | m2 + y2. If
E 3 (mod 4), the congruence x2 + 3/2 E 0 (mod 1)) has only the trivial
solution (as, y) = (0,0) and so we obtain
(P-1)G2=p-1—(P2-1)=-p(P-1),
thus 02 = —p as desired. If p E 1 (mod 4) the congruence m2 + y2 E 0
(mod p) has 2p — 1 solutions by proposition 5.112, thus we obtain in this case
(p— 1)GZ= (2p— 1)(p— )—(p2—2p+ 1) =p(p— 1)
and finally G2 = p, as needed.
El
Remark 5.122. 1) One can also argue more directly as follows: brutally expand
p—l
=zfir
m,y=0
Proposition 5.112 shows that when :13, y run from 0 to p— 1 the numbers :32 +1;2
.
cover every nonzero res1due
mod p exactly 11 — (—1) 2:1
2 t1mes and cover the
-1
zero residue mod p exactly 1) + (p — 1)(—1)P2— times. We conclude that
G2=p+(p—1)(—1)%+(p— (1)212)(z+z +.. .+zP‘1)
and the result follows from the equality z + 22 + + 219—1 = —1.
2) It follows from the previous theorem that G = :lzfi when p E 1 (mod 4)
and G = iifi when p E 3 (mod 4). Finding the correct sign is a very difficult
problem that took several years for Gauss to solve! More precisely, Gauss
proved that
G=\/fi if pEl
(mod4)
and
G=ifi ifnot.
296
Chapter 5. Congruences involving prime numbers
Let us come back to our counting problem and recall that N is the number
of solutions of the congruence 23% +
+ (5,2; E 1 (mod p), where n is odd. We
have already seen that
p—l
N = pH + p1 k=1
z z-kaac)",
thus using the previous results and the fact that n is odd we obtain
N =pn—1 +1p k=1 (g) G"
13—1
+; (z
(a)
G"
k=1
p
—1
n
—
1—
n—
= :o"‘1 + EGG” = p ‘1 + G"'1 = 23'“ + ((-1)%1p)TlThis gives a different proof of Lebesgue’s theorem 5.117. To fully appreciate
the power of this approach, we suggest the reader to find an explicit formula
for the number of solutions of any congruence of the form
111e +
+ anxi E b
(mod p),
where (11, ..., an are integers not divisible by p and b is an integer. The next
example discusses a special case.
Emmple 5.123. (MOSP) Let p be an odd prime. Find the number of 6-tup1es
(a, b, c, d, e, f) of integers between 0 and p — 1 such that
(12+b2+c2 Ed2+62+f2 (modp).
Proof. Let z be a primitive root of order p of unity. Arguing as in the previous
discussion, it follows that the desired number of 6—tuples is
—l
1
S=—
E:
p§:zk(a+b+c
2 2 2_ dze
_ 2_ f)
2
p 03a,b,c,d,e,fSp—1 19:0
—1
_ 1 p
Z
p k=0 03a,b,c,d,e,fgp—1
zk(a2+b2+c2—d2—e2—f2)
5.4.
Quadratic residues and quadratic reciprocity
1 p—l
= _
zka2
Z
p k=0 ogagp—l
Z
z—kd2
3
030K —1
1 13—1
__
1 17—1
3.
297
= p5 + 5 Z G(k)3 ' 0003 = P5 + 13 Z IGUOI6 = P5 + (P — 1)P2,
since |G(k)| = | (g) GI = |G| = V13 for k not divisible by p. Hence the result
is p5+(p— 1)p2.
5.4.3
I]
The quadratic reciprocity law
We are now ready to give a simple proof of one of the cornerstones of
number theory, the celebrated quadratic reciprocity law. This theorem (conjectured by Euler), one of the most beautiful in number theory, has hundreds of
different proofs. It is certainly the most important result concerning quadratic
residues.
Theorem 5.124. (Gauss’ quadratic reciprocity law) For all add primes p 75 q
we have
1)
q
E 9-;
(5)'(5)="1’ ’ ' 2'
Proof. Let N be the number of solutions of the congruence :3? +
+ :33 E 1
(mod p). By Lebesgue’s theorem 5.117
-1
-1
—1
—1
—1
N =pq-1+<(—1)%p)32- =pq-1+(—1)%‘32-p’2E 1 + (—1)P;—1'g;_Jl - (5)
(mod q).
If we could prove that N E 1 + (g) (mod q), then we would deduce that
(2) E (—1)%1'q;_1 - (5)
(mod q).
P
But then the difference between the two sides is a number between —2 and
2, which is also divisible by q > 2, therefore it must be 0 and the quadratic
reciprocity law follows.
298
Chapter 5. Congruences involving prime numbers
We will prove now that
_
q
finishing the proof. The argument is purely combinatorial and very simple.
Note that if (11:1, ..., :cq) is a solution of the congruence afi—I—u. +133 E 1 (mod p),
then so are ($2, ..., 3:4, x1), (x3, ...,:tq, .731, 1132),... and so we can create groups of
q solutions of this equation, obtained by permuting cyclically x1, ..., mg. Note
that since q is a prime, the only possibility for two solutions in a group to be
equal is to have 331 =
= mg. Thus if M is the number of solutions of the
congruence which moreover satisfy :31 = = xq, then N E M (mod q). It is
fairly easy to determine M: this is the number of solutions of the congruence
qx'f E 1 (mod p), or equivalently (qx1)2 E q (mod p). Hence M = 1 + (g)
and so N E 1 + (g) (mod q), as desired.
III
We end the theoretical part of this section with a beautiful proof of the
following key result.
Theorem 5.125. For all odd primes p we have
<:>=<->L
In particular, 2 is a quadratic residue mod p if and only if % is even, which
happens if and only if p E 1 (mod 8) or p E —1 (mod 8).
Proof. Note that % is even if and only if p E :|:1 (mod 8), thus it suffices
to prove the second statement. The identity
(1%)!=2-4-6-...-1-3-5-...
combined with the congruences
2j+lE—(p—(2j+1))=—2-(p—;1-—j)
(modp)
5.4.
Quadratic residues and quadratic reciprocity
299
give
(1%)! E 2.4 - 6 . . (—2) (1%) - (—2) (I? — 1) .... (mod p).
Consider now the case p = 8k: + 1 for some k, then the previous congruence
becomes
(4k)! = (1%)! s 2.4.... - (4k) . (—2) . (4k) . (—2) . (4k—1)-... . (—2) - (2k+1)
= 22k(2k)!(—2)2k(2k + 1)...(4k) = 24’9 - (4k)! (mod p),
which yields 223—1 E 1 (mod p) and so (%) = 1 by Euler’s criterion. Similarly,
if p = 8k: + 3 the congruence becomes
(4k + 1)! = 2 - 4.
. (4k) . (—2) - (4k + 1) . (—2) . (4k) .
. (—2)(2k + 1)
= 22’c - (2k)! - (—2)2’°+1 - (2k + 1)...(4k + 1) = —24’°+1 - (4k + 1)! (mod p),
yielding 2’3—1 = 24k+1 a —1 (mod p).
We deal similarly with the cases p = 81:: + 5 and p = 8k: + 7.
El
Example 5.126. (Vietnam TST 2004) Prove that 2” + 1 does not have prime
divisors of the form 8k — 1 for any n 2 1.
Pmof. Suppose that p 5 —1 (mod 8) and p | 2"" + 1 for some n 2 1. Since
p E 3 (mod 4), n is odd (since otherwise 2" + 1 is of the form 3:2 + 1). Then
2" E —1 (mod p) yields 2"”‘1 E —2 (mod p) and so (_?2) = 1. This is
impossible, since (_?1) = —1 and G) = 1. The result follows.
III
Example 5.127. (Romania TST 2005) Let p E 7 (mod 8) be a prime. Prove
that for all n 2 1 we have
§{E_1}_z;1
k=1
p
2
2
where {1:} = a: — [c is the fractional part of the real number x.
300
Chapter 5. Congrnences involving prime numbers
Proof. Observe first that for any real number :1: we have
{x—%}=%+{2x}—{x}
since [11: — 3' = [293] — [x] — 1 (as the reader can easily check). Thus the
problem is reduced to the identity
Eve—Em
k=1
1’
k=1
1’
Recalling that p{%} is the remainder of a: when divided by p (when a: is
an integer), we reduced the problem to a statement about the remainders of
the numbers k2” and 2192". If we prove that there is an integer a: such that
2 E :52" (mod p), then we are done, as then the remainders of 2162” (when It
varies from 1 to p — 1) are a permutation of the remainders of the numbers
k2" for 1 S k S p—l. Next, note that ifp | k2" —-l2n for some 1 S k,l gp—l,
then 10 | k2 — 12 since p | kscd-D — lg°d(2”’P-1> = k2 — 12. It follows that
the remainders of the numbers k2" (when k varies) are a permutation of the
quadratic residues mod p. Thus it suffices to prove that 2 is a quadratic residue
mod p, which follows from p E —1 (mod 8).
III
Example 5.128. (Romanian Masters in Mathematics 2013) If a is a positive
integer, define x1 = a and xn+1 = 2.1:” + 1. Find the largest positive integer k
for which there is a positive integer a such that the numbers 2””1 — 1, 2””2 — 1, ...,
2’"c — 1 are all primes.
Proof. Note that k 2 2 since for a = 2 the numbers 2""1 —1 = 3 and 2””2 -1 = 31
are both primes. We will prove now that k S 2, by showing that for any
a 2 1 at least one of the numbers 2’51 — 1, 2""2 — 1, 2’3 — 1 is composite.
Assume that these three numbers are all primes. It follows that .731 = a,
$2 = 2a + 1, x3 = 4a + 3 are also prime numbers. The case a = 2 is easy
to settle (as then 2""3 — 1 = 211 — 1 = 23 - 89), so assume that a is an odd
prime. Then 4a + 3 E —1 (mod 8), thus 2 is a quadratic residue mod 4a + 3
and so 4a + 3 | 240 23—1 — 1 = 2“”2 — 1. Since 2'152 — 1 is a prime, it follows that
5.4.
Quadratic residues and quadratic reciprocity
301
22‘”1 — 1 = 4a + 3. This can be rewritten as 22“_1 = a + 1, and is clearly
impossible since 22“_1 2 1 + 2a — 1 = 2a > a + 1. Thus the result of the
problem is 2.
El
Example 5.129. Find all primes p such that p! + p is a perfect square.
Proof. Clearly 2 and 3 are solutions of the problem. We will prove that these
are the only solutions. Clearly p = 5 is not a solution, so let p > 5 be such
that p! + p = :02. Clearly a: is odd, so 032 E 1 (mod 8) and then (as p 2 5)
p E 1 (mod 8). If q is an odd prime smaller than p, then q | p! and so
<2>=<2:—“>=1~
Using the quadratic reciprocity law, we deduce that
=(—1)%"13-‘ = 1,
(2)
P
the last equality being a consequence of the congruence p E 1 (mod 4). Thus
all odd primes less than p are quadratic residues mod p. Since p E 1 (mod 8),
2 is also a quadratic residue mod p.
We conclude that all numbers are quadratic residues mod p, which is absurd.
Thus no p > 3 is a solution of the problem.
I]
Example 5.130. Find all integers x,n such that x3 + 2x + 1 = 2".
Proof. Clearly n 2 0. If n = O we obtain a: = 0, which gives us the solution
(2:,n) = (0,0). Clearly n = 1 gives no solution and n = 2 gives the solution
(amt) = (1,2). Assume now that n 2 3, thus 8 | x3 + 2:1: + 1. Clearly
a is odd, thus 3:3 E a: (mod 8) and then :1: E 5 (mod 8). Next, note that
2" — 1 = :1:(a:2 + 2) is divisible by 3, thus n must be even. Finally, write the
equation as
(m+1)(a:2—:1:+3)=2”+2,
which shows that for any prime divisor p of x2 — :1: + 3 we have (_T2) = 1
and then p E 1, 3 (mod 8). We deduce that x2 — a: + 3 E 1, 3 (mod 8), which
contradicts the fact that m2 — a: + 3 E 25 — 5 + 3 E —1 (mod 8). Thus the
only solutions are (:13, n) = (0,0), (1,2).
[I
302
Chapter 5. Congruences involving prime numbers
Example 5.131. Prove that if r is an odd number, then there are infinitely
many primes p E r (mod 8).
Proof. Let us start with the case r = 1 and consider prime factors p of n4 + 1,
with p 79 2. Then p I (112)2 + 1, thus p E 1 (mod 4). p E 5 (mod 8), then
Fermat’s little theorem yields
_1 = (.1)"Z—1 E (71,4)1'1—1 = n?—1 E 1
(mod p),
a contradiction. Thus p E 1 (mod 8) for any such prime and the result follows
now from Schur’s theorem 4.67, which guarantees the existence of infinitely
many p that divide a number of the form n4 + 1.
Assume next that r = 3 and let p1 = 2,p2 = 3,
be the sequence of
primes. Consider Nn = (p2p3...pn)2 + 2 with n > 2. Then Nn E 3 (mod 8),
thus Nn must have a prime factor p not of the form 8k :I: 1 (otherwise Nn
would be congruent to :|:1 mod 8). Since p | Nn, —2 is a quadratic residue
mod p, which yields p E 3 (mod 8) (since p is not 1 mod 8). Also p aé 3 (since
Nn E 2 (mod 3)) and p > pn. Varying n yields the desired result.
Similarly, if r = 5 one considers the number N = (p2...pn)2 + 4 E 5
(mod 8) and argues as above, while if r = 7 one considers 2(p1p2...p,,)2 — 1. III
Example 5.132. (AMM E 3012) Let a and b be positive integers such that
a > 1 and a E b (mod 2). Prove that 2“ - 1 is not a divisor of 3“ — 1.
Proof. The result is clear if a is even (as then 3 | 2“ — 1), so assume that a
and b are odd. If p is any prime factor of 2“ — 1, then “ E 1 (mod p) yields
(%) = 1 and 3“ E 1 (mod p) yields (g) = 1. The first relation holds if and
only if p E :l:1 (mod 8). The relation (3 = 1 is equivalent (by the quadratic
reciprocity law) to (—1)%1 . (g) = 1. Discussing two cases according to
whether p E 1 (mod 4) or p E 3 (mod 4), one easily checks that the equality
(—1)P§—1 - (g) = 1 is equivalent to p E :|:1 (mod 12). We deduce that p E :|:1
(mod 24) for any prime factor p of 2“ — 1 and so 2“ — 1 E :|:1 (mod 24). Since
this is obviously impossible, the result follows.
Remark 5.133. In particular 2” — 1 cannot divide 3” — 1 unless n = 1.
E!
5.4.
Quadratic residues and quadratic reciprocity
303
Example 5.134. (Bulgaria 1998) Suppose that m, n are positive integers such
that ("133% is an integer. Prove that this integer is odd.
Proof. Assume that this integer is even, so that 6m divides (m+3)" + 1. First,
observe that m is even (otherwise (m+3)” + 1 is odd). But then 4 divides 6m,
so it divides (m + 3)" + 1, forcing m E 0 (mod 4). Repeating the argument,
we have 8|6m|(m+3)”+1. If 8 divides m, we would have 8|3"+1, which is not
possible for any n. Thus m E 4 (mod 8) and since 8 divides (m + 3)” + 1, it
follows that n is odd. For m = 4 we can easily check the result, so assume that
m > 4. Then there exists a prime p > 2 dividing m (as we proved that m E 4
(mod 8)). Then p divides 3” + 1, thus —3 is a quadratic residue mod p (since
n is odd and 3"+1 E —3 (mod p)). Using the quadratic reciprocity law, this
implies that p is a quadratic residue mod 3 and so p E 1 (mod 3). Since this
happens for any p > 2 dividing m, it follows that we can write m = 4k with
k: E 1 (mod 3) and k: odd. But then m E 1 (mod 3), which makes impossible
the divisibility 3|(m + 3)" + 1. The result follows.
III
Example 5.135. (Komal) Prove that there are infinitely many composite num—
bers of the form 22" + 1 or 62" + 1.
Proof. We will prove that if 22n+1 is a prime p > 5 for some n, then necessarily
6‘13—1 + 1 (which is still of the form 62m + 1) is composite, more precisely a
multiple of p (it is clear that it cannot be p, since it is greater than p). This
is of course suflicient to conclude. Suppose that p = 22" + 1 is a prime > 5
and let us prove that p | 623—1 + 1. This is equivalent to (g) = —1, Le.
(%) . (g) = —1. But since p E 1 (mod 8), we have (%) = 1 and (using the
quadratic reciprocity law) (g) = (—1)?;—1 (g) = —1, since p E 2 (mod 3) and
p E 1 (mod 4). The result follows.
Cl
Example 5.136. (Taiwan 2000) Prove that if m,n are integers greater than 1
such that <p(5m — 1) = 5” — 1, then gcd(m, n) > 1.
Proof. Assume that gcd(m,n) = 1. Then gcd(5”‘ — 1, 5" — 1) = 4. Note that
we cannot find an odd prime p such that p2 divides 5m — 1. Indeed, if this
304
Chapter 5. Congmences involving prime numbers
happened we would get p|<p(5m — 1), so that p|5” — 1 and p|5m — 1. But then
p = 2, a contradiction. Thus we can write
5m — 1 = 2ap1...pk,
5" — 1 = 2a_l(p1 — 1)...(p,c — 1)
for some a 2 2 and some distinct odd primes p1, ..., pk. Note that k 2 1, since
otherwise 5’” — 1 = 2“, 5" — 1 = 2“_1 and so a — 1 = 2, which doesn’t yield any
solution. Thus 2“ divides 5m — 1 and 5" — 1, yielding a S 2 and then a = 2. It
follows that 8 does not divide 5m — 1, forcing m to be odd. Combined with the
fact that p, divides 5m — 1, this implies that 5 is a quadratic residue mod p,- and
using the quadratic reciprocity law we deduce that p, is a quadratic residue
mod 5. But then p,- E :|:1 (mod 5). Since 1),; — 1 divides 5” — 1, we cannot
have p,- E 1 (mod 5), thus all p,- are congruent to —1 modulo 5. But then the
equation 5”— 1 = 2(p1 — 1)...(pk—1) implies that —1 = 2(—2)’° (mod 5), While
the equation 5"“ — 1 = 4p1...pk gives —1 = (—1)""'1 (mod 5). It is immediate
to see that we cannot simultaneously have these two equations, finishing the
solution.
III
5.5
Congruences involving rational numbers and
binomial coefficients
In this relatively technical section we discuss a few more delicate congruences related to binomial coefiicients. The reader is invited to skip this section
for a first reading and to consult the following beautiful articles for further information: A. Granville, 'Binomial coefficients modulo prime powers'I and R.
Mestrovic, "Lucas’ theorem: its generalizations, extensions and applications".
5.5.1
Binomial coefficients modulo primes: Lucas’ theorem
In this section we will discuss several results concerning the arithmetic of
the binomial coefficients, more precisely we will try to discuss the remainder
of (2) when divided by a prime p, and use this to establish several rather remarkable congruences. The letter p will always denote a prime in this section.
5.5.
Congruences involving rational numbers and binomial coefi‘lcients
305
We have already seen when discussing Fermat’s little theorem how useful
the congruence p | (i) (for 1 S k < p) is. Before dealing with more technical
things, we would like to emphasize the very useful congruence below.
Proposition 5.137. For all primes p and all 0 S k S p — 1 we have
(19; 1) E (—1)k
(mod p).
Proof. This follows directly from
k!(p;1) = (p — k)(p— k + 1)...(p— 1) a (—k)(—k + 1)...(—1)
E (—1)’°Ic!
(mod p)
and the fact that gcd(k!, p) = 1.
III
The next problem establishes the converse of the previous proposition.
Example 5.138. Let n > 1 be an integer. Prove that if
(n; 1) E (—1)k
(mod n)
for all k 6 {0,1,.. . ,n — 1}, then it is a prime.
Proof. Assuming that this is not the case, let p be the smallest prime factor
of n and write n = rp for some r > 1. Then by assumption ("z-)1) E (—1)?
(mod n), thus
(77’ _ 1)(n—1)?)"(n _p) E (_1)p
(mod n)
and so
(n — 1)(n — 2)...(n — p + 1)(r — 1) E (p — 1)!(—1)p
(mod n).
However the left-hand side is congruent to (—1)P_1(p — 1)!(r — 1) mod n and
since p is the smallest prime factor of n we have gcd(n, (p— 1)!) = 1. Thus the
previous congruence is equivalent to (—1)P_1(r — 1) E (—1)? (mod n), that is
r E 0 (mod n). This is clearly absurd and so n is a prime.
El
306
Chapter 5. Congruences involving prime numbers
We will attack now the general problem of understanding the remainder of
(2) when divided by a prime p. The final answer will be relatively complicated,
so let us start with some simple but nontrivial observations. Consider the
Euclidean division
n=pn1 +112, k=pk1+k2
of n, respectively It by p, thus n1, k1 2 0 and 0 S n2, 192 < p are integers. The
binomial coeflicient (Z) is the coefficient of Xk in the polynomial (1 + X)".
Since p | (g) for 1 S k Sp— 1, we have (1 +X)P E 1 +XP (mod p) and so
(1 + X)" = [(1 + X)P]"1 . (1 + mm a (1 + X19)“ . (1 + X)“2 (mod p).
The coefficient of Xk = k1+k2 in (1 + X9)”1 ~ (1 + X)"2 is (2:) ~ (2:) (with
the usual convention that (g) = 0 whenever a < b) since the only way to write
k =pk1 +k2 in the formpu+v with 0 S u 3 n1 and 0 S v S n2 is by setting
it = k1 and v = k2, if possible (i.e. if In S n1 and kg S n2). The previous
polynomial congruence yields therefore the following very useful result below.
Theorem 5.139. If n = pn1+n2 and k = pk1+k2 for some integers n1, k1 2 0
and 0 S n2, k2 < p, then
).
(2) E (2:) ' (11:) (mod 2»
We can consider the previous theorem as a recursive recipe of computing
the remainder of (2) when divided by p. Iterating this result yields the following classical and important theorem of Lucas. Before stating it, we recall1
that for any integer a > 1 one can write any integer n 2 1 uniquely in the
form
n = no + me + me2 +
+ nkak
with no, ..., nk 6 {0,1,..., (1—1} and nk 75 0. This is called the base a expansion
of n (when a = 10 we obtain the usual decimal expansion of positive integers)
and the numbers no, n1, ..., nk are called the digits of n when written in base
a (for instance no is simply the remainder of n when divided by a). We can
now state and prove Lucas’ theorem (we recall that (g) = 0 if a < b).
1The reader not aware of this result is invited to prove it using the Euclidean division.
5.5. Congrvences involving rational numbers and binomial coefficients
307
Theorem 5.140. (Lucas) Let n = no+n1p+...+ndpd be the base p expansion
ofa positive integer n, and let k E {0, 1, ....,n} Write2 k = ko+k1p+ ...+kdpd
for some integers 0 3 k1, ..., kd S p — 1. Then
(2) E (:3) . (2:)
(2:) (mod p).
Proof. Applying the previous theorem several times yields
_ no
n = no ' n1 +n2p+
+ndpd‘1
k
+ kdpd_1
_
n1 ' 77.2 +
’60
k1 + kzp +
+ndp ‘2 =
- (a) (a) (...-..W—2)
= no . n1 .
. nd
(lo) (.1) (a) (“1°“)-
The result follows.
[I
We illustrate now the previous theorem with a few examples.
Example 5.141. Prove that if n is a positive integer and n is a prime, then
(2) ta (......)
Proof. Writing n = no + n1p +
+ ndpd in base p, Lucas’ theorem gives
n=no.n1.n2..nd==2
(Mo) (1) (0) (o) m-tl 0mm
which finishes the proof.
El
Example 5.142. (Fine’s theorem, 1947) Let n be a. positive integer and let
no, ..., nd be the digits of n when written in base p, where p is a prime. Prove
that the number of binomial coefficients not divisible by p in the nth row of
Pascal’s triangle is (1 + n0)(1 + n1)...(1 + nd).
2In other words we consider the base 1) expansion of k and add some leading zeroes if
needed, in order to obtain the same number of digits in base p as n.
308
Chapter 5. Congruences involving prime numbers
Proof. We need to find the number of integers k E {0,1,...,n} for which p
does not divide (2). Write k = 190 + klp +
+ kdpd for some 0 S k,- g p — 1
(uniquely determined by k). Then by Lucas’s theorem
an.)
d
m
thus p does not divide (2) if and only if p does not divide any of the numbers
(2:). Since 0 S 16,-, ni < p, this happens precisely when k,- S n,- for all 0 S i g d.
Thus for each 0 S i S d we have exactly m + 1 possibilities for k,- and since It
is uniquely determined by the d-tuple (kg, 191, ..., kd), the result follows.
III
Remark 5.143. For p = 2 we recover Glaisher’s classical theorem (obtained
in 1899): the number of odd entries in the nth row of Pascal’s triangle is 2’,
where s is the number of 1’s in the binary (i.e. base 2) expansion of n.
Example 5.144. Let p be a prime and let n be an integer greater than 1.
a) Prove that all binomial coeflicients G"), ..., (”21) are divisible by p if and
only if n is a power of p.
b) Prove that none of the binomial coefficients ('1‘), ..., (”’11) is divisible by
p if and only if n = q — 1 for some 0 < q < p and some d 2 0. In particular
(’1’), ..., (nil) are all odd if and only if n + 1 is a power of 2.
Proof. a) Ifn = pd for some d 2 1, then clearly for all k = ko+pk1+...+pdkd 6
{1,2, ...,n — 1} we have by Lucas’s theorem
(Z) E (I?)
(1.3) . (1.1) E 0 (mm).
since kd = 0 and at least one of the numbers k0, ..., kd_1 is positive. Conversely,
suppose that (71‘), ..., n21) are divisible by p, then Fine’s theorem above gives
(1 + no)(1 + n1)...(1 + nd) = 2 where no, ...,nd are the digits of n in base p.
This immediately yields no =
= nd_1 = 0 and nut = 1, thus n = pd and the
result follows.
b) If n = q — 1 for some (1,2 0, 0 < q < p, then the base p expansion of
n is
n:(11—1)Pd+(P—1)Pd_l+---+(P—1),
5.5.
Congmences involving rational numbers and binomial coefi‘icients
309
and the result follows directly from Lucas’ theorem. Conversely, suppose that
none of (71‘), ..., (117-11) is divisible by p and write it = no + pm + +pdnd in
base p. If 71,- < p — 1 for some 3' 6 {1,2, ...,d}, then ((711-471)?) is divisible by
p thanks to Lucas’ theorem, and 1 3 (nj + 1)p7 < n, a contradiction. Thus
no =
= nd_1 = p — 1 and the result follows immediately.
III
Example 5.145. (Iran TST 2012) Find all integers n > 1 such that for all
0 S i, j g n the numbers i+ j and (1‘) + (3") have the same parity.
Proof. The condition is equivalent to the fact that the numbers (:3) — i have
the same parity for 0 g 2‘ S n. By taking 1' = 0, we see that they must be odd,
thus the condition is equivalent to (f) E i + 1 (mod 2) for 0 S i S n. For
OSiSn—l wethenhave
(3:11) = (1:1) + (7:) 52i+3E 1 (mod 2),
thus the numbers ("‘IH), ..., (":1) are all odd. By the previous example we
obtain that n + 2 is a. power of 2, thus 77. = 2k — 2 for some k 2 2. Conversely,
for such 77. Lucas’ theorem easily yields (7:) E i+ 1 (mod 2) for O S 71 S 77.:
writing n = 2’°-1 + 2’9-2 +
+ 2 and i = ik_12’°‘1 +
(1:) (“1.)
+21. gives
(.1) . (0) (mod 2)
and it is a simple matter to check that the last expression has the same parity
asio+1,i.e.asi+1.
El
Example 5.146. Let p be a prime and let 1?. > 1 be an integer. Prove that p
does not divide (2:) if and only if all digits of n when written in base p belong
to {0,1,...,P;—1 .
Proof. Let 2n = a0 + pal +
+ pdad be the base p representation of 2n
and let n = be + pbl +
+ pdbd be the base p representation of n (possibly
completed with some leading zeros). Lucas’ theorem shows that p does not
divide (2:) if and only if a,- 2 b,- for all 0 S 2' S d. We need to prove that this
310
Chapter 5. Congruences involving prime numbers
is equivalent to ma-Xogjgd bj S %1. Clearly this last condition is equivalent
to aj = 2b,- for 0 S j S d, so we obtain one implication. For the other
implication, assume that (13- 2 bj for 0 S j S d and let us prove that aj = 2b,for 0 S j S (1. Suppose that for some j we know that aj 5 2b,- (mod p), then
p > a,- — 2bj 2 -bj > —p and so necessarily aj = 2bj. On the other hand, we
' have
= (a0 — 2110) + (a1 — 2b1)p +
+ (ad -- 2bd)pd.
Thus an E 2b0 (mod p) and the previous discussion gives a0 = 2b0. Next, the
previous relation yields a1 E 2b1 (mod p), thus a1 = 2b1. Continuing like this
yields the desired result.
D
Example 5.147. (Vietnam TST 2010) Prove that (3:) + 1 is not divisible by 3
for any positive integer n.
Proof. Assume that 3 divides (3Z) + 1 for some n > 1. Using the previous
example, we deduce that in the base 3 representation 2n—
— a0 +3a1 +.. +3dad
of 2n we have a, 6 {0,1} for all i, thus the base 3 representation of 4n is
(2%) + (20.1) - 3 + + (2%) -3d. Lucas’ theorem and the hypothesis then give
4n
d
2a'
—1 E (2n) 5 H (0;)
(mod 3).
3:0
Note that (31“?) is congruent to —1 modulo 3 when (11-: 1 and to 1 otherwise.
Thus the number of j 6 {0,1,...,d} for which aj— 1 must be odd. But this 1s
clearly impossible, since 2n—
- a0 + 30,1 +
is even. The result follows.
5.5.2
+ 3dad is even, thus a0 +
+ 0.4
El
Congruences involving rational numbers
By theorem 5.2 for any prime p and any k 6 {1,2, ...,p — 1} the number
fig) is an integer. A natural question is: what is the remainder mod p of
this integer? In order to seriously study this question, we need to extend the
notion of congruences from integers to certain rational numbers. Many of the
more delicate results in the next section will crucially use such congruences.
5.5. C’ongmences involving rational numbers and binomial coeflicients
311
We start by introducing a notion of congruence modulo p for rational
numbers whose denominators are not multiples of p. This allows us to work
with such fractions as with integers, which turns out to be extremely useful
in practice. Let n be an integer greater than 1 and consider the subset of Q
defined by
z(,,,) = {% |a,b e Z,gcd(b,n) = 1}.
So Z(,,) consists of rational numbers whose denominator (when written in
lowest terms) is relatively prime to n. Let us note that if cc, y E Z(,,) then my,
.1:+y and a; — y are also in Z(,,), since ifa: = % and y = 5 then
ac
_ ad + be
_ ad — be
and gcd(bd, n) = 1.
Definition. 5.148. We say that 32,3; 6 Z(n) are congruent modulo n and
write x E y (mod n) if a: — y = nz for some z e Z(,,) or, equivalently, if the
numerator of the fraction as — y when written in lowest form is divisible by n.
The notion of congruence defined above extends the usual congruence on
Z C Z(n) and has the same formal properties (see proposition 2.2), as the
reader can easily check.
We make now the following important remark: if 33,3; 6 Z then x E y
(mod n) in Z(,,) is equivalent to :1: E y (mod n) in Z. Indeed, the only nontrivial statement is that if a: E y (mod n) in Z(,,), then n I a; — y. But by
assumption as - y can be written as % with gcd(a, b) = 1 and gcd(n, b) = 1.
Since a: — y is an integer, it follows that b | na and since gcd(b,na) = 1, we
obtain b | 1 and so a: — y = :l:na E nZ.
Next, we make a very important observation concerning congruences with
rational numbers, which turns out to be very handy in practice (as the next
examples will illustrate). Let a: = % E Z(n). By definition gcd(b, n) = 1 and
so there is a unique c E {1, ...,n — 1} such that be E 1 (mod n). Then a: E ac
(mod n) in Z(,,). Indeed,
x—ac
= a(1 — bc)
b
312
Chapter 5. Congruences involving prime numbers
and the numerator is divisible by n, while the denominator is prime to n.
For instance, let us apply this observation to prove the following congruence
(which will be improved in the next section to a congruence mod p2 if p > 3)
l
1
— E0
+p—1
1 +2+
—
(mo d p)
valid for any prime p > 2. Indeed, let a,- E {1, 2, ...,p— 1} be such that iai E 1
(mod p), then the previous discussion gives
1
1
1+2+..+—12a1+...+ap_1
(modp).
But since a1, ..., ap_1 are pairwise distinct modulo p, they are a permutation
of 1,2, ...,p — 1 and so
—1
a1+a2+...+ap_1El+2+...+(p—1)=I%——)-EO
(modp).
The same argument shows that for any prime p and for any positive integer
k we have
1
1
k
1+2—k+... +—
(p_ 1)" :1+2 +. +(p
1)
k
(modp).
Using corollary 5.77 we obtain the beautiful and extremely useful congruence
below.
Proposition 5.149. For any prime p and any integer k which is not divisible
byp — 1 (in particular ifl S k < p— 1) we have
1 +
1+—
2—,:
+
1
—k=0
(p— 1)
(modp).
Before moving to concrete examples illustrating these relatively dry the-
oretical results, let us solve the original problem that motivated this short
section: finding the remainder of fig) when divided by p.
Proposition 5.150. For all primes p and all integers 1 S k S p — 1
_ k—l
1—1)(:) E £—1k);—
(mod p).
5.5. Congruences involving rational numbers and binomial coeflicients
313
Proof. This follows directly from the identity
1 p _ 1 p— 1
p k — k k—1
and the congruence (£1) E (—1)’°_1 (mod p) (see proposition 5.137 for the
latter).
[I
It is now time to see how the previous results actually work in practice.
Example 5.151. Prove that for all primes p > 3
1
2
1
EEEWEO
(modp).
=j_1j_12 =j_1j12+
and
OE
P‘11
13—1 1
1:122
122101? 12%“?
-_=
+
$4
1
1,341
_—
.—+
I?
1
41-232 Qwflw
Example 5.152. (Putnam 1996) Let p be a prime and let k = lzfj . Prove that
(f) + (12’) + + (Z) a 0 (mod P2)Proof. Equivalently, we need to prove that
£16?) 50
j=1p
J
(modp).
314
Chapter 5. Congruences involving prime numbers
k
k
_ -_
”la-
But using proposition 5.150 we obtain
k
L]
1:1
{i=1
ZE<P)EZQ;—J-—1=Z%—2
j=1p
.7
1:1
k
i521+
.7
J
=
1.7
‘
—. (modp)-
11,—}
One easily checks that p — l—J—
— k + 1 by distinguishing the cases p:
— 1
(mod 6) and p=
_ 5 (mod 6). Using proposition 5.149 we finally obtain
—l
1:
Zl(?)E::%EO
(modp).
i=1
Proof. By proposition 5.150 we have
11—1 z'
12—1 .
i=1 z
i=1
_
i—l
215221.;
1) (p): —2 2 (mow)p
7'
10
On the other hand, let
L1
2
2:1
1
14:2;
2
1
and B=¥2i_1.
1,—1
t—l
Wehave
A
P‘11
hence
—— B: 21—
i=1
(mod p).
III
5.5. Congruences involving rational numbers and binomial coefficients
315
Using again proposition 5.150 we obtain
( 1)“ < O—
1>*2—21’
T (modp)
Z—
III
and the result follows.
Remark 5.154. A consequence of the proof is that for any odd prime p we have
2P-1—1
1
1
—=1+§+...+m (modp).
Example 5.155. (ELMO 2009) Let p > 3‘be a prime and let a: be an integer
such that p | x3 — 1 but p ’f a: — 1. Prove that
x2
2
x3
3
:c——+——...—
as?—1
1 E0
p—
(mod p).
Proof. By proposition 5.150 and the binomial formula we obtain
_
—1
z—?+%3—...—::11‘=':=1%<:>a3k= W+M
(modp),
thus it sufl‘ices to prove that
(1 + :3)? E 1 + .73”
(mod p2).
This follows from example 5.18, since by assumption p | $2 + a: + 1.
Example 5.156. (IMO Shortlist 2011) Let p be an odd integer. If a 6 Z, let
0,2
ap— 1
S=—+2+...+_p 1.
Prove that if m, n are integers such that S3 + S4 — 332 = %, then p I m.
III
316
Chapter 5. Cong’ruences involving prime numbers
Proof. Proposition 5.150 gives
5.:
10—1 k
k=1
“———z(l)k1k()
=--z(_.)k()=— (m),
1”—1
p
(a—l)P—ap+1
p k=1
k
1)
hence
$3+S4—3825 21’ — 31’ + 1 +3? — 41’ + 1 — 3+3 ~21" — 3
P
21’ — 2 2
—Q E 0 (mod p),
P
the last congruence being a consequence of Fermat’s little theorem.
5.5.3
III
Higher congruences: Fleck, Morley, Wolstenholme,...
We will deal now with higher congruences (i.e. modulo powers of p) involving binomial coefficients. This will crucially use the previous two sections.
The following beautiful and classical congruence due to Babbage (1819) is
based on theorem 5.2 and the very important Vandermonde’s identity
(min)=§(T)-(k’ii),
(2)
which follows by identifying the coefficients of Xk in both sides of the equality
(1 + X)m+"= (1 +X)m (1 +X)”
Example 5.157. Prove that for all primes p we have
2
(If) E 2
(mod p2).
Equivalently, (25:11) E 1 (mod 112) if p > 2 is a prime.
5.5.
Congruences involving rational numbers and binomial coefficients
317
Proof. Vandermonde’s identity specializes to
(2?) = i (pl7’
k=0 k
Using theorem 5.2 we obtain p2 | (132 for 1 g k g p — 1, thus (211)”) E 2
(mod p2). The last assertion of the problem follows directly from what we
have already done, since (21012—11): —(2:).
I]
The next classical and important theorem improves the result established
in the previous example and the k: = 1 case of proposition 5.149.
Theorem 5.158. (Wolstenholme, 1862) For all primes p > 3
H —.1
E0
(mod p2)
2
and
< p) E 2
j=1 .7
(mod p3).
p
Proof. Note that
—1—1
17—1
2:1: z
:17
j=11=:=1(.%4-p_1—j)
1
f
j=1](p_J)
and using proposition 5.149 we obtain
:2—1=Z_—1
_1j(p- i) H i2
:0
>
(modp,
whence the first part of the theorem.
For the second part, propositions 5.150 and 5.149 give
.—2<<.>—2>=.;<.<.>>
1
2p
The result follows.
”‘1 1 p
2_p‘11 _
E
318
Chapter 5. Congruences involving prime numbers
Remark 5.159. 1) Wolstenholme’s theorem was generalized by Ljunggren
(1949) to (5%) E (3) (mod p3) and by Jacobsthal (1952) to
pb 5 (2) (mod 10"), q = 3 + ”14‘1““ _ b»
(pa)
for a > b > 0 and p > 3. The proof of this last congruence is very difficult.
2) The congruence (2:) E 2 (mod n) can hold when n is composite and
odd, for instance for n = 29 - 937. Similarly the congruence (2:) E 2 (mod n2)
holds for n = 168432.
3) Primes p for which (2:) E 2 (mod p4) are called Wolstenholme primes.
The only such primes less than 109 are 16843 and 2124679.
No prime p
satisfying (2:) E 2 (mod p5) is known (and probably there is no such prime).
Example 5.160. (APMO 2006) Let p 2 5 be a prime and let 7‘ be the number
of ways of placing p checkers on a p x p checkerboard so that not all checkers
are in the same row (however they may all be in the same column). Prove
that r is divisible by p5.
Proof. The problem is equivalent to the congruence
(p2) —pEO
(modps)
P
or, after dividing by p, to
p-1
p2
H (T — 1) E 1 (mod p4).
k=1
A brutal expansion of the left—hand side shows that
102
1
2 17—1 P2
4
),
p
(mod
r
Z
<—1>P+
<—1>Pa
1)
—
(I
II
Ic=1
k=1
13—1
thus the problem is reduced to proving the congruence
P_1 1
E E0
(mod p2),
lc=1
which follows from theorem 5.158.
El
5.5. Congruences involving rational numbers and binomial coeflicients
319
Remark 5.161. We leave it as a challenge for the reader to establish the con—
<2) (2:)
gruence
3
for all primes p 2 5.
Next, we will try to explain the proof of a beautiful but difiicult congruence
due to Morley. Example 5.153 can be seen as a way of computing the remainder
of 219—1 — 1 modulo p2 in terms of the harmonic numbers
1
1
2
n
Hn=1+—+...+—.
More precisely, the second congruence in that example says that if p > 2 is a
prime, then
2"‘1 .=_ 1 — 3H?
(mod p2).
The next example pushes this further, to a congruence modulo p3. This is an
intermediate (but interesting in its own right) step in the proof of Morley’s
congruence. It is much more challenging than the previous problem.
Example 5.162. Prove that if p is an odd prime, then
10
21"1 E 1 —.§Hp;_1
+ p2
EH33;
(mod p3).
Proof. Recall the identity
(17. + 1)(n+ 2)...(n+n) = 2" - 1 - 3 -
- (2n — 1).
Choosing n = %1 we obtain
2%(p+1)(p+3)...(2p—2)=2?1 '1'3'----(p—2),
that is
I”
—3
21H:(p+1)(p+€‘>)---(p+zo—2)= "’
1-3-...-(p—2)
1 L ,
2j+1 )
,H,(+
320
Chapter 5. Congruences involving prime numbers
Expanding the right-hand side yields
P;_3
p—1_
_
2
1
3
Z _3 (2j+1)(2k+1) (“1°”)
__
—
1+17223'1—214—10
0S1<kS
—E —pZ-2—1j=--HL1 (modps)
12.7"”
|l
ow
P
'P’HEL
Now, by Wolstenholme’s congruence (theorem 5.158)
It is thus sufficient to prove that
1
__1
2
2 gem-41%;: (“1°”)
0S1 <kS
The left-hand side equals
2
2:92
1
g2j+1
2
5+3
1
J.Z=%(2‘7'+1)2
and using the congruences in theorem 5.158 and example 5.151 we see that
this is indeed congruent to %H& modulo p.
U
2
We are now ready to establish the following beautiful result of Morley.
Theorem 5.163. (Marley’s congruence) If p > 3 is a prime, then
(—1)2L1L(p_1) a 41*1 (mod p3).
2
Proof. Let a: = H2;; . A brutal expansion yields
L1
2:1
<—1>%1(P;)=fii;p=1f1(l—§)
5.5. Congruences involving rational numbers and binomial coefl‘icients
321
Pd
El—gyar+p2
Z
2
1
2
1
i=1—pa:+p§ 152—23
(modp3).
i=1 ‘7
igi<j5P;—1
By example 5.151 we obtain
2
_1
_
(—1)1'3T1(pL1 ) E 1 —pa: + 1,351?
2
(mod p3).
On the other hand, by problem 5.162 we obtain
12 =(1— —a:+—
2222
P2 2
41" 1 =(2p‘)
)=1—pa:+§a:
3
(modp)
[I
and the result follows.
We end this section with two challenging examples, which illustrate many
of the ideas and techniques introduced in the previous sections.
Example 5.164. (Fleck’s congruence, 1913) Let p be a prime, j an integer and
n 2 1. Prove that if q = lg] then
2 (— 1)’"(m)5 0 (mod p4).
0<m<n
pIm-J'
Proof. We will prove the result by induction on q. If q = 0, there is nothing to
prove, so assume that q 2 1 and the result is known for q— 1. In particular, the
inductive hypothesis can be applied to N = n — (p — 1), since lfiJ_
— q — 1.
Thus we know that for any integer j we have
=2 (— 1)m(N)EO
“3:55?
(modp‘1_1).
Using Vandermonde’s identity and the congruence (‘0:1) E (—1)" (mod p) (see
proposition 5.137), we can then improve the previous congruences as follows
322
Chapter 5. Congruences involving prime numbers
(for simplicity we no longer write the bounds on the indices, by using the
convention that (Z) = 0 whenever b < 0 or a < b)
E (—1>m(;) = Z (-1)'"(N+7fi‘1)
0311,15;
P4
pIm—j
—1
N
”I
.
—1
.
N
= Emitt- )(m—i)=;<-I>*(’Z ) a—wm-‘(m—i)
pIm-J
1—0
12—1
z-O
_
plm J
12-1
= Z(-1)i(p Z. 1) Sj—i E Z Z (4)1111) (mod 10")i=0
i=0 p|m+i—j
Note that the last sum is equal to Efi=0(—1)m(fi) = 0, hence the inductive
step is proved and we are done.
El
Example 5.165. (Russia 2002) For each positive integer n, write
1 + 21 + + n1 —_ B(n)’
AW
where A(n) and B(n) are relatively prime integers. Prove that A(n) is not a
power of a prime for infinitely many n.
Proof. To simplify notations, write
1
1
Assume that there is N such that A(n) is a power of a prime for all n 2 N.
For each prime p > N + 1 we have f(p — 1) E 0 (mod p2) by Wolstenholme’s
theorem, thus A(p - 1) is a multiple of p2 and must be a power of p, different
from p.
This is the starting point of an induction that will show that A(pk — 1) is
a power of p different from p for all k 2 1. We have just proved this for k = 1,
so assume that it holds for k 2 1 and let us prove it for k + 1. We have
A
k+1 _ 1
-‘B((:&c-I-—1_1; = f(pk+1 _ 1)
5.5. Congruences involving rational numbers and binomial coefl‘icients
p—lpk- 1
p—lpk —1
=2i+22
j=1 P]
323
'r=1 j=0 pj +1.
=+1r<pk—1>+22pj1+,,
P
'r=1 j=0
The term 5f(pk — 1) is 0 mod p by the inductive hypothesis. On the other
hand, for all 1 S 1' S p — 1 we have
p"—1
1
Z pj+r_—:p:1—=O
i=0
(modp).
j=0
We deduce that A(p"+1 — 1) E 0 (mod p) and so A(p’°"'1 — 1) is a power of
12. We still need to prove that A(p"+1 — 1) cannot be p. This will require
the following nice observation: in general, if 23' S n < 23"”, then among the
numbers 1, 2, ..., n there is a unique multiple of 2’. (namely 27' ), thus 2j divides
B(n) and so B(n) > 12’, yielding
A(n) > B(n) > 3.2
Therefore
A
(p
[3+1 __ 1
)>
pk+
—1
2
—1
— p2
which proves that A(p"""1 — 1) is not equal to p and finishes the induction.
We are now (finally!) almost done. Write A(p’° — 1) = puk and note that
since A(pk -— 1) > #, we must have uk 2 k — 1, in particular the sequence
(uk)k tends to 00. On the other hand
fak—1)=1+2+...+pk
=
k
—
-p
1
p’“ — p + 1
+ —— +...——+
p’“ — 1
1
and the sum in the right—hand side is 0 mod p. We deduce that A(pk — p) is
also a power of 11, say A(pk — p) = 1)”. As above, the sequence (’Uk)k tends to
00. It follows that
m+m+pfi=flphlrflptmzo (modpwn,
324
Chapter 5. Congruences involving prime numbers
where wk = min(uk, '01,) tends to 00. Since
1
1
_
1
1
m+m+pk—-l——(l+§+w+p—l)
k
(modp),
we deduce that for all k:
1
1 + —2 +
1
—
_1
+p
a0
.
(mod pWWW“) ) .
This is certainly impossible, since min(wk, k) tends to 00, while 1 + % +
is nonzero.
5.5.4
+ 11%,
III
Hensel’s lemma
In this section we study the congruence f (w) E 0 (mod p”), where f is
a polynomial with integer coefiicients, p is a prime and n > 1 is an integer.
Thanks to the previous sections, we already have a good understanding of
congruences modulo primes, so it is natural to try to use this information in
order to deal with congruences modulo higher powers of primes.
We argue inductively and assume that we already know how to solve the
congruence f (:13) E 0 (mod p ’1). Let us fix a solution a of this latter congruence3 and try to understand the liftings of a to solutions of the congruence
f (w) E 0 (mod p"), i.e. those solutions y of this last congruence which also
satisfy 3; E a (mod pn‘l). Write y = a + p"_1b for some integer b. Theorem
2.69 yields
f(y) = NH!) ‘11»)2 M) +p ‘1bf’(a) (mod 1220"”)
and since 2(n — 1) 2 n we have f(y) E f(a) +p ‘lbf’(a) (mod p"). Thus
y = a + p ‘1b is a solution of the congruence f(x) E 0 (mod p“) if and only if
IE
+ bf'(a.) E 0 (mod p).
n—l
31f there is no solution then clearly the congruence f(z) E 0 (mod p”) also has no solution.
5.5. Congruences involving rational numbers and binomial coefficients
325
If f’ (a) is not divisible by p then there is a unique solution b of this linear
congruence, hence there is a unique lifting of a to a solution of the congruence
f (z) E 0 (mod p"). Otherwise p | f’ (a) and we have two possibilities: either
p" | f (a), in which case a lifts to p distinct solutions of the congruence f (as) E 0
(mod p") (namely all a + p"_1b with 0 S b S p — 1), or p” does not divide
f (a), in which case a does not lift to any solution of f (93) E 0 (mod p“). We
summarize the previous discussion in the following important statement:
Theorem 5.166. {Hensel’s lemma) Let f be a polynomial with integer coefi‘icients, p a prime and n > 1 an integer. Let a be a solution of the congruence
f (:13) E 0 (mod p”_1). The number of solutions y of the congruence f (x) E 0
(mod p”) satisfying y E a (mod p ‘1) is
o 1 if p does not divide f’ (a).
o 0 if p divides f’ (a) and 1)” does not divide f (a).
o p if p divides f’ (a) and p” divides f(a).
The following consequence of the previous theorem appears quite often in
practice.
Corollary 5.167. Let f be a polynomial with integer coeflicients and let p
be a prime and n > 1 an integer. If a E Z satisfies f(a) E 0 (mod p) and
gcd(p, f’ ((1)) = 1, then the congruence f (x) E 0 (mod p") has a unique solution b such that b E a (mod p).
In other words the solution a of the congruence f(w) E 0 (mod p) lifts
uniquely to a solution of the congruence f (x) E 0'(mod p"), provided that p
does not divide f' (a).
Proof. Applying the previous theorem with n = 2 shows that a lifts uniquely
to a solution an of the congruence f (cc) E 0 (mod p2). Note that f’ (a1) E f’ (a)
(mod p), hence p does not divide 1" (a1). Applying theorem 5.166 again shows
that a1 lifts uniquely to a solution a2 of the congruence f (x) E 0 (mod p3),
and again p does not divide f’ (a2). Repeating this process yields the desired
result.
Example 5.168. Let p be an odd prime and let n be a positive integer.
a) How many solutions does the congruence sup—1 E 1 (mod p") have?
b) Answer the same question for the congruence mp E 1 (mod p").
III
326
Chapter 5. Congruences involving prime numbers
Proof. a) Consider the polynomial f (X) = X?"1 — 1. By Fermat’s little theorem, the congruence f (as) E 0 (mod p) has p—l solutions, namely 1, 2, ..., p—-1.
Moreover f’ (3:) is relatively prime to p for any such :0, thus by Hensel’s lemma
each solution of the congruence f(sc) E 0 (mod p) uniquely lifts to one of
the congruence f (as) E 0 (mod p”). It follows that there are precisely p —— 1
solutions for all n 2 1.
b) Letting f(X) = X1" ’— 1, the congruence f(as) E 0 (mod p) has one
solution x = 1, again by Fermat’s little theorem. This time we have f’ (1) E 0
(mod p), so we cannot conclude easily as in part a). If asp E 1 (mod p”), then
a: = 1 + pg for some integer y, and the binomial formula allows us to rewrite
the congruence in the form
y + (12))y2 +
+pp-2y" E 0
(mod pn’2).
If n = 2, this happens for all y, thus the congruence has p solutions in this
case. Suppose that n > 2 and let g(X) = X + (1'2’)X2 + +pp‘2XP. Since
(’2’ ,..., zip—2 are all multiples of p, the congruence g(z) E 0 (mod p) has only
one solution a: = O and g’(0) = 1 is not divisible by p. Hensel’s lemma implies
that y = 0 is the only solution of the congruence g(y) E 0 (mod pn‘z). Hence
3:? E 1 (mod p”) is equivalent to x E 1 (mod p ‘1), which shows that for all
n 2 2 the congruence as? E 1 (mod p“) has p solutions.
III
Remark 5.169. It would be much easier to deal with part b) using the lifting
the exponent lemma: the congruence mp E 1 (mod p”) is equivalent to 1),,(931’ —
1) 2 n, or (using that a: E 1 (mod p) and the lifting the exponent lemma)
1+vp(a:—1) 2n, that isp _1|a;—1.
Let us see how the previous theoretical results work concretely in practice.
Example 5.170. Let p be a prime, a an integer relatively prime to p and n a
positive integer. Consider the congruence x2 E a (mod p").
a) Prove that if p > 2, then the congruence has exactly 1 + (:7) solutions,
i.e. two solutions when a is a quadratic residue modulo p and no solution
otherwise.
b) Describe in terms of a and n the number of solutions of the congruence
when p = 2.
5.5. Congr'aences involving rational numbers and binomial coefi‘lcients
327
Proof. Let f(X) = X2 — a.
a) It is clear that if the congruence has solutions, then a must be a quadratic
residue modulo 1). Conversely, suppose that a is a quadratic residue modulo 1).
Then the congruence f (ac) E 0 (mod p) has exactly two solutions and these
solutions are relatively prime to p (recall that p does not divide a). Since 10
is odd, it follows that gcd(f’(a:), p) = 1 whenever f (as) E 0 (mod p). Hensel’s
lemma implies that the two solutions of the congruence f (x) E 0 (mod p)
lift uniquely to solutions of the congruence f(:1:) E 0 (mod p”), yielding the
desired result.
b) It is clear that if n = 1 there is one solution, while if n = 2 there are no
solutions unless a E 1 (mod 4), in which case there are two solutions. Assume
now that n 2 3 and note that there is no solution unless a E 1 (mod 8) (since
3:2 E 1 (mod 8) Whenever a: is odd). Thus assume that a E 1 (mod 8) and let
us prove first by induction that for all k 2 3 the congruence m2 E a (mod 2")
has solutions. This is clear for k = 3, so assume that a E :02 (mod 2’”) for
an integer ac. If a. E 31:2 (mod 2H1) then we are done, otherwise a E x2 + 2’“
(mod 2k“) and one easily checks that a E (a: + 2k_1)2 (mod 21““), yielding
again the inductive step. Next, choose :60 such that £3 E a (mod 2"). Then
x2 E a (mod 2”) is equivalent to x2 E :33 (mod 2") or 2" | (a: — mo)(a: + .730).
Since gcd(x — xo,x + $0) = 2, this is also equivalent to 2”‘1 | :1: — $0 or
El
2”—1 | x + x0, yielding four solutions in this case.
Example 5.171. Let p be an odd prime and let x be an integer relatively prime
to p. Prove that sup 92—1
E 1 (mod p2) if and only if there is an integer y
such that y2 E a: (mod 122). How many integers a: e {0,1,...,p2 — 1} have this
property?
Proof. Suppose that xp 1’2 1) E 1 (mod p2), then 1 E mp F2 1 —
:x 2
(mod p),
hence :1: is a quadratic residue modulo p. By example 5.170 there 1s an integer
y such that y2 E a: (mod p2), yielding one direction. Conversely, if such y
— 1
—x'5—:
exists then clearly :1: is a quadratic residue modulo p, hence a: -
(mod p) and so
a3":(1+(a—1))p=1+p(a—1)+...E1
(modp2),
328
Chapter 5. Congruences involving prime numbers
yielding mm; 1) E 1 (mod p2). It follows easily from Hensel’s lemma (or even
more directly from example 5.170) that the congruence 93p p271! E 1 (mod 112)
has 13%;” solutions (each solution modulo 1) lifts to 19 solutions modulo p2).
El
Example 5.172. (ELMO Shortlist 2014) Is there an increasing infinite sequence
of perfect squares a1 < (12 < a3 <
such that for all k 2 1 we have that
13%,, + 1?
Proof. The answer is positive, and it suffices to prove that for each It 2 1
the congruence x2 + 1 E 0 (mod 13’“) has solutions (as then there will be
arbitrarily large values of x with x2 + 1 E 0 (mod 13’“), allowing an inductive
construction of the desired sequence). Letting f (:12) = x2 + 1, the congruence
f(3:) E 0 (mod 13) has a solution :30 = 5 with f’(a:o) = 10 prime to 13, thus
by Hensel’s lemma this solution uniquely lifts to a solution of the congruence
f(:13) E 0 (mod 13’“) for all k. The result follows.
E!
Example 5.173. (IMO 1984) Find two positive integers a, b such that 7 does
not divide ab(a + b) but 77 divides (a + b)7 — a7 — b7.
Proof. A first key point is factoring the expression (a + b)7 — a7 — b7. For this
it suffices to factor the polynomial f (X) = (X + 1)7 — X7 — 1. Note that
f(0) = f(—1)= 0, thus f is a multiple of X(X+ 1). Also, if 23 = 1 and z 7E 1
then z+1 = —z2 and f(z) = —zl4—z7—1 = —z2—z——1 = 0. Thus f is also
a multiple of X2 + X + 1. Using this it is a simple matter to check that
f(X) = 7X(X + 1)(X2 + X + 1)2.
Thus 77 | (a+b)7 —- a7 — b7 if and only if 73 I a2 +ab+b2 (using the fact that 7
does not divide ab(a + b), by hypothesis). To make our life simpler we choose
a = 1, so it suffices to find a positive integer b for which 73 I b2 + b + 1 (for
any such b the number b(b + 1) is automatically not a multiple of 7). Letting
g(X) = X2 + X + 1 we need to study the congruence g(zzt) E 0 (mod 73). We
start by studying the congruence g(as) E 0 (mod 7), which is easily seen to
have two solutions, namely :2 = 2 and a: = 4. Since 9’ (2) = 5 and g’ (4) = 9
are nonzero modulo 7, we know by Hensel’s lemma that each of these will lift
to a unique solution modulo 73, but since we are asked for a and b, we will
5.5. Congmences involving rational numbers and binomial coefiicz'ents
329
need to do the lifting. Let us lift the solution a: = 2 to a solution modulo 72.
We are thus trying to find t such that 9(2 + 7t) E 0 (mod 72), or equivalently
9(2) + 7tg’(2) E 0 (mod 72). This is equivalent to 1 + 5t E 0 (mod 7) and
the unique solution is t = 4, yielding a solution 30 of the congruence g(m) E 0
(mod 72). Finally, we lift this solution to one modulo 73, by looking for s such
that 9(30 + 725) a 0 (mod 73). This is equivalent to g(30) + 72g’(30)s a 0
(mod 73), or 931 + 72 - 613 E 0 (mod 73). This reduces to 19 + 613 E 0
(mod 7), or 5 — 2.5 E 0 (mod 7), with the unique solution 3 = 6. We obtain
therefore the solution 30 + 72 - 6 = 324 of the congruence g(m) E 0 (mod 73).
Hence a solution of the problem is a = 1 and b = 324. Note that if we tried
to lift the solution :1: = 4 of the congruence g(x) E 0 (mod 7), we would have
obtained the solution b = 18 of the congruence g(z) E 0 (mod 72), which is
also a solution of the congruence 9(a) E 0 (mod 73).
El
Example 5.174. (Putnam 2008) Let p be a prime and let f 6 Z[X] be a
polynomial. If f (0), f (1), ..., f (p2 — 1) give distinct remainders when divided
by p2, prove that f (0), f (1), ..., f (p3 — 1) give distinct remainders when divided
by p3.
Proof. Assume that f(z') E f(j) (mod p3) for some 7;, j. Since f(i) E f(j)
(mod p2) and since f is injective mod 112, we deduce that i E j (mod p2), say
j = i + p216. It is enough to prove that k E 0 (mod p). Assume that this is
not the case. We have
N) 2 f0) 2 f(z' + hp?) s N“) + kp2f’(i) (mod :03),
so p divides kf’ (i), hence p divides f’ (1) But then
f(i + hp) a N) + kpf’(i) a 1‘0“) (mod :02),
which, combined with the hypothesis, yields i+ kp E 12 (mod 122), a contradiction. Thus k E 0 (mod p) and 2' E j (mod p3). The result follows.
III
330
5.6
Chapter 5. Congruences involving prime numbers
Problems for practice
Fermat’s little theorem
1. Prove that for all primes p the number
11...122...2...99...9—12...9
p
p
p
is divisible by p.
2. (Baltic Way 2009) Let p be a prime of the form 6k — 1 and let a, b, c be
integers such that p I a + b + c and p | a4 + b4 + c4. Prove that p | a, b, c.
3. (Poland 2010) Let p be an odd prime of the form 3k + 2. Prove that
p—l
[[092 + 19+ 1) E 3
k=1
(mod p).
4. (Iran 2004) Let f be a polynomial with integer coefficients such that for
all positive integers m, ii there is an integer a such that n| f (am). Prove
that 0 or 1 is a root of f.
5. (Cippola, Rotkiewicz) Prove that if n1 > 722 >
> me > 1 are integers
with k > 1 and 2% > m then Fm...F,,k and (2Fn1 — 1)...(2Fnk — 1) are
pseudo-primes, where E, = 22" + 1 is the nth Fermat number.
6. (India TST 2014) Find all polynomials f with integer coefficients such
that f (n) and f(2”) are relatively prime for all positive integers n.
7. (Rotkiewicz) An integer n > 1 is called pseudo-prime if n is composite
and n I 2” — 2. Prove that if p,q are distinct odd primes, then the
following statements are equivalent:
a) pq is a pseudo-prime.
b)p|2q_1—1andq|2p_1—1.
c) (21’ — 1)(2q — 1) is a pseudo-prime.
5.6.
331
Problems for practice
8. (Gazeta Matematica) Find all odd primes p for which 2,24 is a perfect
power.
9. (IMO Shortlist 2012) Define rad(0) = rad(1) = 1 and, for n 2 2 let
rad(n) be the product of the different prime divisors of n. Find all poly-
nomials f (as) with nonnegative integer coefficients such that rad(f(12.))
divides rad(f (nrad(n))) for all nonnegative integers n.
10. (Turkey TST 2013) Find all pairs of positive integers (m, n) such that
2"+(n—<p(n)—1)!=nm+1.
11. (Serbia 2015) Find all nonnegative integers x, y such that
(22015 + 1):!3 + 22015 = 2y + 1.
12. (Italy 2010) If n is a positive integer, let
an = 2n3+1 _ 3n2+1 + 5n+1.
Prove that infinitely many primes divide at least one of the numbers
(11, (12,
13. (China TST 2010) Find all positive integers m, n 2 2, such that
a) m + 1 is a prime number of the form 4k — 1;
b) there is a prime number p and a nonnegative integer a such that
2"—1_1
m_=mn+pa_
m—l
Wilson’s theorem
14. Let p be a prime. Prove that there is a positive integer n such that p is
the smallest prime divisor of n! + 1.
332
Chapter 5. Congruences involving prime numbers
15 Let n > 1 and suppose that there is k E {0, 1, ..., n — 1} such that
k!(n — k — 1)!+(-1)k E 0 (mod n).
Prove that n is a prime.
16. For each positive integer n find the greatest common divisor of n! + 1
and (n + 1)!.
17. Let p be a prime and let al, a2, ..., ap_1 be consecutive integers.
a) What are the possible remainders of a1a2...ap_1 when divided by p?
b) Suppose that p E 3 (mod 4). Prove that 0.1, ..., ap_1 cannot be partitioned into two sets with the same product of their elements.
18. Find two primes p such that (p — 1)! + 1 E 0 (mod p2).
19. Find all sequences a1, a2,
integers m, n
of positive integers such that for all positive
m! + n! | am! + an!.
20. Let p be an odd prime. A subset A of Z is called a complete set of
nonzero residue classes modulo p if A consists of p — 1 integers giving
pairwise distinct and nonzero remainders when divided by p. Prove that
if A = {a1,a2,...,ap_1} and B = {b1,b2,...,bp_1} are complete sets
of nonzero residue classes modulo p, then {a1b1, . . . ,ap_1b -1} is not a
complete set of nonzero residue classes.
21. (Clement’s criterion) Let n be an integer greater than 2. Prove that n
and n + 2 are both primes if and only if
4((n — 1)! + 1) + n E 0
(mod n(n + 2)).
22. Let n > 1 be an integer. Prove that there exists a positive integer k and
8 E {—1, 1} such that 2k: + 1 | n +ekl.
23. (Moldova TST 2007) Prove that for infinitely many prime numbers p
there is a positive integer n such that n does not divide p— 1 and p | n!+1.
5.6. Problems for practice
333
24. Find all polynomials f with integer coefficients such that for all primes
p we have f(p) | (p— 1)! + 1.
25. (adapted from Serbia 2010) Let a, n be positive integers such that a > 1
and a" + (In—1 +
+ a+ 1 divides a”! + (Em—1)! +
+ a1! + 1. Prove that
n = 1 or n = 2.
Lagrange’s theorem and applications
26. Let p be a prime. Prove that the sequence of remainders mod p of the
numbers 1, 22, 33, 44,
is periodic and find its least period.
27. (Don Zagier) Somebody incorrectly remembered Fermat’s little theorem
as saying that the congruence a‘"‘"1 E a (mod 71.) holds for all integers
(1. Describe the set of integers n for which this property is in fact true.
28. Let p be an odd prime. Find the largest degree of a polynomial f with
the following properties:
a) deg f < p.
b) the coefficients of f are integers between 0 and p — 1.
c) If m,n are integers and p does not divide m — n, then p does not
divide f (m) — f (n)
29. (Iran TST 2012) Let p > 2 be an odd, prime. Hi 6 {0, 1, ..,p — 1} and
f = a0 + a1X + + 0,a is a polynomial with integer coefficients, we
say that f is i-remainder if
2
ajaz'
(modp).
J'>0,P-1Ij
Prove that the following statements are equivalent:
a) f, f2, ..., f1"2 are O-remainder and fl"1 is 1-remainder.
b) f (0), f (1), ..., f (p — 1) form a complete residue system modulo p.
30. Find all integers n > 2 for which n | 2" + 3" +
+ (n — 1)".
334
Chapter 5. Congruences involving prime numbers
31. (Alon, Dubiner) Let p be a prime and let an, ..., 0.31,, In, ..., b3p be integers
such that
3?
3p
Zai E Zb; E 0
i=1
i=1
(mod p).
Prove that there is a subset I C {1, 2, ..., 3p} with p elements such that
Zai E Eb; E0 (modp).
ieI
iel
32. Prove that for any n > 1 the number (3)4 + (71%)4 +
of any prime p E (n, fin].
+ (Z)4 is a multiple
33. Let f be a monic polynomial of degree n 2 1, with integer coeflicients.
Suppose that b1 , ..., bn are pairwise distinct integers and that for infinitely
many primes p the simultaneous congruences
f(a:+ b1) E f(:c + b2) E
E f(a: + bn) E 0
(mod p)
have a common solution. Prove that the equations
f(x + bl) =
= f(a: + bn) = 0
have a common integral solution.
34. (Romania TST 2016) Given a prime p, prove that
[t]
Z ”‘1
k=1
is not divisible by q for all but finitely many primes q.
35. (China 2016) Let p be an odd prime and a1, a2, ..., up be integers. Prove
that the following two conditions are equivalent:
a) There is a polynomial P of degree 3 %1 such that P(z') E (11- (mod p)
for all 1 S i S p;
5.6. Problems for practice
335
—1
b)Forany1$dS%
P
Elm-+4 — (102 E 0 (mod p),
where indices are taken modulo p.
36. (USAMO 1999) Let p be an odd prime and let a, b, c, d be integers not
divisible by 1) such that
ra
M
m
rd
— + — + — + — =2
p
P
P
p
for all integers r not divisible by p (where {x} is the fractional part of
x). Prove that at least two of the numbers a+b, a+c, a+ d, b+ c, b+d,
c + d are divisible by p.
Quadratic residues and quadratic reciprocity
37. Let n be a positive integer such that p = 4n + 1 is a prime. Prove that
n" E 1 (mod p).
38. Let p be an odd prime.
Prove that the number of integers n E
{1, 2,. ., p— 2} such that n and n + 1 are both quadratic residues mod p
is i;iEL2—__ 1_
39. (Gazeta Matematica) Prove that for any n 2 1 the number 3” + 2 does
not have prime divisors of the form 24k: + 13.
40. Prove that there are infinitely many primes p E —1 (mod 5).
41. Let p = a2 + b2 be an odd prime, with a, b positive integers and a odd.
Prove that a is a quadratic residue mod p.
42. Let n be a positive integer and let a be a divisor of 3617.4 — 817,2 + 1, such
that 5 does not divide a. Prove that the remainder of a when divided
by 20 is 1 or 9.
336
Chapter 5. Cong'ruences involving prime numbers
43. Are there positive integers x, y, 2 such that 8:1:y = :1: + y + zz?
44. (Komal A 618) Prove that there are no integers as, y such that
x3—x+9=5y2.
45. Let p be an odd prime divisor of n4 — n3 + 2n2 + n + 1, for some n > 1.
Prove that p E 1,4 (mod 15).
46. Przove that infinitely many primes don’t divide any of the numbers
2n +1 - 3n with n 2 1.
47. a) (Gauss) Prove that an odd prime p can be written a2 + 2b2 for some
integers a, b if and only if p E 1,3 (mod 8).
b) (Euler, Lagrange) Prove that a prime p 76 3 can be written a2 + 3b2
if and only if p E 1 (mod 3).
48. (Moldova TST 2005) Let f, g : N —) N be functions with the properties:
i) g is surjective;
ii) 2f(n)2 = n2 + g(n)2 for all positive integers n.
iii) | f (n) — n| S 2004\/7—l for all n E N.
Prove that f has infinitely many fixed points.
49. (Romania TST 2004) Let p be an odd prime and let
f(x) = :31 (-)
XH.
P
1:].
a) Prove that f is divisible by X — 1 but not by (X — 1)2 if and only if
p E 3 (mod 4);
b) Prove that if p E 5 (mod 8) then f is divisible by (X — 1)2 but not
by '(X — 1)3.
5.6.
Problems for practice
337
50. For an odd prime p, let f(p) be the number of solutions of the congruence
y2 E 9:3 - :1: (mod p).
a) Prove that f (p) = p for p E 3 (mod 4).
b) Prove that if p E 1 (mod 4) then
—1
1-121 L
f(p)E(—1)4 (L1)
(map).
4
c) For which primes p do we have f(p) = 1)?
51. Is there'a polynomial f of degree 5 with integer coefficients such that f
has no rational root and the congruence f (x) E 0 (mod p) has solutions
for any prime 1)?
52. Let p be an odd prime and let a be an integer not divisible by p. Let
N (a) be the number of solutions of the congruence y2 E :33 +aa: (mod p)
and let
1
p“
3(a) = E (
k=0
k3 + ak
).
p
1) Prove that N(a) = p + 3(a).
2) Prove that if p E 3 (mod 4) then 5(a) = 0 for all 0,, hence N(a) = p.
We assume from now on that p E 1 (mod 4).
3) Prove that if b is not a multiple of p, then
S’(ab2) = (3) 3(a).
4) Prove that
p—l
2 so»? = 21200 — 1)
a=0
and that if A = .S'(—1) and B = S(a) for any quadratic non-residue a,
then
A2 + 32 = 41).
338
Chapter 5. Congruences involving prime numbers
5) Prove that A E —(p + 1) (mod 8).
6) Deduce the following theorem of Jacobsthal: let p E 1 (mod 4) be
a prime and write p = a2 + b2 with a, b integers, a odd and a, E —P;—1
(mod 4). Then the congruence y2 E 9:3 —x (mod p) has p+2a solutions.
53. (Mathematical Reflections) Find all primes p with the following property: whenever a, b, c are integers and p | azb2 + b2c2 + cza2 + 1, we also
have p | a2b2c2(a.2 + b2 + 02 + a2b2c2).
Congruences involving rational numbers and binomial coefficients
54. Let n be a positive integer and let p 2 2n + 1 be a prime. Prove that
2n
_
4n L}!
n =(—)
n (mod p).
55. (Mathematical Reflections 0 96) Prove that if q 2 p are primes, then
pq
P+q
—
q
— 1.
56. (Hewgill) Let n = no +2n1 + +2dnd be the binary representation of an
integer n > 1 and let S be the subset of {O,1,...,n} consisting of those
k such that (Z) is odd. Prove that
2 2k = FgOFfl...n,
keS
where Fk = 22k + 1 is the kth Fermat number.
57. (Calkin) Let a be a positive integer and let
sonic)“
k=0
5.6.
Problems for practice
339
for n 2 1. Let p be a prime, n an integer greater than 1 and let
n=no+pn1 +...+pdnd
be its base p representation. Prove that
d
can 5 H mm. (mod p).
i=0
58. Let p be a prime and let k be an odd integer such that p — 1 does not
divide k + 1. Prove that
P-ll
_
j—k=0
2
(modp).
j=1
59. (Tuymaada 2012) Let p=4k+3 be a prime and write
02+1
12+1
(p—1)2+1_n
for some relatively prime numbers m, n. Prove that p | 2m — n.
60. (IMO Shortlist 2012) Find all integers m 2 2 such that n | (mf2n) for
any integer n e [%, % .
61. (Putnam 1991) Prove that for all odd primes p we have
2?: (Z) (pl—k) E 2” + 1
(mod p2).
k=0
62. (ELMO Shortlist 2011) Prove that if p is a prime greater than 3 then
L1
i (2)3,“ E 21’ — 1
k=0
(mod p2).
340
Chapter 5. Cong'rnences involving prime numbers
63. (IberoAmerican Olympiad 2005) Let p > 3 be a prime. Prove that
El E0
(mod p3).
i=1 7’?
64. (AMM) Let 0,, = #16?) be the nth Catalan number. Prove that
01+02+...+Cn E 1
(mod 3)
if and only if n + 1 has at least one digit equal to 2 in base 3.
65. Prove that for any prime p > 5 we have
P‘1 1 2 El—p2Z—2
P‘1 1
1+p2—
k=1 k
(modp5).
k=1 k
66. (USA TST 2002) Let p > 5 be a prime number. For any integer x, define
1W): 23—
(pa: + k)2
Prove that fp(a:) E fp(y) (mod p3) for all positive integers x, y.
Chapter 6
p-adic valuations and the
distribution of primes
The goal of this chapter is a rather detailed study of the p-adic valuation
map up : N —> N (Where p is a fixed prime). Recall that if n is an integer
greater than 1, then vp(n) is the exponent of p in the prime factorization of
n. After reviewing the basic properties of the map up, we will use it to obtain
results about the distribution of prime numbers.
6.1
6.1.1
The yoga of p-adic valuations
The local-global principle
Let us fix a prime number p. It will be convenient to extend the map
1),, : N —> N (whose definition was recalled above) to a map '01,, : Z —> NU {00}
by setting vp(n) = vp(|n|) for each n aé O,:l:1, vp(:l:1) = 0 and vp(0) = 00. In
other words, if n is a nonzero integer, then vp(n) is the largest nonnegative
integer k such that pk divides n. In particular vp(n) 2 1 is equivalent to p | n.
We call vp(n) the p-adic valuation of n.
The following theorem summarizes the basic properties of the p—adic valuation map up. It is a direct consequence of the definition of this map and of
the fundamental theorem of arithmetic.
342
Chapter 6. p-adic valuations and the distribution of primes
Theorem 6.1. a) If n is a nonzero integer, then we can write n = p”P(n) -m
with m relatively prime to p.
b) For each n > 1 we have
n = Hpvpcn),
pln
the product being taken over all primes p dividing n, or equivalently1 over all
prime numbers.
c) For all integers a, b we have
vp(ab) = vp(a) + vp(b)
and vp(a + b) 2 min(vp(a), vp(b)).
Proof. Parts a) and b) are clear from the fundamental theorem of arithmetic.
Part c) is obvious if one of a, b is zero, so suppose that ab 75 0. By a)
we can write a = p”P(“)u and b = p”P(b)v with u,v relatively prime to p.
Then uv is relatively prime to p and ab = p”P(a)+”P(b) - (av). Hence vp(ab) =
vp(a) +vp(b). Next, pmin(”P(“)’”P(b) divides both a and b, hence it divides a+ b,
hence vp(a + b) 2 min(vp(a),vp(b)).
D
The following crucial result shows that we can detect divisibility of integers
by working "locally at every prime p'. This is the first local-global principle
in number theory and we will use it a lot to prove divisibilities which would
be rather difficult to prove otherwise.
Theorem 6.2. If a,b are integers then a | b if and only if vp(a) S vp(b) for
all primes p.
Proof. We may assume that a, b are nonzero. If a | b and b = ac then vp(b) =
vp(a) + vp(c) 2 vp(a) for all p. Assume that vp(a) S vp(b) for all p. Replacing
a,b by their absolute values, we may assume that they are positive. Then
b = ac, Where c = 1],, p”P(b)_”P(“), an integer. Hence a | b.
El
Remark 6.3. The previous theorem immediately implies the following result
(which we have already proved using Gauss’ lemma): if a, b are integers and
1Since p"P(") = 1 whenever p does not divide n.
6.1.
The yoga of p-adic valuations
343
n 2 1 satisfies a” | b", then a | b. Indeed, by the previous theorem we have for
all primes p the inequality n'vp(a) S nvp(b). Thus vp(a) S vp(b) for all p and
the result follows by applying again the previous theorem.
We can also characterize nth powers of positive integers in terms of their
p—adic valuations:
Theorem 6.4. Let a and n be positive integers. Then a is the nth power of
an integer if and only if vp(a) E 0 (mod n) for all primes p (less formally, if
and only if all emponents in the prime factorization of a are multiples of n).
Proof. If a = b" is an nth power, then vp(a) = vp(b”) = nvp(b) E 0 (mod n)
for all p. Conversely, if 'up(a) = nbp for all p and some nonnegative integers
bp, then bp = 0 for all but finitely many primes p. If we set b = Hp pbP, then
b“ = Hp pup“) = a and we are done.
El
Remark 6.5. This immediately implies the following result, which has already
been proved using Gauss’ lemma in a slightly tricky way: let a, b be relatively
prime positive integers. If ab is the nth power of an integer, then a and b
are nth powers of some integers. Indeed, suppose that ab = c” for some
integer c. For all primes p we have vp(a) + vp(b) = vp(c") = nvp(c) E 0
(mod n). Moreover, since gcd(a, b) = 1, p cannot divide both a and b, so we
have min(vp(a), vp(b)) = 0. We deduce that vp(a) E op(b) E 0 (mod n) for all
primes p and the result follows from the previous theorem.
Finally, we compute the p—adic valuation of the greatest common divisor
and least common multiple of two numbers (of course, they have obvious
versions for several integers).
Proposition 6.6. For all integers a, b we have
vp(gcd(a, b» = min<vp<a), no)» and vp(1cm(a, b» = max<vp(a).vp(b)).
Proof. If one of the numbers a, b is 0 this is clear, so assume that ab aé 0. Since
pmm(”P(“)’”P(b)) divides both a and b, it divides gcd(a, b), hence
vp<gcd(a, b» 2 min<vp<a),vp(b».
344
Chapter 6. p-adic valuations and the distribution of primes
On the other hand, p”p(g°d(a 1’» divides a, and b, hence vp(gcd(a, b))_
< 22,, (a)aand
vp(gcd(a, b)) < vp(b). The result follows. For lcm, use that lcm(a, b): M
to obtain
'Up(lcm(a, b)) = vp(ab) _ vp(n(a’) b)) = vP(a’) + 1013(1)) _ min(vp(a')a 0P0)»,
from which the result follows readily.
C]
We end this section with a few concrete illustrations of the previous results.
Example 6.7. Prove that if n > 1 is an integer and p is a prime, then
vp(lcm(1,2, ...,n)) = [logp(n)J .
Proof. The previous proposition gives
vp(lcm(1,2, ...,n)) = lrgganpfi).
Let k = [logp(n)J, so that pk S n < pk“. Then clearly no i 6 {1,2, ...,n} is
divisible by p""‘1 and so
{gag vp(i)-— vp(p’°)-—
as desired.
El
Example 6.8. Prove that for all n 2 2 we have
lcm(1,2, ...,n) S 71.1“”),
where 1r(n) is the number of primes not exceeding n.
Proof. If pk S n < pk“, then vp(lcm(1, 2, ..., 17.)) = k by example 6.7, hence
pvp(lcm(1,2,...,n)) S n-
The result follows by taking the product of these inequalities over all primes
not exceeding n.
III
6.1.
The yoga of p-adz'c valuations
345
Example 6.9. Is there an infinite set of positive integers such that the sum of
the elements in any nonempty subset is not a perfect power?
Proof. The answer is positive: consider the numbers an = 27‘3”+1 for n 2 1
and let A = {a1,a2,...}. If 2'1 < £2 <
< 1'], are positive integers, then
:v := ail + ah + + 01,, satisfies o2(x) = i1 and v3(a:) = i1 + 1. Indeed, we
have x = Zily with y = 3‘”1 + 21.2—1'13'524'1 + + 21"“271 3‘"6+1 being odd, hence
v2(:c) = i1 and similarly 223(33) = i1 + 1. Since gcd(o2(x),v3(w)) = 1, 38 cannot
be a perfect power. Thus A has the desired property.
III
Example 6.10. (Saint Petersburg 2006) Let a1, a2, . . . , 0101 be positive integers
such that gcd(a1, a2, . . . ,a101) = 1 and the product of any 51 of these numbers
is divisible by the product of the remaining 50. Prove that men . . . a101 is a
perfect square.
Proof. It suffices to prove that vp(a1...a101) = 2,4211 vp(a,-) is even for all primes
1). Fix a prime p and let x,- = vp(a,:). The hypothesis gcd(a1, ..., (1101) = 1 yields
min(a:1, -.-,93101) = 0. Assuming that :01 2 x2 2
2 $101 (which we can do
without loss of generality), we deduce that $101 = 0. Since a51a52...a101 is a
multiple of a1...a5o, we obtain
$51 + $52 +
+ $100 + 93101 2 $1 + $2 +
+ 0650-
However, 13101 = 0 and 5351 S :51, 9352 3 $2,..., 3:100 S 5650. Thus we must have
11351 = $1, $52 = 3:2,..., 33100 = $50. We deduce that
:61 + 132 +
+ {17101 = 2(l +
+ $50)
is even, as desired.
III
Example 6.11. (Mathematical Reflections 0 136) Let (fn)n21 be the Fibonacci
sequence, i.e. f1 = f2 = 1 and fn+1 = fn + fn_1 for n 2 2. Prove that
125(n) = 115(fn) for all 71..
Proof. Let a: > y be the solutions of the equation t2 — t — 1 = 0, so that
$n_yn
fit.“
«5
346
Chapter 6. p-adic valuations and the distribution of primes
f5n =
y
4'”
I
3'”
H:
I
2‘",
2“:
I
"r
3'":
I
411
Note that if we set
ln = “in + yn,
the nth term of the Lucas sequence, then (using the fact that my = —1)
w4n + xBnyn + x2ny2n + mny3n + y4n = $411 + y4‘n + (_1)n(x2n + y2n) + 1
= (2?" + 2/2"? + (—1)”(w2” + :12”) — 1 =13", + (—1)"lzn — 1.
Thus, setting
xn = (-1)"lzn = (-962)” + (-312)",
we have
f5n = fn ' (33121 +9311, _ 1)-
We will now prove that '05 (x3,+a3n—1) = 1, which will yield v5(f5n) = v5(fn)+1
and then 125(fn) = v5(n) by an immediate induction on '05 (n) (using the fact
that the sequence (fn)n21 is periodic modulo 5, with period 20, and that
f5, f10, f15 are the only multiples of 5 among f1, ..., f19, which can be easily
checked by direct inspection). Note that it is enough to prove that an E 2
(mod 5): if can = 5k + 2 then
x§+xn—1=25k2+20k+4+5k+2—1=25(k2+k)+5
and so clearly 1150163, + 1:", — 1) = 1. We will prove that an E 2 (mod 5) by
strong induction, the cases n = 1 and n = 2 being immediate. Next, note that
—:r2 and —y2 are solutions of the equation
(t+x2)(t+y2)=t2+3t+1=0
since $2312 = 1 and 9:2 + y2 = (a: + y)2 — 2a:y = 3. Thus the sequence ($7,)n21
satisfies $n+2 + 3xn+1 + em = 0 for n 2 1. In particular, if remain“ E 2
(mod 5), then xn+2 E —6 — 2 E 2 (mod 5). This finishes the proof.
6.1.
The yoga of p-adic valuations
347
Here is an alternate solution, suggested by Richard Stong. Let l0 = 2,
I1 = 1, and ln+1 = ln + ln_1 for n 2 1 be the Lucas sequence. Then from
lo+fo\/§=
2
1,
l1+f1\/§=1+\/5=
2
2
<p,
and (p2 = (p + 1, it follows by an easy induction that
ln+fn\/§_ 1+x/5 ”
T_ T
'
Hence by the binomial theorem (and the irrationality of x/g),
2
n—l
_
L(n-1)/ZJ
n
k_
l(n-1)/21 L n — 1
k
f'“ I; (2k+1)5 ‘7” kg 2k+1<2k )5'
Since 5’“ > 2k + 1, it follows that v5(2k + 1) < k, and hence every term in the
sum is a multiple of 5”5(”)+1. Thus we conclude that
v5(fn) = 11.6(2’1'11‘71) = v5(n)6.1.2
D
The strong triangle inequality
We have already established that if a, b are nonzero integers, then
vp(a + b) 2 min(vp(a), v10(6)),
in other words setting Ialp = p‘”P(a) (we call |a|p the p—adic absolute value of
a) we obtain
Ia + blp S maX(lalp, lblp)Note that this is much stronger than the usual triangle inequality
la+ bl S lal + lbl
that holds for complex numbers a, b (with the usual absolute value). This is
why the inequality
«w + b) 2 min<vp(a),vp<b)>
348
Chapter 6'. p-adic valuations and the distribution of primes
is also sometimes called the strong triangle inequality.
The following theorem establishes a key property of the up map, related to
the strong triangle inequality.
Theorem 6.12. If p is a prime and a,b are integers such that up(a) 7A up(b)
then
at» + b) = nun<vp<a),vp<b».
Proof. If up(a) > vp(b), then
a + b = p‘vp(b) (pvp(a)-vp(b)u + u)
and p does not divide p”P(“)‘”P(b)u + 1), since it does not divide 1). Thus
”p01 + b) = ”pa’) = min(vp(a), ”p(b))°
D
We illustrate now these theoretical results with some rather interesting
examples.
Example 6.13. (Czech-Slovak 2002) Let m > 1 be an integer. Prove that m
is a perfect square if and only if for all positive integers n at least one of the
numbers (m + 1)2 — m, (m + 2)2 — m, ..., (m + n)2 — m is a multiple of n.
Proof. If m = d2, then at least one of the numbers m + 1 - d, m + 2 -— d, ...,
m + n — d is a multiple of n, and the result follows. For the converse, pick
a prime factor p of m and let k = up(m). Choose 1 S i S p’6+1 such that
p""‘1 | (m + i)2 — m. If vp(m) aé up((m + i)2) then
k + 1 3 Wm + 2')? — m) = min<vp(m).vp(<m + i)?» s upon) = k,
a contradiction. Hence vp(m) = up((m + i)2) = Zup(m + i) is even and since
this holds for any p | m, m is a perfect square.
El
Remark 6.14. The result still holds if we only assume that the statement of
the problem holds for prime numbers n, but the proof is much more diflicult.
We have already proved in theorem 4.67 that if f is a nonconstant polynomial with integer coefficients, then there are infinitely many primes p dividing
a term of the sequence f (1), f(2),
sult.
The following problem extends this re-
6.1.
The yoga of p-ad’ic valuations
349
Example 6.15. (IMO Shortlist 2009) Let f : N —) N be a nonconstant function
such that a — b divides f (a) —— f (b) for all a,b e N. Prove that there exist
infinitely many primes p such that p divides f (c) for some positive integer c.
Proof. Suppose that the conclusion fails and let p1, ...,pk be all primes ap-
pearing in the prime factorizations of the numbers f(l), f(2),
Take any
positive integer a: and write f (:13) = pinup?“ for some nonnegative numbers
a1, ..., ak. Let as = sp‘f‘1+1...p:k+1 for s 2 1. Since as divides f(a:+a5) — flat)
and since up,(f(x)) < opi(as), it follows that vpi(f(a: + as)) = vpi(f(:r)) for
all 7;. But since all prime factors of f (x + as) are among p1, ..., pk, it follows
that f(cc + as) = f(x), and this holds for all s 2 1. But then a: + as — 1
divides f(ac) — f(1) = f(a: + as) — f(l) for all s 2 1, so f(z) = f(l). Since
:5 was arbitrary, it follows that f is constant, contradicting the hypothesis of
the problem. The result follows.
El
Example 6.16. (Kvant M 2163) Find all positive integers a and b such that :
(i) (a + b2)(b + a2) is a power of 2;
(ii) (a + b3)(b + a3) is a power of 3.
Proof. (i) We will prove that a = b = 1 is the unique solution of the problem.
Assume that (a, b) 7E (1,1) and without loss of generality, that a > 1. Write
a+ b2 = 2m and b+a2 = 2" for some mm. 2 1. Ifa is even, then so is b and
since 112 (a) < m = 112(2’”) we have v2(2m — a) = v2(a), thus
2v2(b) = v2(b2) = 122(2’” — a) = v2(a),
and similarly 202 (a) = v2 (b), contradicting our assumption that 122 (a) > 0.
Hence a is odd. If b > 1, then a similar argument as above yields
’l}2(b + 1) < v2(b2 — 1) = ’l)2(2m — (a + 1)) = 02((1 + 1)
and
v2(a + 1) < ”2(02 — 1) = 112(2" — (5+ 1)) = U2(b+ 1),
a contradiction. Hence b = 1 and a + 1 = 2’”, a2 + 1 = 2”. Since 4 does not
divide a2 + 1 for any integer a, we must have n S 1, contradiction with a > 1.
Hence there are no solutions different from a = b = 1.
350
Chapter 6. p-adic valuations and the distribution of primes
(ii) The solutions are (a, b) = (1,2) and (a, b) = (2, 1). Assume that we
have a solution with a, b > 1 and let a3 + b = 3m and a + b3 = 3”. As above,
if 3 divides a, then
3123(a) = '02 (3m — b) = v3(b)
and similarly 3v3(b) = v3(a), a contradiction with 123(a) > 0. Hence a E 1, —1
(mod 3). Note that if a E —1 (mod 3), then b E 1 (mod 3), thus by symmetry
we may assume that 3 I a — 1 and 3 I b + 1. Now if a > 1 a similar argument
as above yields
'vg(a3 — 1) = 03(3’” — (b+ 1)) = 113(b+ 1)
and
03(b3 + 1) = v3(3” — (a — 1)) = 03(a — 1).
Note that v3(a3 — 1) > v3(a — 1) and v3(b3 + 1) > v3(b + 1), since a2 + a +1
and b2 — b+ 1 are multiples of 3. Then the previous equalities yield 123(b+ 1) >
v3(a — 1) > v3(b + 1), a contradiction.
Hence we may assume that a = 1, so b3+1 = 3" and (b+ 1)(b2—b+ 1) = 3'".
Suppose that b > 2, thus n > 1 and so 9 I b+ 1. Then b2 — b+ 1 E 3 (mod 9)
and since b2 —- b + 1 is a power of 3, we get b2 — b + 1 = 3, a contradiction.
Thus we must have b = 2 and the result follows.
III
The next two problems use a similar idea, which is a pretty subtle argument
based on the pigeonhole principle and the strong triangle inequality.
Example 6.17. (IMO Shortlist 2011) Let d1, d2, ..., d9 be pairwise distinct integers. Prove that if a; is a sufficiently large integer, then (:1:+d1)(:1:+d2)...(:r+d9)
has a prime divisor greater than 20.
Proof. Note that there are only 8 prime numbers less than 20, call them
p1, ...,pg. By adding the same number to all di’s nothing is changed, so we
may assume that d,- > 0 for all i. Now, assume that (a: + d1)...(:1: + d9) has
all prime factors among p1, ...,pg, hence so do all numbers a: + d1, ...,:1; + d9.
Assume that a: 2 (p1...p8)N, with N sufficiently large. Then for each 1 S i S 9
we can find 3',- 6 {1,2, ...,8} such that vpji(a: + di) 2 N. Among the numbers
j1, ..., jg E {1, 2, ..., 8} two must be equal, say without loss of generality j1 = j2.
6.1.
The yoga of p-adz'c valuations
351
Then pg divides both x+d1 and x+d2, hence it divides d2 —d1. Since d2 75 d1,
this forces pI-Y g |d2 —d1 I. Hence if N is chosen such that 2N > maXi-7-éj |d,- —dj I,
then for all a: > (p1...pg)N the number (a: + d1)...(a: + d9) cannot have all of
its prime factors among p1, ..., p3, and the problem is solved.
III
Example 6.18. (Erdos-Turan) Let a1 < am <
be an infinite increasing sequence of positive integers. Prove that for any N we can find 75 96 3' such that
a, + a,- has a prime factor greater than N.
Proof. Fix N and let 171, ...,pk be all primes not exceeding N. Suppose that
for all i 76 3', all prime factors of a,- + 0.1- are among 131, ..., pk. Fix any positive
integer d greater than all the numbers av — an with 1 S u < v S k + 1. Fix
also n > (p1...pk)d and note that for all 1 S i g k we have an+a¢ > (p1...pk)d,
thus there is j, 6 {1,2, ...,k} such that vpji(an + at) > (1. Since jl, ...,i are
all between 1 and k, two of them must be equal, say ju = jv with 1 S u < v S
k + 1. Let p = pju, so that vp(an + 0.“) > d and vp(an + av) > d. It follows
that 12,, (au — av) > d, contradicting the fact that d is greater than (1,, — an. I]
The next examples are more challenging.
Example 6.19. (Tuymaada 2004) Let a,n be positive integers such that
a 2 lcm(1,2, ...,n — 1). Prove that there are pairwise distinct prime num—
bers p1, ...,pn such that p,- | a+z' for 1 S i g n.
Proof. Let b = lcm(1, 2, ..., n — 1), thus a 2 b. Consider the numbers
931;
a+i
=———
gcd(a+'i,b)’
1<'<
J-”
.
We claim that 1:1, ..., can are pairwise relatively prime integers and x,- > 1 for
all 72. Note that this immediately implies the result, by taking 10,- to be an
arbitrary prime divisor of 513,-. To prove the claim, note that x, > 1 is clear,
since the equality a + i = gcd(a + i, b) would force a + 1 g b. Assume now
that a prime p divides both 1;,- and acj, for some 1 S i < j S n. Let k = vp(b).
Then
min(vp(a + i),vp(a +J')) S vp((a +J') - (a + 2'» = 0200' - 2') S v12(1)) = k-
352
Chapter 6. p-adic valuations and the distribution of primes
We may assume that op(a + i) S k, but then
121,017,) = 'vp(a + i) — min('vp(a + i), k) = 0,
contradicting the fact that p | 93,. The result follows.
El
Example 6.20. (Iran TST 2013) Find all arithmetic progressions a1,a2,
of
positive integers for which there is an integer N > 1 such that for all k 2 1
“luau-Gk I aN+1aN+2---aN+kProof. Write an = a + nd for n 2 1 and some d 2 1. Note that if a = 0,
then the sequence (an)n is a solution of the problem, since the product of k
consecutive integers is a multiple of k!. We will prove that the case a > 0 is
impossible. Dividing a and d by their greatest common divisor, we may assume
that gcd(a, d) = 1. For k > N the divisibility condition can be rewritten as
0102--~0'N | ak+1ak+2mak+m
by dividing the given divisibility relation by aN+1...ak. Note that a1a2...aN >
N!, hence there is a prime p such that vp(a1...aN) > vp(N!). Then p divides
at least one of the numbers a1, ..., aN, and these are all relatively prime to d
since gcd(a, d) = 1. Thus p does not divide d and so there is an integer k > N
such that p"?(“1"'“N) | ak = a + dk. But then vp(ak) > 'up(N!) 2 vp(jd) for
1 S j g N, hence
'Up(Nl) < vp(a1...aN) S vp(ak+1...ak+N)
= vp((ak + 000:»:c + 2d)-~(ak + M1»
= '11,,(a;c + d) + 1),,(a;c + 2d) +
= 'up(d) + 'vp(2d) +
a contradiction.
+ '12,,(a1c + Nd)
+ 'vp(Nd) = vp(N!),
III
Example 6.21. (IMO 2010) Find all sequences of positive integers (an)n21 such
that (an + m) (am + n) is a perfect square for all positive integers n, m.
6.1.
The yoga of p-adic valuations
353
Proof. It is clear that an = n + k is a solution of the problem for all k 2 0.
We will prove that these are all solutions.
Let n, m be distinct positive integers and suppose that a prime p divides
an — am. We will prove that p I n — m. We claim that we can find 3 2 1 such
that vp(s + an) and vp(s + am) are odd. If the claim is proved, then vp(n + as)
and vp(m + as) must be odd, since (3 + an)(n + as) and (s + am)(m + as) are
perfect squares. Thus p divides n+a5 and m+as, and then p | m—n, as desired.
Now, let us prove the existence of 3. If vp(a,n — am) = 1, choose 3 = p3r - an,
Where r is large enough and relatively prime to p. If 1),, (an — am) 2 2, choose
3 2 pr — an, where r is large enough and prime to p.
Now, the previous paragraph shows that an 75 am for all n aé m, and also
that Ian — an+1| = 1. Thus an“ — an and an+1 — an+2 are both 1 or —1, and
distinct, thus they must add up to O. This implies that an+2 —an+1 = an“ —an
for all n 2 1, and since an > 1 for all n, we must have an+1 —- an = 1 for all n.
Thus an = n + k for some constant k 2 0, and the problem is solved.
El
6.1.3
Lifting the exponent lemma
Let us start with some easy observations, which are however very useful in
practice. Let a, b be integers and let p be a prime dividing a — b. Note that
a.” = (a — b + b)? = (a — b)” +p(a — b)p_1b +
+p(a — b)b”_1 + b”.
In the previous sum all terms except for the last one are multiples of p2, since
p | a — b. We conclude that p2 | a? — bp. In other words, if a and b are
congruent mod p, then up and bp are congruent mod p2, i.e. raising to pth
power improves congruences! The same formula shows more generally that if
pl divides a — b for some l 2 1, then pl+1 divides ap — b”. This easily yields
the following estimate.
Theorem 6.22. Let a, b be integers and let p be a. prime dividing a — b. Then
for all positive integers c we have
vp(ac — b”) 2 14,01 — b) + 'vp(c),
i.e. '01, (ac: c) 2 vp(c).
354
Chapter 6. p-adic valuations and the distribution of primes
Proof. Let k = vp(c) and l = up(a— b). Since pl | a — b, the previous discussion
shows that p“'1 | ap — bp, then pl+2 | up2 — b"2 and continuing like this we
obtain pl‘Hg | apk — bpk. Since pk | c, we have apk — bpk | a6 — be. Thus
'11,,(ac — b“) 2 l+ k = up(a — b) + up(c).
El
Example 6.23. (Romania TST 2009) Let a,n > 2 be integers such that n
divides (a — 1),“ for some k 2 1. Prove that n divides 1 + a + a2 + + an‘l.
Proof. Take a prime p dividing n. By hypothesis p divides a — 1. It is thus
enough to prove that up (“(3:11) 2 up(n), which follows from theorem 6.22.
III
The next result, more technical, refines the previous one. One has to be
careful when applying this result, since there are a few hypotheses involved in
its statement.
Theorem 6.24. (Lifting the exponent lemma) Let p be an odd prime and let
a, b integers not divisible by p such that pla — b. Then for all n 2 1
up(a" — b”) = up(n) + up(a — b).
Proof. Call an integer n 2 1 good if satisfies the conclusion of the theorem
for any a, b as in the statement. Note that if m,n are good, then so is mn.
Indeed, if a, b satisfy the hypotheses of the theorem, then so do am and bm,
thus
”Mam" - hm”) = vp((am)" - (m‘) = vp(am - b’") + ”2201)
= vp(a — b) + up(m) + up(n) = up(a — b) + vp(mn)
and ran is good. Since 1 is clearly good, it suffices to prove that any prime q
is good. If q 76 p, this reduces to proving that % = a"‘1 +aq_2b+ + b‘l“1
is not divisible by p, which is clear since a‘il—1 + aq‘Zb +
+ b‘1_1 E gag—1
(mod p) (as p | a — b) and qa is not divisible by p.
Suppose that q = p and write a = b + pkc for some integer c not divisible
by p and some k 2 1. The binomial formula gives
ap — b? = pk+1bp_1c + (12)) bp_2p2kc +
+pkpcp.
6.1.
The yoga of p—adic valuations
355
Since p > 2, the terms (3) bp_2p2kc, ..., pkpcp have p—adic valuation greater than
k + 1, which combined with gcd(p, be) = 1 gives
vp(ap — b”) = vp(pk+1bp_lc) = k + 1 = 1 + vp(a — b),
as needed.
El
We also mention the following immediate consequence of the previous theorem:
Corollary 6.25. Let p be an odd prime and let a,b be integers not divisible
by p and for which p | a + b. Then for all odd positive integers n
w" + b“) = w + b) + ope).
Proof. It suffices to apply the previous theorem to a and —b.
E!
The reader might wonder what happens when p = 2. In this case the
formula is a bit more complicated to state, but much easier to prove.
Theorem 6.26. If a:,y are odd integers and n is an even positive integer,
then
2
v2(:1:" — y”) = v2 (5172;?! > + v2(n).
Proof. Write n = 2ka for some odd number a. Then using repeatedly the
difference of squares formula we obtain
3:" — y” = (ma _ ya)(xa + yasa + y2a)m($2’°‘1a + y2k‘1a).
Observe that if u, v are odd numbers, then u2 +v2 E 2 (mod 4). The previous
formula gives therefore
v2(x” — y”) = v2(:c2“ — 92“) + k — 1.
Finally, since a, m, y are odd, it is easy to see that $2551 = x2(“'1)+...+y2(“—1)
is odd. The result follows.
El
356
Chapter 6. p-adic valuations and the distribution of primes
Remark 6.27. When n is odd, things are very simple: 1:153: = 3;"‘1 +...+y"‘1
is odd and so U203” — y") = 112(93 — y).
The next series of examples illustrate the power of the previous theorems.
Example 6.28. Find all integers a, n > 1 such that any prime factor of a” — 1
is a prime factor of a — 1.
Proof. Let p be a prime factor of n and assume that p > 2. Any prime factor
q of 1 + a +
1 +a+
+ a1”"1 divides ap — 1 | a" — 1, thus it divides a — 1. But then
+0!"1 E p (mod q) and since q | 1 +a+
In other words 1 + a +
+a1’_1 we obtain q = p.
+ a1"1 = pk for some k > 0, and moreover p | a — 1.
Now lifting the exponent lemma yields (since p > 2)
vp(1 + a +
+ ap_1) = vp(ap —- 1) — vp(a — 1) = 1
and so A: = 1. But this is impossible, since a > 1 and so 1 +a+
+a’"1 > p.
Hence any prime factor p of n is 2, in other words n = 2" for some k > 0.
But then a + 1 | a“ — 1 and so any prime factor of a + 1 divides a — 1 and so
divides 2. Thus a + 1 is also a power of 2, say a + 1 = 2’“.
Suppose that k. > 1, i.e. n > 2. Then a2 + 1 | a” — 1 and as above we
obtain that a2 + 1 is a power of 2, say a2 + 1 = 2’. Since 4 cannot divide a2 + 1,
we must have l = 2 and then a = 1, a contradiction. Hence n = 2 and a + 1
is a power of 2. Conversely, if these conditions are satisfied then clearly (a, n)
is a solution of the problem.
III
Example 6.29. Find all integers a, n > 1 such that any prime factor of a" + 1
is a prime factor of a + 1.
Proof. Assume first that n is even. If p | a" + 1 is a prime, then p | a + 1 and
so 0 E an + 1 E 2 (mod p), that is p = 2. It follows that a" + 1 = 2’“ for some
k; > 0. Since a" + 1 is of the form 1:2 + 1 (as n is even), and such a number is
never a multiple of 4, it follows that k = 1, contradicting a > 1. Hence it is
odd.
If p is a prime factor of n, then any prime q dividing
ap+1
a+1
=ap_1—ap-2+...—a+1
6.1.
The yoga of p-adz'c valuations
divides a + 1 and so 0 E tip—1 — a1"_2 +
357
- (1+ 1 E p (mod q), which in turn
yields p = q. Thus zp—fl 2 pk for some k > 0 and using again the lifting the
exponent lemma we obtain k = 1, thus
ap+1 =p(a+1) or (1(a1"1 —p) =p—1.
Moreover, from the above discussion we know that p | a + 1, so a 2 p — 1
and the previous equation yields a19—1 — p S 1. Since p > 2, we obtain
p + 1 Z a?”1 2 a2 2 (p — 1)2, which immediately implies p = 3 and then
a = 2. Hence a = 2 and n is a power of 3. If n aé 3, then replacing a with
b = a? we obtain that any prime factor of b3 + 1 divides b + 1 and by the
above discussion this forces b = 2, which is not the case. Hence n = 3 and
a = 2 is the unique solution of the problem.
III
Remark 6.30. The previous exercise is a generalization of an IMO Shortlist
2000 problem: find all triplets of positive integers (a, m, n) such that am + 1 |
(a + 1)”.
Example 6.31. (IMO Shortlist 1997) Let b, m, n be positive integers such that
b > 1 and m 9E 77.. Prove that if bm — 1 and b” — 1 have the same prime divisors,
then b + 1 is a power of 2.
Proof. Without loss of generality we may assume that m > n.
Let d =
gcd(m, n) and let m = led and a = bd. Note that k > 1 and any prime p
dividing ak — 1 = bm — 1 divides b" — 1 and so it divides gcd(bm — 1, b” — 1) =
bd — 1 = a — 1. By example 6.28 we deduce that a + 1 is a power of 2, that is
bd + 1 is a power of 2. If (1 is even, then bd + 1 is not a multiple of 4 and is
greater than 2, so it cannot be a power of 2. Hence d is odd and this implies
that b+1 isapower of2, since b+1 |bd+1.
III
Example 6.32. (generalization of IMO 1990 and 1999) Find all primes p and
all positive integers n such that Tip—1 divides (p — 1)” + 1.
Proof. Note that if p = 2, then 77. = 1 or n = 2. From now on, we assume
that p > 2. If n is even, then 4 cannot divide ftp—1 (because 4 does not divide
(p — 1)" + 1) and so p = 2, a contradiction. So, n is odd. Let q be the smallest
358
Chapter 6. p-adic valuations and the distribution of primes
prime factor of n. Since q divides (p — 1)2n — 1 and (p — 1)‘1_1 — 1 and since
gcd(2n, q — 1) = 2, it follows that q divides (p — 1)2 — 1 = p(p — 2).
Suppose first that q divides p— 2. Then, by the lifting the exponent lemma
we have
(P — 1)'Uq('n) = WWII—1) S ”q“? — D2” — 1) = ”q“? - U2 — 1) + ”(1(71'),
so that (p — 2)vq(n) S vq(p — 2). In particular, p — 2 2 qlp"2 2 3P‘2. This
easily implies that p = 3, contradicting the fact that q divides p — 2.
Next, assume that q = 19, so that again by the lifting exponent lemma
(using that n is odd) we have
(I) — 1)vp(n) = vp(np‘1) S 'vp((.v - 1)” + 1) = 1 + ”12(11)Thus (p — 2)vp(n) S 1. In particular, = 3 and vp(n) = 1. Write n = 3a
with gcd(a, 3) = 1 and observe that a2 divides 8“ + 1. We claim that a = 1.
Otherwise, let 7‘ be the smallest prime factor of a, so that 7' divides 64“ — 1
and 64’"—1 — 1. Thus r divides 63, since gcd(a,r — 1) = 1. But then 7" = 3 or
r = 7. Since 3 does not divide a, we must have T = 7 and 7 divides 8“ + 1.
Since this is of course impossible, it follows that a = 1 and n = 3.
El
Example 6.33. (China TST 2009) Let n be a positive integer and let a > b > 1
be integers such that b is odd and bn|an — 1. Prove that ab > %.
Proof. Take any prime factor p of b, then necessarily p > 2 and the lifting the
exponent lemma (combined with Fermat’s little theorem) gives
n S WT") S vp(a” - 1) S ”AW—1)" - 1”) = Map—1 - 1) + 0pm),
so that
n
ab > (JP—1 — 1 Z p””(“p_1"1) 2 p? Z
311
y-
The result follows.
El
We end this section with the following difficult problem.
Example 6.34. (China TST 2002) Find all positive integers n for which
(2" — 1)(3” — 1) is a perfect square.
6.1.
The yoga of p-adz'c valuations
359
Proof. We will prove that there is no such n. Assume that (2"—1)(3”—1) = m2
for some integers m, n 2 1. Note that m is even, thus 4 | 3“ — 1 and n is even.
Therefore 3 | m and so 9 | 2” — 1, which forces 6 | n. Next, we will prove that
10 | n. Write n = 6k, thus (64’c — 1)(36’° — 1) = m2 and so
(2k — 1)(16’“ — 1) E m2 (mod 31).
One easily checks that the left-hand side is a multiple of 31 if and only if 5 | k.
Suppose that 5 does not divide k. The previous congruence gives
2k—1
31
16’“—1 _1
31
"
2k+1
31
4k+1 _1
31
"
which is equivalent to
To check that the last equality is impossible, it suflices to do so for k = 1, 2, 3, 4
(using the 31-periodicity of Legendre’s symbol modulo 31), which (after simple
algebra) comes down to checking the impossibility of any of the following
relations
3
5
5
17
5
13
17
(3‘1) ' (3‘1) ‘ 1’ (a) ‘ (a) ‘ 1’ (a) ' (3‘1) ‘ 1’ (3‘1) ‘ 1'
These follows directly from
(3) = (E) = (1-3) = (3) =1,
31
31
31
31
all easily established.
Write now n = 10a: and use the lifting the exponent lemma to obtain
2011077) = ”11((2n ‘ 1X3" ‘ 1)) = 011((210V — 1) + 011((310)” - 1)
= 011(210 — 1) + 011(310 — 1) + 2112(1)) = 202(17) + 3,
a contradiction. Thus there are no such n.
E]
360
Chapter 6. p-adic valuations and the distribution of primes
6.2
Legendre’s formula
In this section we discuss Legendre’s formula giving the p-adic valuation
of n! and its consequences to the arithmetic of binomial coefficients. We will
use these properties in the next section to obtain nontrivial estimates on the
distribution of prime numbers.
6.2.1
The p-adic valuation of n!: the exact formula
We have already given several proofs of the fact that the product of n
consecutive integers is a multiple of n!. Most of these proofs used specific
properties of binomial coefficients. We would like to give a proof of this result
using the local-global principle according to which a | b if and only if vp(a) S
vp(b) for all primes p. For that, it is necessary to compute up (n!) for a prime
p and a positive integer n. This is the object of the next theorem.
Theorem 6.35. (Legendre) For all primes p and all positive integers n we
have
vp(n!) = [g] + lg] +
Before giving the proof of this theorem, we emphasize that the apparently
infinite sum appearing in the statement is in fact finite, since all but finitely
many terms are zero. Indeed, there is k such that pk > n, and then [fit-J = 0
for all i 2 16.
Proof. We have
vp(n!) = vp(1 - 2 -
- n) = vp(1) + 1),,(2) +
+ vp(n).
Among the numbers 1, 2, ...,n there are [i] multiples of p, [#J multiples of
p2, and so on. Multiples of p but not of p2 have contribution 1 to the sum,
multiples of p2 but not of p3 have contribution 2, and so on. Hence
vp<m>=EJ-l%J+2(l%J-l%J>+3(l%J-L%J)+~-
and the sum telescopes to the desired formula.
El
6'. 2.
Legendre ’s formula
361
Let us come back now to our original problem, namely giving a proof of
the fact that n! divides (a: + 1)(a: + 2).“(1: + n) for any integer m using p—adic
valuations. Fix a prime p and let nk be the number of multiples of pk among
:5 + 1, ..., a: + n. As in the proof of the above theorem, we see that
vp((:z; + 1)(a: + 2)...(:I: + 71.)): n1 + n2 +
On the other hand, it is clear that
m+n
a:
n
”Fl pk l'lfilzlfil’
since in general La: + y] 2 [:6] + Ly] for all real numbers 9:, y. Thus Legendre’s
formula yields
vp((m + 1)...(a: + n)) 2 vp(n!)
for all primes p and the result follows.
Here are a few more examples of counting arguments used to establish
divisibilities or identities.
Example 6.36. (China TST 2004) Let m1,m2, ...,mr and 711,712, ...,ns be positive integers such that for any integer d > 1 the number of multiples of d
among m1, ...,mr is greater than or equal to the number of multiples of d
among 774, ..., n3. Prove that nlng...ns divides mlmz...m,.
Proof. For d > 1, let Md and Nd be the number of multiples of d among
m1, ...,mr, respectively n1, ...,n8. By hypothesis Md 2 Nd for all d > 1. For
any prime p we have (arguing as in the proof of Legendre’s formula)
vp(m1m2...mr) = Mp + Mp2 +
+M n +
Z Np + s +
= vp(n1n2...ns)
hence n1...ns | m1...mr and the problem is solved.
Example 6.37. (Putnam 2003) Prove that for each positive integer n,
n! = filcm(1,2,. . . , [n/z'j).
i=1
El
362
Chapter 6. p-adic valuations and the distribution of primes
Proof. It is enough to prove that both sides have the same p—adic valuation
for all primes p. Fix a prime 1). Using Legendre’s formula and the fact that
vp(lcm(1,2, ...,d)) = [logp(d)J ,
we are reduced to proving the equality
z lfil :2 l ogp BJJ
for all primes p and all n.
For this, we count in two different ways pairs
of positive integers (i, k) such that ip’c S n. For fixed i there are [logp [fl]
possibilities for k, while for fixed Is there are IJ—z‘k-J possibilities for i. The result
follows.
E
Example 6.38. (Miklos Schweitzer Competition 1973) Let n, k be positive integers such that n > k + lcm(1, 2, ..., k). Prove that (2) has at least k distinct
prime factors.
Pmof. Write Lk = lcm(1, 2, ..., k). It suffices to prove that for n > k + Lk the
number (2) is a multiple of a product of k numbers that are pairwise relatively
prime and greater than 1. For 0 S i < k let
x. _ L
‘l — n(n - 1:, Lk) .
Clearly as; > 1 and one easily Checks that $0, ...,:ck_1 are pairwise relatively
prime (see the proof of example 6.19). It suflices therefore to prove that
$o$1---wk—1|
n
k ,
which is equivalent to
n
k!|
H
i=n—k+1
gcd(i, Lk).
6. 2. Legendre ’s formula
363
It sufi‘ices therefore to prove that for all primes p
n
”100903 2 vp(gcd(z',Lk))i=n—k+1
Let r = vp(Lk) = [logp k] (see example 6.7). For all i S 7" there are at least
[1%] multiples of pi among 12, n — 1, ..., n —— k + 1. Also, if u is a multiple of pi
with z' 5 r, then so is gcd(Lk, u). The desired inequality is then an immediate
consequence of Legendre’s formula.
El
6.2.2
The p-adic valuation of n!: inequalities
Observe that for all primes p and all positive integers n we have
n
n
n
n
n
p
p
p
p
p— 1
[—J+[7J+...<—+j+...=—
and
n
n
n
p
p
:9
l—l+l_—2J+m>——1'
Combining these inequalities with Legendre’s formula we obtain the following
estimate, which is more useful in many situations than the exact formula for
'up (n!) obtained in the previous section.
Theorem 6.39. For all n > 1 and all primes p we have
n
n
— — 1 < v n! < —.
p
,( > p _ 1
We give now some nice illustrations of the previous result.
Example 6.40. (MEMO 2015) Find all pairs (a, b) of positive integers such
that
a!+b! =ab+b“.
Proof. By symmetry, we may assume that a S b. If a = 1, the equation
becomes b! = b, yielding the solutions (1, 1) and (1, 2), so assume that a 2 2.
Then b! — ab = b“ — a! 2 a“ — a! > 0, thus b! > ab. On the other hand, the
AM—GM inequality yields
b!=1-2-...-b<_ (b(b+1))b=
(H—IY.
2b
2
364
Chapter 6'. p-adtc valuations and the distribution of primes
We conclude that 2a < b + 1, thus b 2 2a.
Let p be a prime divisor of a. Then p | a!+b! and p | ab, thus p | b. Therefore
vp(ab+ba) Z a. On the other hand, since b 2 2a we havep | (a+1)-(a+2)-...-b,
hence
vp(a! + b!) = vp(a!) + vp(1 + (a + 1) - (a + 2) -
- b) = vp(a!) < a,
the last inequality being a direct consequence of theorem 6.39. We obtain
therefore the plain contradiction a < a, showing that all solutions of the
problem are (1,1), (1,2) and (2,1).
III
Example 6.41. (Saint Petersburg 2007) Find all positive integers n and k for
which
1“+2”+...+n"=k!.
Proof. We will prove that n = k = 1 is the unique solution of the problem.
Suppose that n > 1. Note that k" > k! > 17.”, thus k: > n. First, assume
that n is odd. Then 2“ + 3” + + n” is a multiple of n + 2 (since each of
the numbers 2" + n”, 3" + (n — 1)”,... is a multiple of n + 2), thus k! — 1 is
a multiple of n + 2. In particular k < n + 2 and since k > n we must have
k = n + 1. Then (a + 1)! > n", which gives n < 3, a contradiction.
Hence n is even, say 71. = 2m. Also, 4 | k! and
1n+2"+...+n"Em
(mod4)
thus 4 | m and 8 | n. Write n = 28m with s 2 3 and m odd. Fort E {1,2, ...,n}
odd we have
t" = (2.23)”, E 1
(mod 23'”)
and when i is even in E 0 (mod 23“). Thus
1” + 2” +
+ n" E 25—1m
(mod 28“)
and so
12206:!) = 122(1” + 2" +
+ n") = s — 1.
On the other hand theorem 6.39 gives
k
v2(k!)>5—1>g——1=23_1m—1228_1—1,
6. 2. Legendre ’s formula
365
hence s > 23—1, impossible. Hence there are no solutions with n > 1.
E!
The next example is much more challenging.
Example 6.42. (Russia 2012) Prove that there is a positive integer n such that
1! + 2! +
+ n! has a prime factor greater than 102012.
Proof. Let f(n) = 1! + 2! +
+ n! and let S be the set of all primes not
exceeding d := 102012. Suppose that for all n 2 1, all prime factors of f (n)
are in 8'. Let P = Hpes p2. The key ingredient is the following result.
Lemma 6.43. There is a constant c > 0 such that for all p S d and all n 2 c
relatively prime to P
vp(f(nP — 2» s v.<(nP)!> — 2.
Proof. We will prove that for any p S d, the inequality vp(f (nP — 2)) 2
vp((nP)!) — 1 can hold for at most one n that is relatively prime to P. Fix
1) S d and suppose that this inequality holds for two integers n < m relatively
prime to P. Since
vp<<nP — 1)!) = v.((nP)!) — um) = v.((nP)!) — 2,
the strong triangle inequality gives
vp(f(mP — 2)) = vp((nP — 1)! + f(nP — 2) + (nP)! +
+ (mP — 2)!)
= vp((nP — 1)!) = vp((nP)!) — 2.
On the other hand by assumption
vp(f(mP — 2)) 2 v.(<mP>!) — 1.
We deduce that vp((nP)!) 2 vp((mP)!) + 1, which is obviously impossible.
The result follows.
B
Let c be as in the previous lemma. We conclude that for all n 2 c relatively
prime to P we have
vp(f(nP — 2)) s 5"; — 2 < nP.
366
Chapter 6. p-adic valuations and the distribution of primes
Since all prime factors of f (nP — 2) are less than or equal to d, this forces
(nP — 2)! < f(nP — 2) s H pnP < d!”P
d
for all n 2 c relatively prime to P. This is clearly impossible.
[II
We also point out the following important consequence of Legendre’s formula, which will be very useful in obtaining explicit estimates concerning
prime numbers.
Theorem 6.44. Let n 2 k 2 0 be integers and let p be a prime. Then
pvP((']:)) S n.
In other words, all prime powers dividing (Z) are smaller than n + 1.
Proof. Legendre’s formula gives
vp((:))=vp<m>—vp<k!>—vp<<n—k>l>=,;(t%JlaM)Note that each term in the sum is equal to 0 or 1, since for any real numbers
93,11
L56 + y] - Lwl - [it] 6 {0,1}Indeed, the left-hand side equals |_r + s], where r = a: — |_r] 6 [0,1) and
s = y — Ly] 6 [0,1). Finally note that for p7 > n
ltl=l§J=V§fJ=m
thus there are at most |_logp(n)J nonzero terms in the sum and so
u. ((9) s [10n .
The result follows.
El
6.2. Legendre ’s formula
367
Remark 6.45. The inequality (discussed in the proof of the previous theorem)
OS Lw+yl - Lwl - [21] 31
will be used implicitly quite often from now on.
The following example uses similar ideas to establish a rather remarkable
identity.
Example 6.46. (AMM E 2686) Let n be an integer greater than 1. Prove that
(72+ 1) lcm ((3), (111).“, (2)) = lcm(1,2,.. . ,n+ 1).
Proof. We will prove that for each prime 13 both sides have the same p—adic
valuation, which is enough to conclude. Let p be a prime and let k be such
that pk g n + 1 < 12"“. By example 6.7 we have
vp(lcm(1,2, . . . ,n + 1)) = k.
Note that (n + 1)(pk"_1) = pk ("581), thus the p-adic valuation of the left-hand
side is greater than or equal to k. To prove that this valuation is at most k,
fix 0 g i g n and use Legendre’s formula to get
up ((n+ 1)(:’))=vp((¢+1)(?:11))= vp(z'+ 1) +2233“
where
wr=[”;11—r;11-r.:i
Note that a» E {0, 1} for all 7' (see remark 6.45) and 51:, = 0 if 7' > k (since
in this case pr > n + 1). The key point is that w,» = O for all r S vp(z' + 1).
Indeed, writing 12+ 1 = pru for some integer u, we have
11:, =
[n + 1]
p?
[n + 1
—u— —
—
pr
Putting these observations together yields
Ex, 3 k —vp(z'+ 1),
121
]
= 0.
368
Chapter 6. p-adic valuations and the distribution of primes
from which we get up ((i + 1)(:‘_"'_'11)) S k for all 0 S i S n, establishing the
El
desired inequality.
Combining the result of the previous exercise with example 6.8 yields the
following estimate for the number 7r(n) of primes not exceeding n, which is
surprisingly good (see the next section for a more detailed discussion of such
issues).
Example 6.47. Prove that for all n > 1 we have
lcm(1,2, ...,n) 2 2"'1
and
727“”) 2 2"_1.
Proof. For the first inequality, simply note that
<n+wcm<<z>(all-42>)agar
and use the result established in the previous example. For the second inequal-
ity, use the first one and the inequality lcm(l, 2, ..., n) S n"(”) established in
example 6.8.
El
Example 6.48. Prove that if c 6 (0,2), then for all sufi'lciently large n the
product of all primes not exceeding n is greater than c".
Proof. By the previous example
lcm(1,2, ...,n) 2 2"_1.
On the other hand by example 6.7 we have
H
lcm(1,2, ...,n) = H pll°gr(")l g H n173%;
P5"
fi<psn
We deduce that
H p 2 2"_1 - n—‘F‘.
psn
Thus we need to prove that for any 0 E (0, 2) we have
(2) 2
n
C
p g n‘/’_‘ - H p.
1091
6. 2. Legendre ’3 formula
369
for all n large enough. Since 211W < n2\/’_‘, it suffices to check that (%) WI > n2
for large enough n, which is immediate.
6.2.3
El
Kummer’s theorem
Instead of giving estimates for [%J + [1—H + like we did in theorem 6.39,
we can also obtain an exact formula as follows: write
n = akpk + ak_1p’°_1 +
+ a0
in base p (thus a0, ...,ak E {0, 1, ...,p— 1} and ak 7E 0). Then for all 0 Sj S k
In,
.
.
lfij = akpk‘J + ak_1p"'1‘1 +
+ a,-,
therefore
n
I:
n
11—1
+ a1
+ 1) +
+ 1) + ak_1(pk_2 +pk‘3 +
k__1
=ak'p
-
E :(akpk" + ak—ipk'l" + + On)
= j=1
id
p + l_J
p2 +
= ak(p’°‘1 +p’°‘2 +
:
k—1_1
_1
+ak_1p—+...+a1p
12—1
p—l
= (akpk+...+a1P+ao)— (ak+...+ao) = n—sp(n)
p—l
p—l
’
where
sp(n) = a0 +
+ ak
is the sum of digits of n when written in base p. Combining this computation
with Legendre’s theorem we obtain the following result.
Theorem 6.49. For all n 2 1 and all primes p we have
_ 3pm) ,
| = n p—l
vp(n.)
where sp(n) is the sum of digits of n when written in base p.
370
Chapter 6. p-adic valuations and the distribution of primes
This theorem immediately implies the following formula for the p—adic
valuation of binomial coefficients.
Corollary 6.50. For all primes p and all integers n 2 k 2 1
v ((12)) = spas) + spa — k) — spa)
p
k
p— 1
'
Let us observe that W32 is precisely the number of carries
when adding k and n— k in base p. We obtain therefore the following beautiful
theorem.
Theorem 6.51. (Kummer) The p-adic valuation of (Z) is the number of carries when adding k and n — k in base p.
Remark 6.52. Even more precisely, for each 3' 2 1 we have
PrPerflkf
where u, u, w are the remainders of k, n — k, n when divided by p7. Note that
u + u = to if and only if u + 'v < pl, if and only if there is no carry in the jth
digit when we add k and n — k in base p. Thus
lfliflitfl
p”
p7
p7
is equal to 1 if there is a carry in the jth digit when adding k and n — k in
base p, and it is equal to 0 otherwise.
We illustrate the previous results with some concrete examples.
Example 6.53. Prove that if n is a positive integer and 1 S k S 2”, then
warn—w»
6'. 2. Legendre ’s formula
371
Proof. Using corollary 6.50 we obtain
2n
’02
(16)) = 152(k) + 82(2” — k) — 82(2n).
If k = We with 'r 2 0 and 3 odd, then clearly 'r S n and
32(2" —k) = 32(2n—2Ts) = 32(2n'r—s) = n—r+1—32(s) = n—r+1—sz(k).
Taking into account that 32 (2") = 1, the result follows.
III
Example 6.54. Prove that n 2 1 is a power of 2 if and only if 4 does not divide
2
(,7)-
Proof. 4 does not divide (2:) if and only if 122“?» S 1. This is equivalent
to 282 (n) — 32(2n) g 1. Since 32(2n) = 3202) (as the binary expression of 2n
is simply the binary expression of n followed by a terminal 0), this is further
equivalent to 32(7),) S 1. Clearly, this happens if and only if n is a power of
2.
El
Example 6.55. Prove that all numbers (2;) with 1 g k < 2" are even and
exactly one of them is not a multiple of 4. Which one?
Proof. Corollary 6.50 gives
’02 ((3:1)) =82(k) +82(2n—k) — 1 2 1.
In order to have equality we need 3206) = 32(2" — k) = 1, which is easily seen
to happen only for k = 2"“1.
El
Example 6.56. (IMO Shortlist 2008) Let n be a positive integer. Prove that
the remainders of the numbers
(”51), (2'1”), (”2‘I), (23111)
when divided by 2” are a permutation of 1, 3, 5, ..., 2" - 1.
372
Chapter 6. p-adic valuations and the distribution of primes
Proof. By Lucas’ theorem (or by example 6.53 and the equality (2”,:1) =
2:1“ (2‘)) all remainders belong to {1, 3, 5, ..., 2" — 1}, so it suffices to prove
that (2",:1) and (2"1—1) are not congruent modulo 2" if 1 g k < l S 2‘" are odd.
Assume that
2" — 1 )=(
_ 2" l— 1 )
(k
n
(mod2)
and observe that
(2“;1>=(2£‘)-(2£‘:5)=(Zf)-(i"1>+<2?-‘21>="'
=(2:)-(i”1)+(i"2>- +63?)
thus the congruence can be written as
2”
2"
2n
(l)_<l—1)+m_(k+1)50
,,
(mod2 ).
Since (2:) is divisible by 2” whenever s is odd (by example 6.53), the previous
congruence is equivalent to
2“
2n
2” _
(mod2).,,
..+(,+1)_0
(,_1)+(,_3)+.
Let
n
se{l—1,l—3,...,k+1}
n
w<<2>>=v2<<2>>
s
x
for some :1: E {l— 1,l—3, ..., k+1}. Since (1231) + (12:3) +...+ (5:1) is a multiple
of 2” and n > N, there must be y e {l — 1,l — 3, ...,k + 1} different from a:
v2 ((3‘)) ((33))-
Using again example 6.53, we obtain 11201;) = 122(y). Let m = 122(ac) and
without loss of generality, assume that a: < 3;. Then a: = 2ma and y = 7%
6.3. Estimates for binomial coefficients
373
with a, b odd and a < b. But then :1: + 2"" E {l — 1,l — 3, ..., k + 1} and (using
once more example 6.53)
<<>><<>>
contradicting the minimality property of :3.
6.3
III
Estimates for binomial coefficients and
the distribution of prime numbers
This section is rather technical, but contains many beautiful results concerning the distribution of prime numbers. The reader may want to skip some
of the more involved estimates for a first reading. Our goal is to use Legendre’s
formula and a detailed study of binomial coefficients and their p—adic valuations to try to answer the following basic question: about how many primes
are there between 1 and n?
6.3.1
Central binomial coefficients and Erdiis’ inequality
We will focus on central binomial coefiicients, since these are the easiest
to estimate asymptotically. More precisely, since (2:) is the largest among
(26‘), ..., (3:) and the sum of these binomial coefficients is 22", it is clear that
411
2n
> 4” .
> (n) - 2n+1
Also note that since (2";1) = (211:?) and 23:61 (2”,:1) = 22”“, we have
(2n+1) <4"n
This will play a crucial role in the proof of the following beautiful result. If S
is a set of positive integers, we make the convention that [[1763 p is the product
of all primes in S (the letter p will always denote a prime in this section).
374
Chapter 6. p-adic valuations and the distribution of primes
Theorem 6.57. (Erdo's) For n 2 2 the product of all primes not exceeding n
is smaller than 471—1. In other words
H p < 4""1.
1031»
Proof. The proof is by strong induction, the case n = 2 being clear. Assume
that the result holds up to n — 1 and let us prove it for n > 2. If n is even,
then clearly HpSnp = HpSn—lp and we are done thanks to the inductive
hypothesis. Assume that n = 2k + 1 is odd. Note that
2k+1 _ (2k+1)! _(k+2)(k+3)...(2k+1)
k — k!(k+1)! ‘
k!
is a multiple of Hk+23p32k+1 p, thus Hk+25p32k+1 p S (2121-1) and so
2k + 1
17311
pSk+1
By the inductive hypothesis Hpsk+1 p < 4k and by the discussion preceding
the theorem (2";1) < 4", hence
Hp<4k-4k=4"_1,
pSn
finishing the proof.
El
Example 6.58. Prove that for all sufliciently large integers n there are 2n
consecutive composite numbers smaller than n!.
Proof. Let p1,...p;c be all primes not exceeding 2n + 1. Then p1...p;c + 2,
p1...p;c +3, ..., p1...pk+2n+1 are all composite and the largest of these numbers
is (by theorem 6.57)
p1...pk+2n+1 <4"+2n+1 <2-4n.
Since 2 - 4" < n! for n large enough, we are done.
El
6.3. Estimates for binomial coeflicients
375
Example 6.59. Prove that for all n > 2 we have
lcm(1, 2, ...,n) < 9".
Proof. Combining example 6.7 and theorem 6.57 gives
lcm(1,2,...,n) = Hpfl°gpnl = H p- H plbgpn] < 4n~
PS"
p>¢fi
psfi
H n) g 4"-n‘/fi.
SW?
It suffices therefore to prove that 4”-n\/’7 < 9", or equivalently that ”17% < 1n %.
A simple study of the function f (x) = 1% shows that f is maximal at a: = 62
and f(e2) = g < 0.74 < lug.
III
We give now a different and much more conceptual proof of the result
established in example 3.31.
Example 6.60. (IMC 2012) Is the set of positive integers n such that n! + 1
divides (201277.)! finite or infinite?
Proof. We will prove that there are only finitely many such n. Suppose that
n! + 1 divides (kn)!, where k = 2012. 'Then any prime factor of n! + 1 is greater
than n and smaller than or equal to kn. If p is such a prime factor, theorem
6.39 combined with the inequality p > 77. yields
ppm! + 1) g vp((kn)!) < pkfnl g Is.
Using theorem 6.57, it follows that
n! + 1 =
H p”P("!+1) <
n<pSkn
H pk < ( H 1))" < 41‘2”.
n<p5kn
pgkn
Thus any solution n of the problem satisfies n! < 41‘2". It follows immediately
that there are only finitely many solutions.
El
376
Chapter 6. p-adic valuations and the distribution of primes
6.3.2
Estimating 7r(n)
Recall that
7r(n) = :1
psn
denotes the number of prime numbers not exceeding n. One of the deepest
and most beautiful theorems in number theory is the following result proved
by Hadamard and de la Vallée—Poussin in 1896. The proof of this result is way
beyond the scope of this modest book.
Theorem 6.61. (prime number theorem) We have
lim "(7’) = 1.
n—)oo L
Inn
The famous prime number theorem asserts that for n large enough 7r(n)
behaves like $. The following result gives a uniform upper bound for the
quotient @. Of course, this bound is weaker than the one given by the prime
lnn
number theorem, but it is rather amazing that with so few tools it already
gives the "correct'I upper bound. Note that 6ln2 = 4.15....
Theorem 6.62. For all n 2 2 we have
or equivalently 7r(n) < 6ln2 - fi.
n"(”) < 64”,
Proof. Since
(2n) = (n + 1)(n + 2)...(2n)
n
n!
is a multiple of Hn<p32n p, we deduce that
nvr(2n)—1r(n) =
H
n<p$2n
n <
H
n<ps2n
p S (2”) S 4n.
n
Setting n = 2’c yields
Ic(7r(2’°+1) — «(25) 3 2k“,
or (k + 1)7r(2k+1) — k7r(2’°) g 2’°+1 + 1r(2k+1).
6. 5’. Estimates for binomial coeflicients
377
Since 7r(2’°+1) g 2", we obtain
(k + 1)1r(2’°+1) — k7r(2k) g 3 - 2'“.
Adding these inequalities for k = 1, 2, ..., n — 1 we obtain the inequality
n - 7r(2”) < 3 - 2”.
In general, let k; = Llogg (71)] , so that 2’6 S n < 2””. Then using the previously
established inequality, we obtain
n1r(n) < (2k+1)1r(2’°+1) < 82k+1 S 6477’,
[I
yielding the desired result.
We would like to find a good lower bound for 1r(n). Actually we have
already obtained a fairly good such bound in the previous section.
precisely we proved the inequality
More
n7l' (n) 2 211—1
for all n > 1 in example 6.47. This can be rewritten as
n—1
>
. lnn’
7r(n)_ln2
and is a fairly good lower bound taking into account that ln2 = 0.69... and
that ’l‘n—j is essentially the same as $1.111 particular, this bound immediately
implies the following one, which is weaker but has a somewhat more conceptual
proof.
Theorem 6.63. For n 2 2 we have
2
n7r(70>
_ f”,
ln2
n
'ltl
or equwa
en 31 7r(n) >—-—.
_ 2 Inn
Proof. One easily checks the result f0 72. S 5, so assume that n > 5. Writing
71. = 2k or n = 2k — 1 and using that «(216 — 1) = 7r(2k) for k 2 2, it suffices
to prove that (2k: — 1)"(2'°_1) 2 2’“ for k 2 3. Theorem 6.44 shows that for all
378
Chapter 6. p—adic valuations and the distribution of primes
.
. . .
2k
- pvP ((2"))
prlmes p d1v1d1ng (k) we have p1;P ((2k))
k 3 2k — 1 (the equallty
k _
— 2k IS
impossible, as this would force p = 2 and k = 2j for some j and then 2 = 2k).
Thus
(21:7) =
H pvp((2:)) E (2k _ 1)1r(2k—1).
pS2k—1
Since (2,?) 2 %, it suffices to prove that 2’“ 2 2k + 1 for k 2 3, which is
|:|
immediate.
Example 6.64. Prove that for all n > 1 we have
nlnn
< pn < 6nlnn.
5
Proof. The key point is that «(pn) = n, so we can use the previous estimates.
For instance, theorem 6.62 yields
641’" > p3 > n”,
thus
> nlnn > nlnn
1””
In 64
5
Similarly, theorem 6.63 yields
n>y.
—
2
pn
_
lnpn
The function f(2:) = fi being increasing for a: 2 3 (as a simple derivative
computation shows), assuming that pn > 6n lnn we obtain
n>E-
6nlnn
_ 2
111(6nlnn)’
which yields
ln(6nlnn) 2 3ln2 - lnn > 2lnn = lnn2.
We deduce that 6 lnn > n, which is false for n > 20 (as one can easily check).
For n S 20 it is not difficult to check the result by hand (taking into account
that p20 = 71).
El
6.3. Estimates for binomial coefi‘icients
379
Remark 6.65. Deep theorems of Rosser and Schoenfeld show that if pn is the
nth prime, then pn > nlogn and for all n > 66
n
log n—
1r(n) < —.
logn—g
We illustrate the previous theorems with two beautiful examples.
Example 6.66. Let k be a positive integer. Prove that there is a positive integer
n which can be written as the sum of two primes in more than k different ways.
Proof. There are 71'(N)2 pairs of prime numbers (p, q) with p, q S N. For any
such pair the sum p + q is at most 2N. Therefore by the pigeonhole principle
there must be an 'r S 2N which can be written as r = p + q for at least
7r(N)2 > (1112)2
2N -
4
N
'(lnN)2
pairs (p, q) (using theorem 6.63). This quantity tends to infinity as N grows,
so for N large enough this implies that r can be written as a sum of primes
in at least k ways.
El
Example 6.67. Prove that 7r(n) divides n for infinitely many 17..
Proof. The solution of this problem is short, but not easy to find! We claim
that for any positive integer m 2 2 we can find an integer n such that m7r('n,) =
n. We will choose n= mk for some positive integer k, so the previous equation
becomes gill“):
.Consider the set
S: {j > 1 |_—
”(——mj)>
—}.
mj >m
Note that 1 E S, so S is nonempty. Since fig? tends to 0 as a: —> 00, the set S
is finite. Letting k: max(S), we will prove that M: — ,which will finish
the proof. If M: #does not hold, then 1r(m(kk+ 1))m> 1r(mk) > k + 1,
contradicting the maximality of k. The result. follows.
[I
380
6.3.3
Chapter 6. p-adic valuations and the distribution of primes
Bertrand’s postulate
The last result we want to establish in this section is the following theorem,
that was conjectured by Bertrand in 1845 and proved by Chebyshev in 1850.
Later on, Erdos simplified the proof, and we follow his approach here. The
proof is unfortunately fairly technical and we advise the reader to skip it for
a first reading.
Theorem 6.68. (Bertrand ’s postulate) For all n 2 4 there is a prime p E
(n, 2n— 2). In particular, for n > 1 there is always a prime between n and Zn.
The key of the proof is again the study of the prime factorization of (2:).
It will be useful to introduce the following expression
Pu:
H
p,
n<p$2n~1
the product of all primes between n and 2n. Since it is not at all clear that
there are such primes (this is after all what we are trying to prove!), we use
the convention that P7, = 1 if there are no such primes. We will actually prove
a much stronger result (see the discussion following the proof of the next
theorem for the reason why it is much stronger than Bertrand’s postulate).
4
“I:
Theorem 6.69. For all n > 125 we have
Pn > (270%
Proof. Let A = (2:). All prime factors of A are between 1 and Zn and it is a
simple matter to check the equality
A = 1311' H pvp(A)_
psn
Note that
1
>
4n
_ 2n + 1
> 4n— ,
2n
6.3. Estimates for binomial coefi‘icients
381
thus in order to prove the theorem it suflices to prove that
H 19%“) < (2n)\/§—1 .42T”—1.
1611
For this, we will carefully analyze each p”P(A). By theorem 6.44 each p”P(A) is
S 2n. Also, Legendre’s formula shows that vp(A) S 1 for p > m and, most
importantly, that vp(A) = 0 for p 6 (Zn/3,77,]. Indeed, for such 1) we have
vp((2n)!) = 2 and vp(n!) = 1, thus vp(A) = 0. We conclude that
H p”p(A) S
133”
H (277,) .
pgv 2n
H
p.
v2n<pS 2?"
Now let n 2 125 and let k = l_\/2nJ, so that k 2 15. Since 1,9,15,4, ...,2 IEJ
are not primes, we have
7r(k)gk—(2+EJ)<§—lg\/g—l.
Combining these observations with theorem 6.57 finally yields
H 10W" < (27W?—1 4%”,
psn
as needed.
III
This fairly technical statement hides quite a. lot of interesting information.
For instance, since we trivially have
P." < (2n)1r(2n)—1r(n),
the previous theorem yields
ln4
n
n
”(273) _ 7r(n) > Y I In 2n _ \/g’
which shows that given 0 > “T4, we have
«(212) — «(71) > cfi
382
Chapter 6'. p-adic valuations and the distribution of primes
for all sufliciently large n, in other words there are many primes between 'n,
and 2n for n large enough.
We still have to explain why theorem 6.69 implies Bertrand’s postulate.
We assume from now on that 'n. > 225 (using tables of primes, one checks
that Bertrand’s postulate holds up to 225). Assume that there is no prime
p E (n, 271 — 2). This means that in the product defining B, there can be at
most one term, namely 2n — 1, in particular R, 3 2n — 1 < 2n. Using theorem
6.69 we obtain the inequality
4% < (2n)1+~/§ < (212W
and so
2g<¢§-\/fi.
Letting k = [4} we have k 2 5 and the previous inequality yields
2k<3-\/2-(k+1)<5(k+1).
It is however easy to check by induction that 28 2 5(3 + 1) for s 2 5, yielding
the desired contradiction. Note that this argument also shows that there are
at least two primes between n and 2n for n > 225 (one actually checks that
this holds for all n > 5).
Remark 6.70. a) It is of course not necessary to check that Bertrand’s postulate
for each n S 224 in order to finish the proof. Actually, usingthe sequence of
primes
7, 11, 13, 19, 23, 37, 43, 73, 83, 139, 163, 277,
the postulate is proved in no time at all for n S 225.
b) Sylvester and Schur proved the following beautiful generalization of
Bertrand’s postulate: if n > k, then at least one of the numbers n, n+1, ..., n+
k— 1 has a prime factor greater than k. In other words, for n 2 2k the binomial
coefficient (2) has a prime factor greater than k. Erdés proved that for k 2 202
and n 2 2k we have
6. 3. Estimates for binomial coefficients
383
which immediately implies the previous result for such n and k. The proof is
unfortunately more technical than that of Bertrand’s postulate, even though
the key ideas are the same.
c) By a deep theorem of Polya, if k 2 2 is an integer and if a1 < a2 <
is the sequence of integers all of whose prime factors do not exceed k, then
a,-+1 — a,- tends to 00. In particular, if n is large enough, then every integer
among n, n + 1, ..., n + k — 1, with one possible exception, has a prime divisor
greater than k.
d) Legendre conjectured that for all sufficiently large n there is a prime
between n and n + J17. This is still wide open.
After the previous hard work, it is time to see some concrete illustrations of
these results. Unfortunately, there seems to be no easier proof for the following
one.
Example 6.71. For n > 1, n! is not a perfect power.
Proof. We can assume that n > 3. By Bertrand’s postulate there is a prime
between 11/2 and n. Clearly vp(n!) = 1 and the result follows.
III
Remark 6.72. A diflicult theorem of Erdos and Selfridge states that the prod—
uct of consecutive integers is never a perfect power. The proof is much
harder than that of the previous corollary. They actually prove that for
all integers l,k > 1 and m 2 1 there is a prime p > k whose exponent in
(m + 1)(m + 2)...(m + k) is not a multiple of l. Moreover, they conjecture
that if l 2 2 and k; _>_ 3 then we can even find such p > k with exponent 1,
except in one case, namely for 48 ~ 49 - 50 (for k = 2 there are infinitely many
exceptions) .
Example 6.73. Prove that if n > 1 then we can make n pairs (a1, b1), ..., (an, b")
out of the numbers 1, 2, ..., 277., such that ai + b,- is a prime for all 1 S i S n.
Proof. We prove this statement by strong induction on n, the case n = 2
being clear (consider the groups (1,4) and (2, 3)). Suppose that the statement
is true for n < k and let us prove it for n = k. By Bertrand’s postulate there
is a prime p such that 216 > p — 2k 2 1. Considering the pairs (2k,p — 2k),
(2k — 1, p — 2k + 1), ..., (%1, phi—1) and applying the inductive hypothesis to
384
Chapter 6. p-adic valuations and the distribution of primes
1, 2, ..., p — 2k — 1 (note that p — 2k — 1 is even and less than 2k) yields the
desired result.
El
Example 6.74. Let A be a subset of {1, 2, 3, ..., 217.} with more than n elements.
Prove that there are two distinct elements of A whose sum is a prime number.
Proof. Consider a partition on {1, 2, ..., 2n} into pairs (a5, bi) such that a; + b.is a prime for all 1 S i S 77.. Since |A| > n, there is i such that a,, b,- E A and
we are done.
El
Example 6.75. Find all disjoint and nonempty subsets A,B C N such that
A U B = N and whenever x, y are distinct positive integers belonging simul-
taneously to A or to B, x + y is composite.
Proof. Clearly letting A be the set of positive even integers and B the set
of positive odd integers yields a solution of the problem. We obtain another
solution by permuting the role of even and odd numbers. We will prove that
there is no other solution. By symmetry we may assume that 1 E A, then
clearly 2 E B and so 3 E A and 4 6 B. Suppose now that n 2 2 and that
1,3, ...,2n — 1 e A, while 2,4, ...,2n 6 B. By Bertrand’s postulate there is a
prime p 6 (2n + 1,2(2n + 1) — 2) and then p — (2n + 1) 6 {2,4, ...,2n} C B.
Using the hypothesis of the problem, it follows that 277. + 1 E A. Similarly,
considering a prime p 6 (2n + 2, 4n + 2) shows that 217. + 2 E B. We have
just proved by induction that A contains all odd positive integers and that B
contains all even integers. The result follows.
El
Example 6.76. (USAMO 2012) For which integers n > 1 is there an infinite
sequence a1, a2, a3, . . . of nonzero integers such that for all positive integers k
ak+2a2k+...+nank=0?
Proof. Observe that n = 2 is not a solution of the problem. Indeed, the
relation ah + 2oz;c = 0 for all k forces 2i | ak for all j and k, thus ak = 0
for all k. We will prove that all numbers different from 2 are solutions, by
constructing such a sequence. We will moreover impose that aman = am.” for
all positive integers m,n, in particular a1 = 1. Thus we only need to define
ap for all primes p, and moreover the relation a], + 20.21,, + . . . + nan], = 0 is
6.3. Estimates for binomial coefficients
385
then equivalent to (11 + 2m + +nan = 0. For n = 4 one can define a2 = —1,
a3 = —1 and give arbitrary nonzero values to up for any prime p 75 2, 3.
Assuming that n aé 2, 4, we will prove in the next paragraph that we can
find different primes p,q such that «E < p S n and g < q < n. For any
prime 1‘ different from p and q define or = q. Then ak is a multiple of q for
any k 6 {1,2, ...,{n} different from 1,p, q since any such q has a prime divisor
different from p and q (since p,q > @. We only need to give values to (LP
and aq such that
Ziaz+qaq+ Z ia,=0,
i=q+1
in other words we need to find a value for up such that q divides 23—11 iai +
Egg+1 ia,. As we have already observed, this sum is congruent modulo q to
1 + pap, thus we can take any number m for which q | l + pm and set up = m.
We still need to prove the existence of p and q as above. We will assume that
n 2 16, for the other cases it is fairly easy to find explicitly p and q as desired.
Applying Bertrand’s postulate we can find a prime q E (n ,2 [g] — 2). Then
g < q < n. Applying again Bertrand’s postulate, there is a prime p E (g, q).
Then p > % > % 2 x/fi and the claim is proved.
El
Example 6.77. A polynomial f e Z[X, Y] with integer coefficients has the
property that for all distinct primes p, q the number f(p, q) is divisible by p
or by q. Prove that f(X, Y) = Xg(X, Y) or f(X, Y) = Yg(X, Y) for some
polynomial g with integer coefficients.
Proof. We need to prove that at least one of the polynomials f (X, 0) and
f (0, Y) is 0. Assume that this is not the case and take positive integers c, d
such that for all positive integers a:
maX(|f($,0)l, |f(0,$)|) S 000d~
This is possible, since f (X, 0) and f(O, X) are polynomials. Let .S' be the finite
set of all roots of the polynomial f (O, X) and consider a large positive integer
N such that the equation f(1.30) = 0 has no solution in (cNd,2cNd) (this
holds for all sufficiently large N since by assumption f(X, 0) is not the zero
polynomial).
386
Chapter 6. p-adic valuations and the distribution of primes
We claim that if q S N and p > cNd are primes, then q E S or q | f(p,0).
Indeed, suppose that q q! S and q does not divide f (p, 0), thus q does not
divide f(p, q) and the hypothesis gives p | f(p, q). This forces p I f(0, q),
which is impossible since f(0, q) 75 0 and |f(0,q)| S c S cNd < p. The
claim is therefore proved.
We conclude that for all primes p > cNd
II qlf(P,0)qSN,q¢S
By Bertrand’s postulate there is a prime p E (cNd, 2cNd) and for such p the
number f (p, 0) is nonzero (by the choice of N) and | f (p, 0)| S cpd < c(2cNd)d.
We obtain therefore the existence of a constant k such that for all sufficiently
large N we have
H q S kNd2.
qSN
This is however impossible by example 6.48. The result follows.
6.4
CI
Problems for practice
The yoga of p-adic valuations
1. (Russia 2000) Prove that there is a partition of N with 100 sets such
that if a, b, c 6 N satisfy a + 99b = c, then at least two of the numbers
a, b, c belong to the same set.
2. (Iran 2012) Prove that for any positive integer t there is an integer n > 1
relatively prime to t such that none of the numbers n +t, n2 +t, n3 +t,
is a perfect power.
3. Prove that if n, k are positive integers, then no matter how we choose
signs :I:
1
1
1
:l:
Ed:
i
is not an integer.
Ila—+1
"'ik-l——n
6.4. Problems for practice
387
(Romania TST 2007) Let n 2 3 and let a1, ...,an be positive integers
such that gcd(a1,...,a,n) = 1 and 1cm(a,1,...,an) | (11 +
that magman divides (a1 + a2 + + an)"_2.
+ an. Prove
(Erdos-Turan) Let p be an odd prime and let .S' be a set of n positive
integers. Prove that one can choose a subset T of S with at least [g]
elements such that for all distinct elements a, b E T we have
to» + b) = min<vp(a>,vp<b».
(Ostrowski) Find all functions f : Q —> [0, 00) such that
i) f(m) = 0 if and only if a: = 0;
ii) Hwy) = f(SD) ' f(y) and f(96 + y) S maX(f($),f(y)) for all 93,11. Find all integers n > 1 for which
n” | (n — 1)""“ + (n + 1W“.
(Mathlinks Contest) Let a, b be distinct positive rational numbers such
that a” — b” E Z for infinitely many positive integers n.
a, b E Z.
Show that
(Saint Petersburg) Find all positive integers m, n such that mnlnm — 1.
10. (Balkan 1993) Let p be a prime and let m 2 2 be an integer. Prove that
if the equation
mp + y? __ (a: + y)m
2
_
2
has a positive integer solution (x, y) 7E (1,1), then m = p.
11. (China TST 2004) Let a be a positive integer. Prove that the equation
n! = ab — ac has a finite number of solutions (n, b, c) in positive integers.
12. (China TST 2016) Let c, d be integers greater than 1. Define a sequence
(an)n21 by a1 = c and an“ = afi+c for n 2 1. Prove that for any n 2 2
there is a prime number p dividing an and not dividing a1a2...an_1.
388
Chapter 6. p-ad’ic valuations and the distribution of primes
13 (Kvant M 1687) Find the largest possible number of elements of the set
{2" — 1| n E Z} that are terms of a geometric progression.
14. (Iran TST 2009) Let a be a positive integer. Prove that there are infinitely many primes dividing at least one of the numbers
221 + a, 222 + a, 223 + a,
15. (China TST 2016) A point in the coordinate plane is called rational if
its coordinates are rational numbers. Given a positive integer n, can we
color all rational points using 11. colors such that
a) each point receives one color;
b) any line segment Whose endpoints are rational points contains rational
points of each of the n colors?
16.
(China TST 2010) Let k > 1 be an integer and let n = 2k+1. Prove that
for any positive integers (11 < a2 < ... < an, the number H19<a(a,-+
aj) has at least k + 1 different prime divisors.
Legendre’s formula
17. (Komal) Which binomial coefficients are powers of a prime?
18. Prove that (2:) | lcm(1, 2, . . . ,2n) for all positive integers n.
19. Prove that for all positive integers n and all integers a we have
1
mm” — 1)(a" — a)...(a" — an—1)E Z.
20. Prove that if k < n then
”(12; 1) |lcm('n,,n — 1, ...,n — k).
21. (Mathematical Reflections S 206) Find all integers n > 1 having a prime
factor p such that vp(n!) | n — 1.
6.4. Problems for practice
389
22 . (Romania TST 2015) Let k be an integer greater than 1. When n runs
through the integers greater than or equal to k, what is the largest
number of divisors of (2) that belong to {n — k + 1, n — k: + 2, ..., n}?
23. (Mathematical Reflections 0 285) Define a sequence (an)n21 by (11 = 1
and an+1 = 2"(2“" — 1) for n 2 1. Prove that n! | an for all n 2 1.
24. (China 2015) For which integers k are there infinitely many positive
integers n such that n + k does not divide (2:)?
25. (Romania TST 2007) Find all positive integers x, 3; such that
x2007 _ 312007 = x! _ y!.
26. a) Prove that for all n 2 2 we have
02 ((4212) — (—1)“(2:)) = 3201) + 2 + 30201),
where 3201) is the sum of the digits in the base 2 expansion of n.
b) (AMM E 2640) Find the exponent of 2 in the prime factorization of
the number
2n+1
2n
( 2. ) - (2.-.).
27. (China TST 2016) Define a function f : N —) Q* as follows: write a
positive integer n = 2km with k 2 0 and m odd, and set f (n) = ml‘k.
Prove that for all n 2 1 the number f (1) f(2) f(n) is an integer divisible
by any odd positive integer not exceeding n.
28. (IMO Shortlist 2014) If :1: is a real number, we denote by ”x” the distance
between :1: and the nearest integer. Prove that if a, b are positive integers,
then we can find a prime p > 2 and a positive integer k such that
a
F
+113!l
pk
a+b
pk
“=1.
390
Chapter 6. p-adic valuations and the distribution of primes
29. (Erdos-Palfy-Szegedy theorem) Let a, b be positive integers such that
the remainder of a when divided by any prime 1) does not exceed the
remainder of b when divided by p. Prove that a = b.
Estimates for binomial coefficients and the distribution
of prime numbers
30. Prove that there exist two consecutive squares such that there are at
least 2000 primes between them.
31. A finite sequence of consecutive positive integers contains at least one
prime number. Prove that the sequence contains a number that is relatively prime to all other terms of the sequence.
32. Prove that 2pn+1 2 pn + pn+2 for infinitely many n, where pn is the nth
prime.
33. (AMM) Find all integers m, n > 1 such that
1! - 3! ~
~ (2n— 1)! = m!.
34. (EMMO 2016) Let a1 < a2 <
be an infinite increasing sequence of
positive integers such that the sequence (1;?) is bounded. Prove that for
infinitely many 17. the number an divides lcm(a1, ..., an_1).
35. Does the equation 9:! = y!(y + 1)! have infinitely many solutions in positive integers?
36. (Richert’s theorem) Prove that any integer larger than 6 is a sum of
distinct primes.
37. (China TST 2015) Prove that there are infinitely many integers n such
that n2 + 1 is squarefree.
38. (USAMO 2014) Prove that there is a constant c > 0 with the following
property: if a, b, n are positive integers such that gcd(a + i, b + j) > 1
for all i,j E {0, 1, . . . n}, then
2
min{a, b} > c" - n 2 .
6.4.
Problems for practice
391
39. (Mertens) Prove that for all n > 1
—6 < 2 E — lnn < 4.
psn
40. (Mertens) Prove that the sequence (an)n22 defined by
an = Z l — lnhln
11571 p
is bounded, Where the sum is over all primw not exceeding n.
Chapter 7
Congruences for composite
moduli
The goal of this chapter is to make a more detailed study of Euler’s totient
function and its applications to congruences for composite moduli. The first
section deals with the Chinese remainder theorem, which we use to explain
how to reduce polynomial congruences for composite moduli to congruences for
primes and powers of primes (which was the subject of the previous chapter).
We then establish Euler’s theorem and give many applications. Finally, we
discuss the important notion of order modulo n and that of primitive roots
modulo n.
7.1
7.1.1
The Chinese remainder theorem
Proof of the theorem and first examples
The Chinese remainder theorem is a very useful result allowing one to find
solutions to systems of linear congruences whose moduli are pairwise relatively
prime. It is a. very powerful tool in constructive problems. Roughly speaking,
it says that congruences modulo (1 and modulo b are unrelated as long as a
and b are relatively prime. The precise statement is the following.
394
Chapter 7. Congruences for composite moduli
Theorem 7.1. Let m1,m2,...,m,c be pairwise relatively prime integers and
let a1,...,a;c be arbitrary integers. Then the system of congruences a: E a1:
(mod mi), 1 S i S It has solutions, and these solutions form an infinite arithmetic progression with common difierence m1...m;c (in other words, any two
solutions difi’er by a multiple of m1...mk).
Proof. For eachi 6 {1,2, ...,k} we have gcd(m,-, Hfii mj) = 1, thus there is an
integer hi such that k1- - Hjaéimj E 1 (mod mi). Setting 93¢ = k2,- - [Ia-#- mj, we
have :13,- E 5z’j (mod mj) for 1 S i,j S k, where by = 1 ifi = j and 6121' = 0 if
1'75 3'. But then a: = alwl +
+ akxk satisfies a: E ai (mod mi) for 1 S i S k,
finishing the proof of the existence part.
Next, fix a solution mo of the system. Any other solution a: satisfies a: E
az- E 1:0 (mod mi) for 1 S i S k. Thus m1, ...,mk divide a: — x0 and since
they are relatively prime, we deduce that m1...m;c I a: — :30. Thus any two
solutions differ by a multiple of m1...mk. Conversely, if m1...m;c | :r — 930, then
m1, ...,mk all divide x — x0 and so a: is also a solution. Thus the solutions
form an infinite arithmetic progression with common difference m1...mk and
III
the result follows.
We continue with a long series of examples illustrating the Chinese remainder theorem. The condition that m1, ..., mk are pairwise relatively prime may
seem too strong in theorem 7.1. Note however that if 51:, a1, ..., ak,m1, ..., mk
are integers satisfying a: E a; (mod mi) for 1 S i S k, then necessarily
gcd(mi,mj) divides ai — a,- = (:1: — aj) — (a: — ai) for all 1 S i,j S k. The
next example states that this necessary condition is also suflicient, thereby
establishing the optimal form of the Chinese remainder theorem.
Example 7.2. If a1, a2, ...,ak are integers and m1, m2, ...,mk are positive inte-
gers such that ai E aj (mod gcd(mi,mj)) for all 1 S i, j S k, then there are
integers a: such that a: E a,- (mod mg) for 1 S i S k.
Proof. The result is clear if m1m2...m;c = 1, so assume that this is not the
case and let p1, ..., pn be the different prime factors of m1m2...mk. For each i,
choose j (i) such that
”Pi (mj(i)) = max(vpi(m1)1 '"i ”pi (77746))
7.1.
The Chinese remainder theorem
395
and let si = 121,1. ("77(0)By the Chinese remainder theorem we can find a: such that a: E am)
(mod pf‘) for all 1 g i g k. We claim that a: is a solution, which comes down
to proving the inequality
”Pi (53 _ al) 2 ”Pi (ml)
for 1 S l S k and 1 S i S 17.. By hypothesis gcd(mz,mj(i)) divides a; — am),
thus
”Mal — aj(i)) 2 ”pi(30d(ml, mm)» = ”1247711)It follows that
”Pi (:1: _ al) 2 min(”pi (:L' _ aj(i))’vpi(aj(i) “ 04)) Z min(51"vpi (7774)) = ”105(ml)
[I
and we are done.
We continue with some constructive problems in which the Chinese remainder theorem plays a key role.
Example 7.3. (Czech-Slovak 2008) Prove the existence of a positive integer n
such that for all integers Is, all prime divisors of k2 + k + n are greater than
2008.
Proof. Let p1, ..., pk be all primes not exceeding 2008. We deal first with each
pi, proving that we can find n such that the congruence k2 + k + n E 0
(mod pi) has no solutions. If pi = 2, simply choose n = 1, so suppose that
pi > 2. Choose a quadratic non-residue a modulo p,- and pick 12 such that
477,— 1 E —a (mod pi) (which is possible since pi is odd). Then the congruence
k2 + k + n E 0 (mod pi) has no solutions, since any solution would satisfy
(2k + 1)2 E —(4n — 1) E a (mod pi), contradicting the choice of a. Thus we
can find for each 2' an integer ni such that the congruence k2 + k + m- E 0
(mod pi) is not solvable. The Chinese remainder theorem shows that we can
find n congruent to m modulo pi for all 1 g 13 S k, and such n satisfies all
requirements by construction.
El
Example 7.4. (Russia 1995) Is there a permutation a1,a2,
positive integers with the property that a1 + a2 +
all n 2 1?
of the set of all
+ an is a multiple of n for
396
Chapter 7. Cong'ruences for composite moduli
Proof. We will prove that the answer is positive by inductively constructing
such a sequence. Define a1 = 1 and assume that 0.1, ..., ak have already been
defined. We will define next ak+1 and ak+2. Let ak+2 be the smallest positive
integer different from a1, ..., (11,. Next, choose ak+1 different from an, ..., ah, ak+2
such that ak+1 E —(a1+...+ak) (mod k+1) and ak+1 E —(a,1+...+ak+ak+2)
(mod 19 + 2). The existence of such a number is a consequence of the Chinese
remainder theorem. Note that by construction the sequence a1, a2,
all requirements.
satisfies
III
Example 7.5. (Baltic 2006) Is there a sequence a1, a2, a3, . . . of positive integers
such that the sum of every 71. consecutive elements is divisible by n2 for every
positive integer n?
Proof. We will construct the sequence inductively. Set a1 = 1 and suppose
that a1, ...,ak have already been constructed. For 1 S i g k let b,- = (7} + 1)2
and c, = —ak —ak_1 — —ak_,-+1. Note that ifz' < 3', then Cj —q is the sum of
j —z' consecutive terms of the sequence a1, ..., ak, hence a multiple of (j — i)2,
which itself is a multiple of gcd(b,-, bj). By example 7.2 we can find a positive
integer ak+1 such that ak+1 E 0,- (mod bi) for 1 S i g k. Now any sequence
of j 6 {1,2, ...,k + 1} consecutive elements of the sequence a1, ...,ak+1 is a
multiple of 3'2, so the inductive step is proved.
D
We end this section with some more challenging examples.
Example 7.6. (Russia 2008) Find all positive integers n with the following
property: there are positive integers b1, b2, ..., bn, not all equal and such that
the number (b1 + k) (b2 + k)...(bn + k) is a power of an integer for each natural
number k. Here, a power means a number of the form :3” with w, y > 1.
Proof. If n is composite, say n = ab with a, b > 1, then we can choose bl =
b2 =
= ba = 1, then ba+1 =
= bza = 2 and all the other bi’s equal to 1.
Then for any k we have
(b1 + k)(b2 + k)...(bn + k) = (k + 1)“(k + 2)“(k + 1)“(b—2),
which is a power.
7.1.
The Chinese remainder theorem
397
Suppose now that n is a prime and that b1, ...,bn satisfy the conditions
of the problem. Let 61,02, ...,cN be the set of distinct numbers among
b1, b2, ..., bn, with multiplicities m1, m2, ..., mN. By assumption, we have N > 1
and clearly n = m1 + mg +
+ mN. Moreover, for any k, the number
(c1 + k)m1(02 + k)m2...(cN + k)mN is a perfect power. The key point is to
choose numbers It for which we can find distinct primes p1, p2, ..., pN such that
vp,(cj + k) = 1 if i = j and 0 otherwise. In this case, if
(cl + k)m1(02 + k)m2...(cN + k)mN = cry
for some cc, y > 1, we have yvp,(a:) = m, so that y divides all mi. But then
y divides their sum, which is n and since n is a prime, it follows that n = y.
Thus n = y will divide all m,- and this obviously contradicts the fact that
N> 1 and m1+m2+...+mN=n.
Thus, we are done if we can find distinct primes p1,p2, ...,pN and k such
that vpi(cj + k) = 1 if i = j and 0 otherwise. This is very simple: first, we
choose some distinct prime numbers p1,p2, ...,pN, sufficiently large, say not
dividing any of the numbers q — cj with i aé j and then choose k such that
k+ci E 1),- (mod p?) for all z'. Such It exists by the Chinese remainder theorem.
Of course, up, (k+c,') = 1 and for j aé i we cannot have pil‘l'k, since otherwise
p,- would divide c,- — Cj, contradicting the choice of p¢.Thus, such It satisfies all
desired conditions and the answer to the problem is: precisely the composite
numbers.
[I
Example 7.7. (IMO Shortlist 2014) Let a1 < (12 < . . . < an be pairwise
relatively prime positive integers with on being prime and a1 2 n + 2. On the
segment I = [0, a1a2 . . . an] of the real line, mark all integers that are divisible
by at least one of the numbers (11, a2, ..., an. These points split I into a number
of smaller segments. Prove that the sum of the squares of the lengths of these
segments is divisible by (11.
Proof. Let 0 = b0 < b1 <
< b; = alaz...a.n be all marked integers, thus we
need to understand (b1 — be)2 + (b2 — b1)2 +
+ (b; — bl_1)2. We start by
finding a more manageable expression.
Call an interval J admissible if it is a closed (nontrivial, i.e. not reduced to a point) sub-interval [a, b] of [0,a1...an] and there are no marked
Chapter 7. Congruences for composite moduli
398
points in the open interval (a, b). Let N be the number of admissible intervals. Consider now pairs (I, J), where I is an interval among
[b0, b1], [b1, b2], ..., [bl_1, bl] and J is an admissible interval contained in I. Since
the intervals [bo,b1], [b1,b2], ..., [b;_1,b;] have no common interior points and
cover [0, alman], for each admissible interval J there is a unique pair (I, J)
attached to J, thus there are N such pairs. On the other hand, if we fix an
interval I among [b0, b1], [b1, b2], ..., [bl_1,b1], say I = [bi, bi+1] for some i, then
clearly the admissible intervals contained in I are all intervals of the form [m, y]
with b, S :1: < y S b¢+1, and there are (““31”“) such intervals. Therefore, a
double count of the pairs (I, J) reveals the crucial identity
Ei<bi+l—bi+l) =N
i=0
or equivalently
2
1—1
20154.1 — 11,92 = 2N — a1...an.
i=0
It is therefore sufficient to prove that N is a multiple of a1. The advantage is
that N is rather easily understood.
Since an admissible interval contains no multiple of al in its interior, the
length of the interval cannot exceed (11. Let us fix now d e {1, 2, ...,a1} and
count the admissible intervals of length d. In other words, we need to find the
number of integers to E {0, 1, ..., alman — d} such that (3:, cc + d) contains no
multiple of any of the numbers a1, ...,an. Note that this is the same as the
number of a: E {0, 1, ..., a1 man—1} with the same property. Such a: is a solution
if and only if its remainder when divided by (1, belongs to {0,1, ..., a, — d} for
all 7}. Since the numbers 04, ..., a," are relatively prime, the Chinese remainder
theorem implies that the number of such :1: is
M) = fist—d“).
i=1
Thus
N = £13011 + 1 — d)(a,2 + 1 — d)...(an + 1 — d).
d=1
7.1.
The Chinese remainder theorem
399
Since the polynomial H?=1(a, + 1 —X) has degree n < a1 — 1 and a1 is a prime,
corollary 5.77 yields
ihtl + 1 — d)(a2 + 1 — d)...(o.n + 1 — d) E 0
(mod (11),
(1:1
proving therefore that al | N and finishing the proof.
El
Example 7.8. (USA TST 2012) A function f : N —) N has the property that
gcd(f(m), f(n)) = 1 whenever gcd(m, n) = 1, and n S f(n) S n+2012 for all
n. Prove that if n > 1 then any prime divisor of f (n) is a prime divisor of 77..
Proof. We start by proving that f has many fixed points, more precisely we
prove the existence of an infinite sequence 1 < 31 < 3'2 <
of pairwise relatively prime integers such that f (jk) = jk for all k. Consider the sequence (on)
defined by a1 = 2013! + 1 and a,“ = oi! + 1 for i 2 1. Then clearly a1,a2,
are pairwise relatively prime, so f(a1), f (a2),... are also pairwise relatively
prime. Since 0 S f(a,-) —a,- S 2012 for all 1;, there is k e {0,1,...,2012} and an
infinite sequence 2'1 < 112 <
such that flail) — ail = f(a,-2) — a,-2 =
= k.
Since k + 1 | a, — 1 = «15.1! for 2’ 2 2 (note that a,- > 2013 for all j), we have
k + 1 | oi]. + k = f(a,-J.) for all j 2 2. Since f(a,-2) and f(a,-3) are relatively
prime, this forces k = 0 and so we can take jl = ail, j2 = aiz, ..., establishing
the desired result. Note that since jl, jg,
are pairwise relatively prime, for
any N > 1 there are infinitely many k such that gcd(jk, N) = 1.
Let now n > 1 and let p be a prime factor of f (n) Suppose that 10 does
not divide n. By the previous paragraph we can find pairwise relatively prime
numbers q1 <
< q2012 which are relatively prime to pn - 2012! and satisfy
f (q,-) = q,- for 1 S i S 2012. By the Chinese remainder theorem there is an
integer a > 1 such that a E 0 (mod p), a E 1 (mod n) and a E —2' (mod q,-)
for 1 S 2' S 2012. Since gcd(a, n) = 1 and p | gcd(a,, f(n)), we cannot have
f(a) = (1, thus f(a) = a +2" for some 1 g 2' g 2012. Then
gcd(f(q,-), f(a)) = gcd(q,-,a + i) > 1,
which gives gcd(q,~, a) > 1. Combined with the congruence a E —2' (mod qi),
this yields gcd(q,-, 'L') > 1, which is impossible since gcd(q,-, 2012!) = 1. Thus p
must divide n and the result follows.
III
400
Chapter 7. Congraences for composite moduli
7.1.2
The local-global principle
The next theorem is very useful in practice: it shows that in order to solve
polynomial congruences f (:12) E 0 (mod n) it suflices to understand the case
when n is a power of a prime, which we have already dealt with in chapter 4.
Theorem 7.9. Let f be a polynomial with integer coefficients. If n is a positive
integer, let
A(n) = {x E {0,1,...,n — 1}|
f(.’1:)E 0 (mod 71)}.
If m1, ..., mk are pairwise relatively prime positive integers, then the map1
A(ml...mk) —> A(ml) x
x A(mk),
a: I—> (x (mod m1), ...,a: (mod mk))
is bijective. In particular, A(ml...mk) is nonempty if and only if A(mi) are
nonempty for 1 S i S k, in which case
|A(m1-..mk)l = |A(m1)| -
- |A(mk)l-
Proof. Let n = m1...mk. Note that if f (:13) E 0 (mod n) and r,- E a: (mod mi)
then 0 E f(:c) E f(r,~) (mod mi), thus rz- e A(mi) and the map, call it f,
from the statement of the theorem is well-defined. Let us prove its injectivity.
If a:,y E A(n) have the same image through f then a: E y (mod mg) for
1 S i S k. Since m1, ..., mk are pairwise relatively prime, we deduce from the
Chinese remainder theorem that a: and y are congruent modulo n = m1...mk.
Since :r,y E {0, 1, ...,n — 1} we conclude that a: = y.
Let us prove now surjectivity. Let :13,- E A(mi), we need to prove the
existence of x E A(n) such that :1: (mod mi) = .73.; for 1 S i S k. By the
Chinese remainder theorem we can find a: e {0, 1, ..., n — 1} such that :1: E :3,(mod mi), thus :1: (mod m,-) = :12,- for 1 g i S k. Since a: E at,- (mod mi)
and m,- E A(mi) we have f(:r) E f(x,~) E 0 (mod m,) for 1 S i _<_ k. Using
again that m1, ...,mk are pairwise relatively prime, we deduce that f(:1:) E 0
(mod n) and so a: e A(n), as desired.
E]
The following result is an immediate consequence of the previous theorem,
but we state it explicitly since it is very important in practice.
1Here :1: (mod N) denotes the remainder of a: when divided by N
7.1.
The Chinese remainder theorem
401
Corollary 7.10. Let f be a polynomial with integer coefficients and let n > 1
be an integer, with prime factorization n = plfl...p’§3. The number of solutions
of the congruence f (x) E 0 (mod n) is the product of the number of solutions
of the congruences f(a:) E 0 (mod pg“), 1 S i S 3.
Example 7.11. Let n be an integer greater than 1. Find the number of integers
w E {0, 1, ...,n — 1} such that
a) 3:2 E a: (mod n).
b) x2 E 1 (mod n).
Proof. a) We first consider the case when n is a power of a prime, say n = pk
for some prime p and some k 2 1. Then x2 E a: (mod n) is equivalent to
pk | ac(:r — 1). Since :5 and a: — 1 are relatively prime, this can only occur when
either pk | cc or p’6 | x — 1. In other words, in this case the congruence has
exactly two solutions: 0 and 1. Corollary 7.10 then shows that in general the
congruence x2 E a: (mod n) has 2" solutions, where s is the number of distinct
prime factors of n.
b) Similarly, we start with the case n = pk, in which case we need to
understand the divisibility p" | (a: — 1)(a: + 1). If p > 2 then p cannot divide
both a: — 1 and a: + 1 thus we must have pk | a: — 1 or 19" I a: + 1, giving two
solutions (a: = 1 and a: = pk — 1) of the congruence. Suppose now that p = 2.
If k = 1 then we have one solution, a: = 1, if k = 2 we have two solutions
a = 1 and w = 3, so assume that k 2 3. Then a: must be odd and one of a: — 1,
:c + 1 must be a multiple of 2k‘1 since gcd(a: — 1, a: + 1) = 2. We then obtain 4
solutions: a: = 1, 2’“1 + 1, 2k — 1, 2’“1 — 1. In conclusion, using corollary 7.10,
we deduce that for n = 2°‘p’f1...pf‘ with p1, ..., p, pairwise distinct odd primes
and k,- 2 1 (but we allow 3 = 0)
o if a S 1 then the congruence has 23 solutions.
0 if a = 2 the congruence has 2"3+1 solutions.
0 if a 2 3 the congruence has 2"+2 solutions.
III
Example 7.12. Prove that the number of solutions of the congruence x2 E —1
(mod n) is
a) 0 if4 | n or ifp | n for some primep E 3 (mod 4);
b) 28 otherwise, where s is the number of different odd prime divisors of n.
402
Chapter ’7. Congmences for composite moduli
Proof. Part 3.) follows directly from corollary 5.28. For part b), by corollary
7.10 it suffices to deal with the case n = pk for some prime p E 1 (mod 4) and
some k 2 1. In this case we need to prove that the congruence has exactly two
solutions. The case k = 1 follows easily from theorem 5.55, and the general
case follows from Hensel’s lemma: each solution of the congruence x2 E —
(mod p) uniquely lifts to a solution of the congruence 2:2 E —1 (mod p"). El
Example 7.13. Find all integers n > 1 for which we can find integers a, b such
that
a2+b2+1E0
(modn).
Proof. Since x2 E 0, 1 (mod 4) for any integer 2:, the number a2 + b2 + 1 is
never divisible by 4. Thus a solution 22 of the problem is not divisible by
4. Conversely, we will prove that if n > 1 is not a multiple of 4, then the
congruence a2 + b2 + 1 E 0 (mod n) has solutions. Write n = 25 - pfl...p§‘ for
some e 6 {0,1}, some pairwise distinct primes 2, p1, ..., p8 and some integers
61,...,es 2 0. If there are integers ao,bo,...,as,bs such that (13+ b3 + 1 E 0
(mod 28) and a? + b? + 1 E 0 (mod p?) for 1 S 2 S s, then the Chinese
remainder theorem gives us integers a,b such that a, E (10 (mod 2‘5),a E a,-
(mod p?) for 1 g 2' S s and similarly b E b0 (mod 2e),b E b,- (mod pf‘) for
1 g 2' S 3. Then clearly a2 + b2 + 1 E 0 (mod n). Thus we may assume that
n is a power of a prime p, and n 6 {1,2} ifp = 2. The case p = 2 being clear,
assume that n = pk with p > 2 and k 2 1. We can find a,b E {0, 1, ..., %1
such that a2 E —(b2 + 1) (mod p) (since the sets {a2 (mod p)|0 S a S %1}
and {(b2 + 1) (mod p)|0 S b S %1} have %1 elements each, and there are
p < 1%; + L31 remainders modulo p). Thus the congruence a2 + b2 + 1 E 0
(mod p) has solutions. Choose a solution (a0, be) with gcd(p, a0) = 1 (we may
always achieve this, possibly by permuting a0 and b0). Choose any integer b
that is congruent to bo modulo p. Hensel’s lemma applied to the polynomial
f (X) = X2 + b2 + 1 shows that the solution 0.0 modulo p of the congruence
f (as) E 0 (mod p) lifts uniquely to a solution a modulo pk of the congruence
f(x) E 0 (mod pk). Thus the congruence a2 + b2 + 1 E 0 (mod pk) has
solutions, and we are done.
El
7.1.
The Chinese remainder theorem
403
Example 7.14. (generalization of IMO Shortlist 1997) Let m,n > 1 be relatively prime integers. An infinite arithmetic progression of integers contains
an mth power and an nth power. Prove that it also contains an mnth power.
Proof. Let (a + 3203-20 be the arithmetic progression. By assumption the
congruences 23"” E a (mod d) and y" E a (mod d) have solutions, and we
need to prove that the congruence 2’“ E a (mod d) also has solutions. Using
theorem 7.9, we may assume that d = pk for some prime p and some positive
integer k. Choose integers (3,3; such that mm E a (mod pk) and y" E a
(mod pk). If a is a multiple of pk, simply take 2 = 0, so assume that vp(a) < k.
Since mm E a (mod pk), it follows that mvp(a:) = vp(a:m) : vp(a). Similarly
nvp(y) = vp(a). Thus m and n divide vp(a) and hence mn also divides vp(a)
(as m and n are relatively prime).
Write vp(a) = mnt for some integer t, thus vp(a:) = nt and vp(y) = mt.
Since mm E a (mod pk), we deduce that w,—“,,; is an mth power modulo pk‘mm.
Similarly, W—“n; is an nth power modulo pk‘mnt. So, it suffices to prove the
following lemma in order to conclude.
Lemma 7.15. Let m,n be relatively prime, let p be a prime number and let
N 2 1. If a: is relatively prime to p and is an mth power and an nth power
modulo pN, then it is also an mnth power modulo pN .
The proof of the lemma is very simple: choose integers a,b such that
a: E am (mod pN) and :c E b” (mod pN). Now am E b” (mod pN), hence
am" E b“” (mod pN) for all u 2 1. By Bezout’s lemma we can find u such
that an E 1 (mod m). The previous congruence shows that b must be an mth
power modulo pN, and so a; E b" (mod pN) is an mnth power.
III
Example 7.16. Consider the polynomial f(X) = (X2 + 3) (X2 — 13) (X2 + 39).
Prove that the congruence f (cc) E 0 (mod n) has solutions for all integers
n > 1.
Proof. By corollary 7.10 we may assume that n is a power of a prime, say
n = pk. Assume first that k = 1 and let us prove that at least one of the
congruences x2 E —3 (mod p), x2 E 13 (mod p) and x2 E —39 (mod p) has
solutions. This is clear if p = 3 or p = 13, so assume that gcd(p, 39) = 1. If
404
Chapter ’7. Congruences for composite moduli
neither of these congruences has solutions, we obtain ($0 = —1, (1,531) = —1
and ("739) = —1, contradicting the multiplicative character of Legendre’s
symbol (theorem 5.101), which gives (#39) = (773) - (1173). This settles the
case k = 1.
Assume now that k > 1 and p 7e 2, 3, 13. By Hensel’s lemma any solution
we of the congruence x2 E a (mod p) with a E {—3, 13, —39} lifts uniquely to
a solution of the congruence 9:2 E a (mod pk) (note that 2160 is not divisible
by p by our hypothesis on p). Thus we are done in this case. It remains to
deal with the cases p = 2,3, 13. If p = 3 we can use Hensel’s lemma to lift
the solution a: = 1 of the congruence x2 E 13 (mod 3) to a solution of the
congruence x2 E 13 (mod 3"). We deal similarly with the case p = 13, by
lifting via Hensel’s lemma the solution a: = 6 of the congruence 9:2 + 3 E 0
(mod 13). Finally, we have to deal with the case p = 2. We prove by induction
the existence of a sequence 33,, such that 2nlx3, + 39. Take 121 = 1, 932 = 1 and
923 = 1. Assuming that 92?, + 39 = 2” - k for some integer k and n 2 3, we have
(2n‘1m + 3%)2 + 39 = 2"(a:a:n + k) (mod 2””). If k is even set xn+1 = awn,
otherwise set x = 1 and so xn+1 = 93,, + k. Note that the case p = 2 could also
have been treated using example 5.170(b), where we saw that the congruence
x2 E a (mod 2") has solutions for all n if a. E 1 (mod 8). Applying this to
a = —39 solves this case.
El
The next example is a variation on the proof of theorem 7.9.
Example 7.17. (AMM E 2330) Let f : N —> Z be a function such that a. — b |
f (a) — f (b) for all positive integers a, b. Let a(n) (respectively b(n)) be the
number of terms of the sequence f (1), f(2), ..., f (n) which are multiples of n
(respectively relatively prime to n). Prove that a, b : N —> Z are multiplicative
functions and
b(n)=nH( 417(9).
pln
Proof. We start with a simple but crucial observation.
Let m,n be rela-
tively prime integers and consider j E {1,2,...,mn}. Let u e {1,2,...,n}
and v 6 {1,2, ...,m} be the unique integers for which j E u (mod n) and
j E 7) (mod m). Then mn divides f(j) if and only if n | f(u) and m I f(v).
7.1.
The Chinese remainder theorem
405
Indeed, mn divides f(j) if and only if m | f (j) and n | f (j), which happens if
and only ifm | flu) and n | f(u) (since f(j) E f(v) (mod m) and f(j) E f(u)
(mod n) by assumption).
Next, let
A = {u 6 {1,2, ---,n}l n | f(U)}, B = {v 6 {1,2, --.,m}l m | NIHFor each (u,v) E A X B there is a unique integer j('u,v) 6 {1,2, ...,mn} such
that j (u, v) E u (mod n) and j (u, v) E 1) (mod m), by the Chinese remainder
theorem. By the previous paragraph, the numbers j(u, v) with (u, 1)) running
through A x B are exactly the integers j 6 {1,2, ...,mn} such that mn | f (j),
yielding a(mn) = a(m)a(n).
_
Next, for each prime divisor p of n let Ap be the set of numbers j 6
{1,2, ..., n} such that p | f(j ) The inclusion—exclusion principle yields
b<n>=n—IuplnApI=n—ZIAPI+ Z lq|+m
pln
meal”
If d is a positive divisor of n, then for each s 2 0 there are a(d) integers k
between sd + 1 and (s + 1)d for which d | f(Is) (this follows from the definition
of a(d) and the fact that d | f(j) if and only ifd | f(Uj), where Uj 6 {1,2, ...,d}
is the unique integer congruent to j modulo d). Thus there are %a(d) integers
j 6 {1,2, ...,n} such that d | f(j). Thus ifp1,...,p5 are pairwise distinct prime
divisors of n then
n
lApln-Psl =
n
p1---psa(pl"'p3) = p1...psa(p1)'"a(ps)
which combined with the previous formula for b(n) yields
b(n) = 11]] (1 — M).
pl"
p
It is clear from this last formula that n I—) b(n) is multiplicative.
E!
The result established in the previous example is fairly useful, as the following two examples show.
406
Chapter ’7. Congruences for composite moduli
Example 7.18. Prove that for any integer n > 1 the number of integers a E
{1, 2, .., n} such that a and a+1 are both relatively prime to n is n ln (1 — 12,).
Proof. Take f (as) = a:(:c + 1) and apply example 7.17. For each prime p there
are exactly 2 integers k 6 {1,2, ...,p} such that p I f(k), namely k = p— 1 and
k = 19, thus with the notations of example 7.17 we have a(p) = 2 for all primes
p. The result follows.
[I
Example 7.19. (Menon’s identity) Prove that for any integer n > 1
Z gcd(n, ’6 - 1) = ¢(n)7(n)-
13kg»
(k,n)=1
Proof. Using Gauss’ theorem 4.112 we obtain
2 gcd(n,k—1)= Z
Z
<P(€)=Z<P(€) Z 1=Z<p(e)|3(e)l,
ISkSn
ISkSn e|gcd(n,k—1)
(k,n)=1
(k,n)=1
e|n
kES(e)
eIn
where S(e) is the set of integers k E {1, ...,n} which are relatively prime to
n and satisfy k E 1 (mod 6). It suflices to prove that S(e) has $3 elements
for all e | n. Fix such 6 and note that 8(a) is in bijection with the set of
:1: 6 {0,1,...,% — 1} for which 1 + we is relatively prime to n (simply set k =
1 + we) or equivalently 1 + (1:6 is relatively prime to 2. Applying example 7.17
to f(:z:) = 1 + me with 2 instead of n and noting that the number of multiples
of p among f (1), ..., f (p) is 1 when p does not divide e and 0 otherwise, we
obtain
_n
1
_n Hp|n(1—l)_cp(n)
gcd(p,e)=1
as desired.
III
We end this section with a more difficult result, which is also quite useful
in practice.
7.1.
The Chinese remainder theorem
407
Theorem 7.20. If an integer a is a quadratic residue modulo all sufficiently
large primes, then a is a perfect square.
Proof. First note that if p2 divides a for some prime p, then a/p2 will also be a
quadratic residue modulo all sufficiently large primes. Thus we may assume a
has no repeated prime factors and hence a = :l:p1p2 . . .ps for pairwise distinct
primes p1, . . . ,ps.
Suppose ps is odd. Let r be a quadratic non-residue modulo p3. By the
Chinese remainder theorem the solutions of the simultaneous congruences
qE 1
(mod 8p1 . . .ps_1),
and
qEr
(mod p3)
form an infinite arithmetic progression m+8p1...psZ for some integer m. Clearly
gcd(a:, 8p1...p3) = 1 and so by Dirichlet’s theorem this arithmetic progression
contains infinitely many primes q. Since such a prime q is 1 modulo 8 by
construction, we have (%) = 1. Also (—1)(‘="‘1)/2 = 1, so the quadratic
reciprocity law gives (32-11) = (5%), which equals 1 if i 75 s and —1 for i = 3.
Thus
<2) = (E)ne =
3
q
‘1
i=1
‘1
contradicting the choice of a.
Thus a has no odd prime factors and hence a = :|:1 or :|:2. However if q
is a large prime congruent to 3 modulo 8, then (L1) = (3) = —1, and if q
q
is 5 modulo 8, then
‘72
q
= —1. Thus the only possibility is a = 1. Since we
only cancelled off squares of primes, it follows that our original a was a perfect
square.
El
Example 7.21. A quadratic polynomial f with integer coefficients has the prop-
erty that for any prime p the congruence f (n) E 0 (mod p) has at least one
solution. Prove that f has a rational root.
Proof. Writing f (X) = aX2 +bX + c, we need to prove that A := b2 — 4ac is a
perfect square. Let p be any prime and let n be an integer such that f (n) E 0
(mod p), then
A E 4af(n) + A = (2an + b)2 (mod p)
408
Chapter 7. Congruences for composite moduli
and so A is a quadratic residue modulo p. The result follows then from theorem
7.20.
CI
Example 7.22. (Mathlinks Contest) Nonnegative integers a1, a2, . . . ,a2004 have
the property that af+a3+0 0 -+a’2‘004 is a perfect square for all positive integers
n. What is the least number of terms of the sequence a1, a2, ..., (12004 that are
equal to 0?
Proof. Suppose that b1, ..., bk are positive integers such that b’f +b§z +. . . +bz is
a perfect square for all 71.. If p is a prime not dividing b1b2...bk, then Fermat’s
little theorem gives
b€_1+b’2’_1+...+bfi_lak (modp)
and the left-hand side is a perfect square, thus 16 is a quadratic residue modulo
p. It follows from theorem 7.20 that k is a perfect square. Since the greatest
perfect square smaller than 2004 is 442 = 1936, there must be at least 2004 —
1936 = 68 zeros in the sequence (11, ..., (12004. To see that this is optimal, simply
take a1 =
= a1936 = 1 and the other terms equal to 0.
El
7.1.3
Covering systems of congruences
We discuss in this section a topic closely related to the Chinese remainder
theorem, that of covering systems of congruences. These were introduced
by Erdos in order to give an explicit construction of an infinite arithmetic
progression of positive integers none of whose terms can be written in the
form 2’“ + p with k; 2 0 and p a prime number. This problem has a quite
long history: de Polignac conjectured in 1849 that any odd integer n > 1
can be written n = 2" + p with k 2 0 and p either a prime number or equal
to 1. This conjecture turns out to be false, for instance 127 and 905 are
counterexamples. Using covering systems of congruences and a very clever
application of the Chinese remainder theorem, Erdos constructed an explicit
infinite arithmetic progression all of whose terms are counterexamples to de
Polignac’s conjecture (it was known previously, thanks to work of van der
Corput, that a positive proportion of the odd integers are counterexamples).
7.1.
The Chinese remainder theorem
409
We will discuss his construction in this section, as well as some other results
related to covering systems of congruences.
If a and n are integers with n > 1, we write
a+nZ={a+na:|:r€Z}
for the infinite arithmetic progression consisting of numbers congruent to a
modulo n. In other words a + 122 is the residue class of a modulo n.
Definition 7.23. A covering system is a finite collection of arithmetic progressions a1 + a,...,a;c + nkZ, with 0,1,...,a,yc E Z and n1,...,nk > 1, such
that
Z = Uf=1(ai + n¢Z).
The numbers n1, ..., nk are called the moduli of the covering system (note that
we impose the condition n1, ...,nk > 1 to avoid trivial considerations in the
sequel).
A trivial covering system of congruences is obtained as follows: choose
any N > 1 and consider the arithmetic progressions (i + NZ)1S,-SN. This is
certainly not very impressive, so let us give a few other examples:
a) An interesting covering system with distinct moduli (and smallest mod-
ulus 2) is
2Z, 3Z, 1 + 4Z, 5 + 6Z, 7 + 12Z.
The reader will easily convince himself that this is indeed a covering system.
b) Erdos’ construction (to be given below) uses the covering system given
by
2Z,3Z,1 + 4Z, 3 + 8Z, 7 + 12Z, 23 + 24Z.
It is not difficult, although a bit tedious, to check that this is indeed a covering
system.
c) A covering system, due to Davenport and Erdos, with smallest modulus
3 and distinct moduli is given by
3Z, 4Z, 5z, 1 + ez, 6 + sz, 3 + 102, 5 + 122, 11 + 152,
7 + 20z, 10 + 242, 2 + 30z, 34 + 402, 59 + 60Z, 98 + 12oz.
410
Chapter 7. Congruences for composite moduli
d) Here is yet another example, due to Erdos:
2Z, 3Z, 5Z, 1 + 6Z, 7Z, 1 + 10Z, 1 + 14Z, 2 + 15Z, 2 + 21Z,
23 + 30Z,4 + 35Z, 5 + 42Z, 59 + 70Z, 104 + 105Z.
As the reader has already guessed, it takes a bit more work to check that these
last two examples are indeed covering systems.
Probably influenced by the previous examples, Erdos conjectured that for
any N one can find a covering system of congruences with distinct moduli
and in which the smallest modulus is greater than N. Choi constructed in
1971 a covering whose smallest modulus is 20, and one had to wait until 2006
for the construction (by Gibson) of a covering system with smallest modulus
25. In 2009 Nielsen proved the existence of a covering system with smallest
modulus 40. All this suggested that Erdos’ conjecture is true. In a spectacular
work, Bob Hough proved in 2015 the following result, which disproves Erdos’
conjecture.
Theorem 7.24. (Bob Hough) In every covering system with distinct moduli,
the smallest modulus cannot exceed 108.
There are many open problems concerning covering systems, some of which
look surprisingly innocent. For instance, the Erdos-Selfridge conjecture states
that there is no covering system whose moduli are distinct odd integers (greater
than 1).
We are now ready to present Erdés’ clever argument.
Theorem 7.25. (Erdb's) There is an infinite arithmetic progression consisting
of odd positive integers n which cannot be written as the sum of a power of 2
and of a prime number.
Proof. We will use the covering system
2Z, 3Z, 1 + 4Z, 3 + 8Z, 7 + 12Z, 23 + 24Z,
which we represent as (a, + niZ)15,-Sk (so a1 = 0, a2 = 0, a3 = 1, n1 2 2,
n2 = 3, 17.3 = 4, etc). Next, choose pairwise distinct primes p1, ..., pk such that
p,- | 2ni — 1 for all i. This is possible, for instance by using the fact that
3|22—1,7|23—1,5|24—1,17|28—1,13|212—1,241|224—1
7.1.
The Chinese remainder theorem
411
we can choose
P1 = 3,P2 = 7,173 = 5,P4 = 17,p5 = 13,106 = 241.
Using the Chinese remainder theorem, we can find an infinite arithmetic progression of (odd and positive) integers n such that
nE 1
(mod 2241), n E 2“"
(mod p,), 1 S 72 S 6.
We claim that any such integer n which is greater than 2241 + 241 is not of the
form 2k +p with k 2 0 and p a prime number. Indeed, suppose that n = 2" +p
and choose 2' such that k: E a, (mod 71,-). Then 2’“ E 2‘11" (mod 2n.- — 1), thus
2’“ E 2‘" (mod 1),). Since n E 2‘“ (mod pi), we deduce that p E 0 (mod 17,-)
and so necessarily p = pi. Since n > 2241 +241 and p,- S 241, we have R: > 241.
But then taking the equation 77. = 2’“ +1), modulo 2241 yields 1 E p,- (mod 2241),
which is certainly impossible since p, S 241.
El
The next example uses a very similar argument.
Example 7.26. (Sierpinski-Selfridge) Prove that there is a positive integer k
such that k - 2” + 1 is composite for all positive integers 72.
Proof. Let E, = 22" + 1 be the nth Fermat’s number. Write F5 = ab with
a, b > 1 (one can take a = 641, see example 2.12). Since the Fermat numbers
are pairwise relatively prime, (example 3.12), the Chinese remainder theorem
yields infinitely many positive integers k such that
k E 2
(mod F0F1F2F3F4a),
and k E —2
(mod b).
We will prove that for each n 2 0 one of the numbers a, b, F0, ..., F4 divides
k-2“+ 1. Let j = v2(n+1) and write n = s-2j — 1 for an odd number s.
We will discuss three cases. If 3' > 5, then k - 2” + 1 E —2"+1 + 1 (mod b)
and b divides F5, which divides 22‘5 — 1, which finally divides 2"1+1 — 1, hence
b | 16-2" + 1. Ifj = 5, then since a | F5, we have
k'2n+lE2n+1+1=2258+lEO (moda).
412
Chapter ’7. Congruences for composite moduli
Similarly, if j S 4, then
k-2"+IE2"+1+1=22js+1E0 (mod F,).
We are now done: simply choose k > F5 satisfying the previous congruences. Then for all n 2 0 the munber k - 2" + 1 is greater than each of the
numbers F0, ..., F4, (1, b, and divisible by at least one of them. Hence 16-2" + 1
is composite for all n and we are done.
D
Remark 7.27. a) The result established in the previous example was obtained
by Sierpinski in 1960. His approach (which is the one explained above) gave
an infinite family of solutions, namely all
k; E 15511380746462593381
(mod 2 . 3 - 5 - 17 . 257 ~ 65537 - 641 - 6700417).
In 1962 Selfridge found that 78557 - 2" + 1 is composite for all n 2 1, being
always a multiple of one of the numbers 3, 5, 7, 13, 19, 37 or 73. This is based
on the fact that
2z, 1 + 4z,3 + 9z, 15 + 18Z, 27 + 36Z, 1 + 3z, 11 + 12z
is a covering system, and on the fact that x = 78557 is a solution of the
following congruences
a: E 2
(mod 3),:r E 2
xE6
(mod 5),:1: E 9
(mod 37),.1: E 3
(mod 73),:3 E 11
(mod 7),:1; E 11
(mod 19),
(mod 13).
For instance, if n E 2Z then :1: - 2" + 1 is a multiple of 3, if n E 1 + 4Z then
:1: - 2"+ 1 is a multiple of 5,..., ifn E 11+12Z then z-2"+ 1 is a multiple of 13.
Conjecturally, 78557 is the smallest positive integer k for which k - 2" + 1 is
composite for all n (it is known that there can be at most five possible smaller
numbers).
b) We could also have proved this result using the covering system from
the proof of Erdiis’ theorem and a similar argument. Reversing the signs of
the congruences would yield infinitely many n such that for all k the number
7.1.
The Chinese remainder theorem
413
n + 2k is divisible by one of the primes 3,5, 7, 13, 17,241. But then for any
such n and any k the number
n + 2k((3—1)(5—1)(7—1)(13—1)(17—1)(241—1)—1)
is divisible by some prime p E {3, 5, 7, 13, 17, 241}, and Fermat’s little theorem
yieldsp I n - 2’“ + 1.
Example 7.28. Let (ai + mZ) be a covering system with pairwise distinct
moduli 1'L1,...,n;c > 1. Prove that the arithmetic progressions a1 + n1Z, a2 +
n2Z, ..., a}, + nkZ are not pairwise disjoint.
Proof. Assume that the progressions are pairwise disjoint and let
N = lcm(n1, ...,nk) and (N = «32%,
For each 1 gj S k let
are precisely the numbers G“, with u E aj + a. Since the arithmetic progressions a1 + n1Z, a2 + n2Z, ..., a], + nkZ are pairwise disjoint and their union is
Z, we deduce that
i
X” — 1 = P1P2...P,,, where 13,-(X): X"2' — zj.
Indeed, it follows from the above description of the roots of P1, ...,Pk that
XN — 1 and P1...P;c have exactly the same roots, with the same multiplicity,
namely 1.
> 72—13:.
> m, so that % >
By symmetry, we may assume that nk >
1
The coeflicient of X "k in the right-hand side of the equality
X
—1=(X”1 —21)-...-(X"k —zk)
414
Chapter 7. Congruences for composite moduli
A
is (—1)k‘1zl...zk_1, while the coeflicient of X "k in the left-hand side is 0.
We obtain (—1)k_121...zk_1 = 0, which is obviously impossible. The result
follows.
E
The reader will compare the next result with the one established in example
7.2.
Example 7.29. (AMM 5747) Let 1 < m <
< nk be integers and let 0 S bi <
m be integers for all 1 S 2' S k. Assuming that gcd(ni,nj) does not divide
bi — bj for all 2' 9E j, prove the existence of an integer a: which is not congruent
to bi modulo m- for all 1 S i S k.
Proof. Assume that this is not the case, so any integer :1: satisfies one of the
congruences a: E bi (mod m), in other words (bi + niZ)19-Sk define a covering
system.
Note that if 2' aé j, then so cannot satisfy simultaneously a: E b;
(mod n.) and w E bj (mod nj), for otherwise we would obtain gcd(n¢,nj) |
b.- — bj, contradicting the hypothesis. The result follows then immediately from
the previous example.
El
Example 7.30. (Erdos-Sun) A family of k arithmetic progressions
(at + niZ)1$iSk
(with ohm- integers and m > 1) has the property that Uf=1(ai + mZ) contains 2k consecutive integers. Prove that this family is a covering system of
congruences.
Proof. The key observation is that an integer 2: belongs to Uf=1(a¢ + mZ) if
and only if
k
m _a.
H<1—e”i(z J)) =0.
j=1
A brutal expansion of the left-hand side yields
k (1 _ e"2'
mfic—a)
H
J ) =
i=1
2:
Ic{1,2,...,k}
CI . e2z1r$d1,
7.1.
The Chinese remainder theorem
where
415
2:;
—2i1r
CI=(_1)|I|He
_
n],
JEI
1
dI=Zn—-
JEI
J
the sum being taken over all subsets I of {1, 2, ..., k} (with the convention that
the product over the empty set is 1). Note that c1,d_r are complex numbers
depending only on the family of arithmetic progressions and not on :3. Letting
21 = e2md1, the hypothesis says that the relation 21 012;” = 0 holds for 2"
consecutive integers m, and we need to prove that it holds for all integers as.
Letting
“m = ZCIZ?)
I
it follows that 2’“ consecutive terms of this sequence vanish. On the other
hand, the sequence (un)n satisfies a linear recurrence relation with constant
coefficients, of order 2’“. Indeed, writing
H (X — 21) = X2’° + A2k_lx2*‘-1 + + A1X + A0,
I
we have the recurrence relation
un+2k + A2k_1un+2k_1 +
+ A0 = 0.
Since A0 79 O and since by assumption 2’“ consecutive terms of this sequence
vanish, it follows immediately that all terms vanish, which is what we needed.
I]
Example 7.31. (Zhang’s theorem) Prove that for any covering system of con-
gruences (a,- + n¢Z)1SiSk there exists a nonempty subset I Q {1, . . . , k} such
that
1
Z— 6 Z
iEI
Proof. An argument identical to the one used in the proof of example 7.30
yields for all integers n
1 +
2
IC{1,2,...,k}
CI _ e2i1l'nd1' = 0,
416
Chapter 7. Congmences for composite moduli
where now the sum is over the nonempty subsets I of {1, 2, ..., k} and
c1
=
_
( 1)
lIl
He
—2127r%-;§
J,
d1
=
_1_
Zn'
161
JEI
3
We need to prove that at least one of the numbers d; is an integer. The key
observation is the following
Lemma 7.32. Suppose that a: E R is not an integer.
(an)n21 defined by
Then the sequence
an ___ 2n: e2i1rzk
k=1
is bounded.
Proof. Write z = em” and observe that z 79 1 since a: is not an integer. Then
an=z+z2+...+zn=z-
1—2”
1—2
and since |z| = 1 it is clear that
2
<—.
|“"|-|1_z|
The result follows.
I]
Assuming next that none of the numbers at; is an integer, we obtain a
contradiction using the lemma and the following relation, which follows by
adding the previous ones for n = 1, 2, ..., N:
N
_N =
2
Ic{1,2,...,k}
CI . Z _e2i1r'nd1.
n=1
Indeed, the left-hand side is obviously unbounded as N —> 00, while the righthand side is bounded thanks to the lemma and our assumption. The result
follows.
III
7. 2.
7.2
Euler’s theorem
417
Euler’s theorem
7.2.1
Reduced residue systems and Euler’s theorem
We start by introducing some useful terminology. Recall that integers
a1, ..., an form a complete residue system modulo n if their remainders when
divided by n are a permutation of 0,1,..., n — 1. Considering the totatives2 of
n instead of 0,1,...,n — 1 naturally yields the following definition.
Definition 7.33. Integers a1, ..., (1;, form a reduced system of residues mod n
(or a reduced residue system mod n) if every integer relatively prime to n is
congruent modulo n to exactly one of a1, ..., (1],.
Before moving on, let us make the following simple remarks, which are
direct consequences of the definition of a reduced system of residues mod n.
Remark 7.34. Clearly (11,...,a;c form a reduced residue system modulo n if and
only if their remainders when divided by n are a. permutation of the totatives
of n. In particular every reduced system of residues mod n has precisely
<p(n) elements. Moreover, if (11, a2, ..., (1;; and b1, ..., bk are reduced systems of
residues mod n, then there is a permutation a of 1, 2, ..., k such that a, E baa)
(mod n) for all i.
If an, ..., an is a complete residue system modulo n, then for any integer a
relatively prime to n the numbers aa1,...,aan form a complete residue system
modulo n. The next proposition establishes a similar result for reduced residue
systems.
Proposition 7.35. If a1, ...,ak is a reduced system of residues mod n and if
a is an integer relatively prime to n, then aa1,a,a2, ..., aak is a reduced system
of residues mod n.
Proof. First, aai is relatively prime to n, since a and a, are so. Next, by
remark 7.34, it suflices to prove that aa1,aa2, ..., (1a,c are pairwise incongruent
mod n. If aai E adj (mod n), by Gauss’ lemma we have a,- E a,- (mod n),
hence i = j. The result follows.
2Recall that an integer a E {1, 2, ...,n} is called a totative of n if gcd(a.,n) = 1.
III
418
Chapter 7. Congruences for composite moduli
We are now ready to state and prove the following important theorem,
which generalizes Fermat’s little theorem.
Theorem 7.36. (Euler’s theorem) If n is a positive integer, then for all integers a relatively prime to n we have
aw") E 1
(mod n).
Proof. Let a1, ..., (1;, be a reduced system of residues mod n. By proposition
7.35 the numbers aa1,...,aak form a reduced residue system modulo n, thus
alag...ak E (aal) - (aa2) -
- (oak)
(mod n),
by remark 7.34. This congruence can be rewritten as
alag...ak(a"°(”) — 1) E 0
(mod n).
Since gcd(n,ai) = 1 for all i, it follows that gcd(n,a1a2...ak) = 1, hence the
previous congruence simplifies to (1990") — 1 E 0 (mod n), as needed.
III
We can also prove Euler’s theorem as follows. Let p be a prime divisor of
n, so that p — 1 | <p(n). By Fermat’s little theorem and the lifting the exponent
lemma (more precisely theorem 6.22) we have
vp(a""(") — 1) = 1),, ((c1,1"1)”:J-212 — 1) _>_ 'up(a"_1 — 1) + 'up (5+7?) .
We conclude that vp(a""(”) — 1) 2 010(7),), since 1),),(ap—1 — 1) 2 1 and
at (1‘:(f1) = we» 2 «2.02) — 1.
We illustrate Euler’s theorem with some simple examples, the more challenging ones being kept for the next section.
Example 7.37. Prove that for all a. 2 2 and n 2 1 we have n | 90(0," — 1).
Proof. By Euler’s theorem we have clown—1) E 1 (mod a." — 1). Thus a” — 1 |
drown—1) — 1. We conclude that n I Lp(a” — 1) using corollary 3.36.
[I
7.2.
Euler’s theorem
419
Example 7.38. Prove that n2 — 1 | 2'”! — 1 for all even integers n > 0.
Proof. Since n is even, n — 1 and n + 1 are relatively prime, thus it suffices to
prove that n — 1 and n + 1 each divide 2"! — 1. By Euler’s theorem n :l: 1 |
2‘P("=t1) — 1 and so it is enough to prove that <p(n :l: 1) | n!. This is clear, since
<p(n:|:1)$(n:l:1)—1Sn.
I]
Example 7.39. Let p be prime number.
Given an integer a such that
gcd(a, p!) = 1, prove that aw‘l)! — 1 is divisible by pl.
Proof. By Fermat’s little theorem a(p_1)! — 1 is a multiple of p, thus it suffices
to prove that (p — 1)! | a<P—1)l— 1. If q < p is a prime and k: = uq((p — 1)!),
then <p(qk) = qk‘1 (q — 1) | (p — 1)!, and Euler’s theorem yields the desired
result.
El
Example 7.40. Find all positive integers dividing infinitely many numbers in
the sequence 1,11, 111, 1111,
Proof. Clearly none of the numbers 1, 11, 111,
is even or a multiple of 5, so
any solution of the problem is relatively prime to 2 and 5. Conversely, let n be
a positive integer relatively prime to 10. We will prove that for infinitely many
k we have n | log—1, or equivalently 9n | 10k — 1. Simply take k = M<p(9n)
for any M 2 1 and use Euler’s theorem to conclude.
III
We end this section with two more results concerning reduced residue sys-
tems. The following theorem relates reduced systems of residues modulo m, n
and mu, if m and n are relatively prime positive integers. Note that it immediately implies that Euler’s totient function (p is multiplicative, a result that
has already been obtained as a consequence of the explicit formula for (p(n).
Theorem 7.41. Let a1,a2, ...,ak be a reduced system of residues mod n and
let b1,b2, ...,bl be a reduced system of residues mod m. If gcd(m,n) = 1, then
(ma,- + nbj)lsisk,1sjsl is a reduced residue system mod mn.
Proof. First, we check that gcd(mai + nbj,mn) = 1 for all t, j. If a prime p
divides mn and ma,- +nbj, we may assume that it divides m. Then p | nbj and
since gcd(m, n) = 1 we have p | bj, contradicting the equality n(bj, m) = 1.
420
Chapter ’7. Congruences for composite moduli
Next, we prove that ma,- +nbj are pairwise incongruent mod mn. Suppose
that mai + nbj E ma;c + nb; (mod mn). Then nbj E nbl (mod m) and since
gcd(n, m) = 1, we must have bj E b; (mod m), thus j = Z. We obtain similarly
i = k.
We prove finally that for any a: relatively prime to mn we can find 2', j
such that at E mai + nbj (mod mn). Pick an integer m’ such that mm’ E
(mod 77.) (possible since gcd(m, n) = 1). Then gcd(m’:13, n) = 1, hence there
is t such that m’at E ai (mod n). Then a: E ma,- (mod n), and we can write
a: = mai + nc for some integer c. Since gcd(a:, m) = 1, we have gcd(c, m) = 1,
thus there is j such that c E bj (mod m). Then a: E mai + nbj (mod mn), as
desired.
El
Remark 7.42. The proof of the previous theorem can be shortened using the
equality <p(mn) = <p(m)<p(n) combined With remark 7.34. Indeed, using these
observations one can simply delete the third paragraph in the above proof. We
preferred to give the previous longer proof since it gives an alternative proof
of the formula <p(mn) = <p(m)go(n).
Finally, we describe the remainder modulo n of the product of the elements
of a reduced residue system. The next theorem is due to Gauss.
Theorem 7.43. Let a1, a2, ..., 0.900,) be a reduced residue system modulo n > 2
and let N be the number of solutions of the congruence $2 E 1 mod n. Then
W»)
N
H a, E (—1)?
(mod n).
i=1
Proof. If an integer r is relatively prime to n, then so is its inverse r"1 modulo
n. It follows that we can make pairs of the form (r, r‘l) out of the numbers
(11, ...,amn), such that the product of the elements in each pair is 1 modulo
n. We have to be a little bit careful, however, since we may have r = r‘1 for
some r, which happens if and only if r2 E 1’ (mod n). Hence we can pair all
ai’s but those which satisfy the congruence x2 E 1 (mod n), and so
<p(n)
H a,- E
i=1
H
zzEl
(mod n)
:1: (mod n).
7. 2.
Euler’s theorem
421
It remains to see that the last product is (—1)N/2 modulo n. We use a
similar argument: if an is a solution of the congruence x2 E 1 (mod n), then
so is —9:, and moreover a: is not congruent to —a: modulo n (as otherwise 72
would divide 2, which is excluded by hypothesis). Thus the solutions of the
congruence x2 E 1 (mod n) can be partitioned into N/2 pairs of the form
(3:, —a:), and the product of the elements in each pair is —:r2 E —1 (mod n).
Thus
H
$251
a: E (—1)N/2 (mod 17.)
(mod n)
and we are done.
El
Remark 7.44. The precise value of N was found in example 7.11, using the
Chinese remainder theorem. We conclude that
k
Hai E 1
(mod n)
i=1
unless n = 4 or n is of the form pk or 2p" for some odd prime p and some
k 2 1, in which case H121 a; E —1 (mod 72.).
7.2.2
Practicing Euler’s theorem
In this section we give several less straightforward examples in which Euler’s theorem is the key ingredient. We start with a very short proof of the
existence part of the Chinese remainder theorem.
Example 7.45. Prove the existence part of the Chinese remainder theorem
using Euler’s theorem.
Proof. Let m1, ...,mn be pairwise relatively prime integers and let a1, ...,an
be arbitrary integers. We need to find a: such that :1: E a..- (mod m,-) for all i.
Simply take
90 = “1(m2---mn)¢(m1) + 02(m1m3u-mn)‘°(m2) +
+ an(m1...mn_1)"’(m").
By Euler’s theorem :1: satisfies the desired congruences.
El
422
Chapter 7. Congruences for composite moduli
We continue with three rather remarkable congruences.
Example 7.46. Prove that for all positive integers n and all integers a
Z <p(d)a.% E 0
(mod n).
dIn
Proof. Let
n
xn(a) = Z <p(d)a7
dIn
and let P(n) be the following statement: n I xn(a) for all integers a. First,
let us check that if gcd(m, n) = 1 and if P(m) and P(n) are true, then so
is P(mn). Let a be an integer. Since gcd(m, n) = 1, it suffices to show that
m I xmn(a) and n I xmn (a). By symmetry, it is enough to prove the divisibility
m I x‘mn(a). Note however that since gcd(m, n) = 1 and (p is multiplicative,
we have
acme) = 2 wow = Z so<e>so<f>fl
dImn
elmJln
= :3
W) Emmi)? = Zw<f>wm<all
fIn
eIm
fl"
Since P(m) holds, each of the numbers mm(a%) is a multiple of m, so we are
done.
Taking into account the previous discussion, it suffices to prove that p” I xpn (a)
for all a, 'n, 2 1 and primes p. Note however that
mpn (a) = a?" + (p — 1)a1’"_1 +p(p — 1)c”_2 +
+p"_1(p — 1)a
= a?" — a?“ + pm?“ + (p — 1)ap"‘2 + + gin—2(1) — 1)a,)
= a?" — a,P"_1 + pxpn—1(a,).
Thus, arguing by induction on n, it sufl'ices to prove that p I xp(a) (which is
equivalent to up E a (mod p), i.e. Fermat’s little theorem) and p" I awn—all"—1L
This last divisibility is clear if p I a, and otherwise it follows from Euler’s
theorem.
El
7. 2.
Euler ’3 theorem
423
Example 7.47. Prove that, for all positive integers n and all integers a,
n
n I Z agodfim)
z=1
Proof. If d is a positive divisor of n, then the integers i 6 {1,2, ..., n} for which
gcd(z', n) = d are precisely the numbers dj with j a totative of 3-, thus there
are 90%) such integers i. We deduce that
fawn) = Zso<§>ad
= Deana?
d|n
dln
i=1
El
and the result follows then from example 7.46.
Example 7.48. (IMO Shortlist 1987) Let (0.11),,21 be a sequence of integers
satisfying
2 ad = 2n
dln
for all n. Prove that n divides can for all n.
Proof. It is immediate to check the property for n = 1 and n = 2. Assume,
by strong induction, that n > 2 and that ak is divisible by k for all k < n. It
suffices to prove that if p is a prime and m = vp(n), then pm divides an. By
hypothesis
d|n,d<n
If d < n is a divisor of n for which pm | (1, then pm | d | ad. Thus
an E 2” — 2 ad = 2" — 2MP
dln/p
(mod 10"").
It sufiices to prove that 2” — 2771’ is a multiple of pm. If p = 2, this is clear,
since 71/]? 2 m (because pm divides n, we have n/p 2 gem—1 = 2"“—1 2 m). So
assume that p > 2. By Euler’s theorem, it is enough to check that n — g is a
multiple of <p(pm) = pm_1(p — 1), or equivalently that n is a multiple of 19’",
[I
which holds by definition of m.
424
Chapter 7. Congruences for composite moduli
The next examples have a more combinatorial and constructive nature.
Example 7.49. Let em, ..., an be rational numbers such that of + a’; +
+ of,
is an integer for all k 2 1. Prove that al, ..., an are integers.
Proof. Let d be the product of the denominators of a1, ..., an and write x,- =
dai, then 931, ...,:cn are integers and by assumption (1" | m’f +
+ 93;“, for all
k 2 1. We want to prove that d | 51:, for all 1'. Using the prime factorization of
d, we may assume that d is a power of a prime p, say d = p7 . By an immediate
induction on j, we may assume that j = 1. Thus pk | m’f + +1.1“, for all k 2 1
and we want to prove that p | 9:1, ..., :13”. Assume that this is not the case and
let I be the set of those 1' e {1, ...,n} for which 1) does not divide mi. Using
Euler’s theorem we obtain
tr?” + Mr?” E III (mod pk)On the other hand, by assumption p‘PU’k) (and thus pk) divides the left-hand
side. We deduce that p’c | |I| and since k 2 1 was arbitrary, it follows that
|I| = O, a contradiction. The result follows.
[I
Remark 7.50. The conclusion is trivially false without the assumption that
a1, ..., an are rational numbers (consider for instance on = 1 + \/2_ and a2 =
1 — fl). The most general result (whose proof is outside the scope of this book)
is the following: for complex numbers a1, ..., an the numbers of + + afi are
integers for all k 2 1 if and only if H2; (X — (1,) has integer coefficients.
Example 7.51. (China TST 2006) Prove that for any positive integers m,n
there is a positive integer k such that 2’“ — m has at least 71. different prime
divisors.
Proof. By replacing m with its largest odd divisor, we may assume that m is
odd. Let w(:r:) be the number of different prime divisors of a: > 1. It suffices to
prove that if 2k—m > 1 then we can find I > k such that w(21—m) > w(2k—m).
Let 2" — m = p?1...p‘1"VN be the prime factorization of 2’“ — m and note that
p,- > 2 for all 1', since m is odd. Choose l = k + “£1 <p(pf“+1) and note that
by Euler’s theorem we have
21 — m E 2k — m (mod pf“)
7. 2.
Euler’s theorem
425
in particular vpi(2’ — m) = a,- = vp‘.(2k — m) for all 1 g 2' S N. Since
21— m > 2" — m, it follows that 21— m must have a prime factor different from
p1, ...,pN, thus (41(2l — m) > w(2k — m) and we are done.
III
Example 7.52. Let y be a positive integer. Prove that there are infinitely many
primes p such that p E —1 (mod 4) and p|2"y + 1 for some positive integer n.
Proof. We may assume that y is odd, so that 2y + 1 E —1 (mod 4). Suppose
that 101, ..., pk are all primes of the form 4m+3 which divide at least one of the
numbers 23/ + 1,434 + 1,8y + 1,
Set n = <p((2y + 1)p1...pk) + 1. By Euler’s
theorem we have
2ny + 1 E 23; + 1
(mod (2y + 1)p1...pk).
Hence we can write 2ny+ 1 = (2y+ 1)(sp1...p;c + 1) for some positive integer 3.
Since 2ny+1 E 1 (mod 4) and 2y+1 E 3 (mod 4), we must have spl...pk+1 E
—1 (mod 4), hence there is a prime q E —1 (mod 4) such that q | $131.42], + 1.
But then q | 2"y + 1, so q 6 {p1, ...,pk}, obviously impossible. The result
follows.
E]
Example 7.53. (IMO Shortlist 2012) Let x and y be positive integers. If 9:2" — 1
is divisible by 2%; + 1 for every positive integer n, prove that :1: = 1.
Proof. Suppose that there is a prime q such that q|2ny+1 and q E —1 (mod 4),
then we get that q|m2n — 1 = (a: — 1)(a: + 1)(:::2 + 1)(:I:4 + 1)...(:1:2"_1L + 1). But
q cannot divide :62,“ + 1 for any positive integer m (see corollary 5.28), so
q|cc2 — 1. We conclude using the previous example.
[I
Example 7.54. Let a1, ..., an be positive integers, not all equal. Prove that the
set of prime numbers dividing at least one of the numbers all“ + (1'2“ +
+ of,
with k 2 1 is infinite.
Proof. We may assume that gcd(a1, ..., a,,) = 1. Write f(k) = of + + of, for
k 2 1 and suppose that all prime divisors of f(l), f (2), belong to {p1, ...,pN}
for some primes p1, ...,pN and some N 2 1. For each 1 S 2' S N, let b,- be the
number of terms of the sequence a1, ..., an which are not divisible by 10,. Since
gcd(a1, ...,an) = 1, we have b, 2 1 for all 1 S 73 S n.
426
Chapter 7. Cong'ruences for composite moduli
Note that for
k= 21—190 (p21+vp,-(bi) )
we have f(k) : b- (mod pv"(b‘)+1) for all 1 S i S N, since for any 1 S j g n we
have (12951 (modp””0, H1) if p, does not divide aj (by Euler’s theorem) and
=0 (modpvp(b.)+1) otherwise (since k > 1 +vp(b,)). Therefore up, (f(16)) =
up, (b ) for all 2' and since all prime divisors of f (k) belong to {p1,p2, ...,pN},
we conclude that f(k)= p0p1(b1)p;”2(b2). p11?” (1)”). Since max(a1, ...,an) 2 2,
we have
f(k)_> 2k > k > Hp”9"",
i=1
a contradiction. The result follows.
[3
Example 7.55. (USA TST 2007) Are there integers a,b 2 1 such that a does
not divide b” — n for all n _>_ 1?
Proof. The answer is negative. We will prove by strong induction on a the
following: for all b 2 1 there are infinitely many n such that a | b" — n. This
is clear for a = 1, so assume that it holds up to a — 1 and let us prove it for
a. Since <p(a) < a, the inductive hypothesis yields the existence of infinitely
many n such that <p(a) | b" — n. We claim that if <p(a) | b" — n and n is big
enough, then a | bb" — b”, which is enough to conclude. To prove the claim,
write b" — n = c<p(a), then
bb" — b“ = WM“) — b" = b”((b°)‘°(“) - 1)Take now any prime factor p of a. and let k = vp(a). If p does not divide b,
then Euler’s theorem gives p”6 | (bc)‘P(Pk) — 1 | (boy/’0‘) — 1. On the other hand,
if p | b and n 2 k, then certainly pk I b”. Thus if n 2 maxpla vp(a), then
a. | b"((b°)‘p(“) — 1), finishing the proof.
El
Example 7.56. (Russia 2004) Is there an integer n > 101000 which is not divisible by 10 such that one can exchange two distinct non—zero digits in its
decimal representation without changing the set of prime divisors of n?
7.3.
Order modulo 7?.
427
Proof. Yes, there is such a number, actually there are infinitely many of them!
For each positive integer k let
10360]: _ 1
nk=13-—9—=144...43.
Exchanging the digits 1 and 3 we obtain the number 344. .—41 —- 31 1
0_9_360k_ 1
7
which has the same prime divisors since 10360,“ — 1 is divisible by both 13 and
31 by Euler’s theorem (because 360 = <p(13 - 31)).
III
7.3
7.3.1
Order modulo n
Elementary properties and examples
Let n be a positive integer and let a be an integer relatively prime to 71.. By
Euler’s theorem there are infinitely many positive integers k such that ak E 1
(mod n), for instance all multiples of <p(n). In this section we study in more
detail the congruence am E 1 (mod n). We will see that all solutions of this
congruence are determined by the smallest positive solution. The following
definition is therefore rather natural.
Definition 7.57. If n is a positive integer and a is an integer relatively prime
to n, the smallest positive solution of the congruence a“ E 1 (mod n) is called
the order of a modulo n and denoted ordn(a).
Note that 0rd,, (a) is not defined when a is not relatively prime to 77.. Also,
the sequence of remainders mod n of the numbers 1, a, a2,
is periodic with
(minimal) period 0rd,,(a). This follows from the fact that ai E ai+j (mod n)
is equivalent (by Gauss’ lemma) to aj E 1 (mod n) for all positive integers
i, j. For instance, consider a—
— 3 and n = 17, then the sequence of remainders
of 1, a, a2 ,. ..when divided by n is
1, 3, 9, 10, 13, 5,15,11,16,14, 8, 7, 4, 12, 2, 6, 1, 3, 9,
and the length of the period is 16 hence 0rd17(3) = 16.
The following fundamental theorem summarizes the most important prop—
erties of 0rd,, (a).
428
Chapter 7. Congruences for composite moduli
Theorem 7.58. Let a be an integer relatively prime to n > 1.
a) The positive solutions of the congruence a’” E 1 (mod n) are exactly the
multiples of 0rd,,(a).
b) ordn(a) divides Lp(n).
Proof. Note that b) follows from a) and Euler’s theorem, so it suffices to prove
part a). Let d = ordn(a). Since ad E 1 (mod n) we have amd E 1 (mod n)
for all m 2 1, so all multiples of d are solutions of the congruence a” E 1
(mod n). Conversely, let k: > 0 be such that a" E 1 (mod n) and consider the
Euclidean division k = q - d + r, with 0 S r < d. Then
1 E ah E aqd - a’" E a’"
(mod n),
thus a." E 1 (mod n). Since r < d, the minimality of d forces r = 0 and so
d I k, finishing the proof.
El
Part b) of the previous theorem is very useful especially when <p(n) has
a simple form. Here are a few relatively simple examples that illustrate this
result (the reader will find more challenging examples in the next section).
Example 7.59. Determine ordn(a) in the following cases:
a) a = 2 and n 6 {7,11,15}.
b) a = 5 and n 6 {7,11,23}.
Proof. In all cases we let d = ordn(a) and we use that d | ¢p(n).
a) Suppose that n = 7, so 90(7) = 6 and d | 6. Checking successively
divisors of 6 yields d = 3. Suppose that n = 11, then d | 10. Again, checking
the divisors 1,2, 5, 10 of 10 yields d = 10. For n = 15 we have <p(n) = 8 and
d I 8. Since 24 E 1 (mod 15) and 22 is not congruent to 1 mod 15 we deduce
that d = 4 in this case.
b) For n = 7 we have d | 6 and since 7 does not divide 52 — 1 and 53 — 1 we
deduce that d = 6. For n = 11 we have at | 10 and 11 does not divide 52 — 1.
Next 55 E 25 0 125 E 3 -4 E 1 (mod 11), so d = 5. Finally, for n = 23 we have
d | 22 and 23 does not divide 52 — 1. Also,
51155-25555-2555-95—1
henced=22.
(mod23)
III
7.3.
Order modulo 7?.
429
Example 7.60. Let n be an integer greater than 1.
a) Compute ordgn (5) and prove that
1, 5, 52,
52““, —1, —5,
—52"‘2—1
form a reduced residue system modulo 2".
b) Prove that for any a E 1 (mod 4) there is a unique'i E {0, 1, ..., 2"—2 —1}
such that a, E 5i (mod 2"), and for any a E ——1 (mod 4) there is a unique
i6 {0, 1, ..., 2"—2 — 1} such that a E —5’: (mod 2").
Proof. a) Let d = ord2n(5), then d l <p(2"') = 271—1, so d = 2’“ for some
0 S k < n. Thus we need to find the smallest k 2 0 for which 2" | 52k — 1, i.e.
such that v2(52k — 1) 2 77.. Using either (and preferably!) the factorization
52” — 1 = (5 — 1)(5 + 1)(52 + 1)...(52’°'1 + 1)
or the lifting the exponent lemma, we obtain 122(52k — 1) = k + 2. Thus the
inequality 122(52k — 1) 2 n is equivalent to k 2 n — 2 and so d = 211-2.
Since <p(2”) = 211—1, any reduced residue system modulo 2" has 2”‘1 el—
ements. It suffices therefore to prove that the numbers 1, 5, 52, ..., 5211—24,
—1, —5, ..., —52"_2‘1 give different remainders when divided by 2". Since
OI‘d2n (5) = 2n‘2, the numbers 1, 5, 52, ..., 52"_2‘1 give different remainders
mod 2”, and similarly for the numbers —1,—5, ..., —52n—2‘1. Finally, we cannot have 5i E —5j (mod 2”), for some 0 S 12, j S 2'“2 — 1, since this would
imply that 1 E —1 (mod 4), a contradiction. The result follows.
b) This is an immediate consequence of part a) and of the fact that 5’“ E 1
(mod 4) for all k, while —5k E 3 (mod 4) for all k.
CI
The result established in part a) of the next example is very important.
Example 7.61. (Lucas, 1878) Let n > 1 be an integer and let p be a prime
divisor of F = 22” + 1.
a) Prove that the order of 2 modulo 1) is 2”+1 and deduce that 27““1 | p — 1.
b) Prove that a = 22%2 (271—1 —— 1) has order 2”"‘2 modulo 1) and deduce
that 2n+2 | p — 1.
c) Prove that if p2 | Fn, then 122 | 21"-1 — 1.
430
Chapter 7. Congruences for composite moduli
d) Prove that p | 2’3—1 — 1 and deduce a new proof of the fact that 2"+2 I
p — 1.
Proof. a) Let d be the order of 2 modulo p. Since 22" E —1 (mod p), we
have 22"+1 a 1 (mod 1)), thus d divides 2n+1. If d divided 2”, then 22" a 1
(mod p) and since 22" E —1 (mod p), we would obtain 2 E 0 (mod p), a plain
contradiction. Thus d divides 2"+1 and does not divide 2", which means that
d = 2"“. Since d divides <p(p) = p — 1, we are done.
b) Note that
a2 = 22”‘1(22" — 2 . 2
2n—1
+ 1) a —2 - 22"‘1+2"‘1 a —2(—1) = 2 (mod p),
since p | 22" + 1. We deduce that a2"+1 E 22'1 E —1 (mod p). Arguing as in
a) we deduce that the order of a modulo p divides 2”+2 and does not divide
2”“, thus it equals 2"”. Since the order divides <p(p) = p — 1, we deduce
that 2"+2 | p — 1.
0) Since p E 1 (mod 2”“) by part a), we obtain
172|Fn|22n+1 —1|2P-1—1,
as needed.
_1
d) The divisibility p | 2% — 1 is equivalent, by Euler’s criterion (theorem
5.99) to (g) = 1, which is equivalent (by theorem 5.125) to p E :|:1 (mod 8).
Since p E 1 (mod 8) by part a), we obtain p | 223—1 — 1. Next, since the order
—1
of 2 modulo p is 2"+1 (again by part a)) and since 223— E 1 (mod p), we
obtain 2”"‘1 | 93—1 and so p E 1 (mod 2"”).
I]
Remark 7.62. The only known primes p satisfying p2 | 21‘"1 — 1 are 1093 and
3511, discovered in 1913 and 1922 by Meissner and Beeger. These primes are
called Wieferich primes and it is an open problem whether there are infinitely
many such primes. Note that 1093 and 3511 cannot divide any Fermat number,
since 27 does not divide 1092 or 3510, while by Lucas’ theorem any prime factor
of 22,1 + 1 with n 2 5 is congruent to 1 modulo 27. Therefore not a single
Fermat number which is not squarefree is currently known!
7. 3.
Order modulo n
431
Combining the next example and the previous remark shows that 21’ — 1
is quite likely squarefree when p is a prime (again, no counterexample to this
assertion is known).
Example 7.63. Suppose that p, q are primes and p2 | 2‘1—1. Prove that 21"-1 E 1
(mod p2).
Proof Let d be the order of 2 modulo p2. Then d | <p(p2) = p(p — 1) and the
hypothesis yields (1 | q. Clearly d aé 1, thus necessarily d = q and so q | p(p— 1).
If q = p, we obtain p | 2" — 1, clearly impossible by Fermat’s little theorem.
Thus q | p — 1. But then p2 | 2‘1 — 1 | 21"1 — 1, as needed.
III
Example 7.64. Let n > 1 be an integer such that a = 2” + 1 is pseudo-prime,
i.e. a | 2“ — 2. Prove that n is a power of 2.
Proof. The hypothesis yields 2" + 1 | 22" — 1. Let d be the order of 2 modulo
2” + 1. Since 22” E 1 (mod 2” + 1), we have d | 2", so d is a power of 2. On
the other hand, 2" E —1 (mod 2'” + 1), thus 22" E 1 (mod 2” + 1) and d | 2n.
If d 7E 272, then d S n and so 2" + 1 g 2"l — 1 < 2”, impossible. Thus d = 2n
and since d is a power of 2, it follows that n is a power of 2.
El
Example 7.65. (Kvaut M 1355) Let n be a positive integer such that 22n+2n+1
is a prime. Prove that this prime is a divisor of 22114.1 — 1.
Proof. Let p = 22” + 2" + 1 and note that p | 23'" — 1. Thus in order to show
that p | 22“+1 — 1 it suffices to prove that 3n I 2” + 1. Let d = ordp(2). Since
23” E 1 (mod p) we have d | 3n. Next, we have d > 2n > 37” since 2‘1 E 1
(mod p) (thus 2"l > p > 22”), which combined with d | 317. yields d = 377..
Since d | p — 1, we conclude that 3n | p — 1 = 2n(2n + 1). Finally, note that
n is odd (if n is even then p > 3 and p E 0 (mod 3), a contradiction) hence
gcd(3n, 2") = 1 and so 3n | 2" + 1, as desired.
III
We present a few more theoretical results that can be very helpful when
dealing with orders modulo n. The first one says that if one knows how to
compute ordn(a), then one can also easily compute 0rd,,(ak) for all k 2 1.
432
Chapter 7. Congruences for composite moduli
Proposition 7.66. Let a,n be relatively prime integers, with n > 1, and let
d = ordn(a). Then for any positive integer k
d
_ gcd(d,k)'
ordn(ak )—
In particular
a) We have ordn(ak) = d if and only if gcd(d, k) = 1.
b) Ifk | d, then 0rd,,(ak) = %.
Proof. Let m = gcd(d, k) and write d = md1,k = mkl with gcd(d1, k1) = 1.
Setting t = ordn(ak), we have
(ak)d1 = amk1d1 = (adycl
E 1
(mod n),
hence t I ah. On the other hand, since a,“ = (ak)t E 1 (mod n) we must have
d I kt, thus (11 | klt. As d1 and k1 are relatively prime, we have d1 | t. We
conclude that t = (11, as desired.
III
The next result reduces the computation of ordn(a) to the case when n is
a power of a prime.
Proposition 7.67. Let a,n be relatively prime integers, with n > 1.
Let
n = p‘f‘lp‘z"2 . . . pgk be the prime factorization of n. Then
0rd,,(a) = lcm(ordp:x1 (a), ..., 0rdp:k (a)).
Proof. To simplify notations, let d = ordn(a) and d, = ordpzxe (a) for 1 g i S k.
Finally, let M = lcm(d1, ..., dk). Since adi E 1 (mod p3“) and d,- | M, we have
aM E 1 (mod pf“) for all 1 g i g k and so aM E 1 (mod n). It follows that
d | M. On the other hand ad E 1 (mod n), thus ad E 1 (mod pf“) for all
1 Sigkandsodildforalll Sigh. ItfollowsthatM|dandthen
d = M, as desired.
El
Finally, the following rather technical result reduces the computation of
01'd (a) to computing 0rd,, (a) and 71,, (a°rdP(a) —1). It is a simple consequence of
the lifting the exponent lemma (which has already been used when discussing
7.3.
Order modulo n
433
example 7.60). We strongly advise the reader to repeat the proof every time
he needs to compute expressions of the form 0rd,;c (a), instead of memorizing
the rather messy formulae.
Proposition 7.68. Let p be a prime, a a positive integer and a > 1 an integer
relatively prime to p. Let d = ordp(a) and let u = up(ad - 1) 2 1.
a) Suppose that p > 2. If u 2 a then 0rd a(a) = (1, otherwise
ordpa (a) = d ~ pa‘”.
In particular, if up(a°'dp(“) — 1) = 1, then
ordpa (a) = ordp(a) -p°“1.
b) Suppose that p = 2 and a > 1. Ifa E 1 (mod 2") then 0rd2a (a) = 1
and if a E —1 (mod 2") then Ol‘dza (a) = 2. In all other cases
ord2a (a) = 2a_v2(02';1) ,
Proof. a) Let k = ordpa(a). Then p“ | a,“ — 1, thus p I ah — 1 and so d | k.
Clearly, if v 2 a then p“ | a“l — 1 thus k | d and then k = (1. Assume now
that 'u < a and write 19 = dl for some positive integer l. Since p°t | a,“ — 1 and
p | ad — 1, the lifting the exponent lemma yields
0‘ 5 ”Male — 1) = ”10d — 1) = ”Add — 1) + ”10(1): 12 + ”12(1)It follows that up(l) Z a — u and so pa‘” | l, thus d - paw | 16. Conversely, the
same calculation shows that p“ | afloat—V — 1 and so k | d - pa"". The result
follows.
b) The first part is clear, so assume that a is not congruent to :l:1 modulo
2“, so that a > ’02 (“22—1). Let k = ordza (a), then k | 2"‘1 and so k = 2’" for
some r 2 0. Moreover, using the lifting the exponent lemma yields
2—1
agv2(ak—1)=v2 (a 2
+7“,
434
Chapter 7. Congruences for composite moduli
_
a_-1
thus r 2 a — v2 (“22—1) and 2a v2( 2 ) | k. A similar computation shows
that for n = 2a_v2(—2—) we have a” E 1 (mod 20‘) and the result follows.
[1
Remark 7.69. If vp(a°rdr(”') — 1) > 1, then p2 | a1’_1 — 1 (since ordp(a) | p — 1,
hence a°'dP(“) — 1 | a?"1 — 1). For any a, this happens for very few primes p
(see remark 7.62 for the case a = 2).
Example 7.70. Prove that if n is a positive integer, then the order of 2 modulo
5" is equal to 4- 5”"1.
Proof. We clearly have ord5(2) = 4 and 115(24 — 1) = 1. Using part a) of the
proposition, we obtain
ord5n (2) = 4- 5"_1,
as needed.
[I
Example 7.71. Prove that if p is an odd prime and n is a positive integer, then
the order of 1 + p modulo p" is p ‘1.
Proof. The order of 1 + p modulo p is clearly 1 and 'vp((1 + p)1 — 1) = 1. Thus
the result follows directly from proposition 7.68.
D
Example 7.72. (China Western Olympiad 2010) Let m, k be nonnegative integers and suppose that p = 22'" + 1 is a prime number. Prove that the order
of 2 modulo p"+1 is 2m+1pk.
Proof. For k = 0 we need to prove that ordp(2) = 2m+1, which has already
been established (see example 7.61). Next, using part a) of proposition 7.68
we obtain
)'
—vp(22m+1_1
0rdpk+1(2) = 2m+1 ' 2k+1
Since we clearly have 111,,(22’1‘+1 — 1) = vp((p — 2)p) = 1, we obtain
OIdpk+1(2) = 2m+1pk,
as desired.
III
7.3.
Order modulo 1?.
435
We end this rather long section with a rather surprising and very useful
connection between order and decimal expansions. This requires some pre-
liminary discussion. If :1: e [0, 1) is a real number, then we can attach to a:
a sequence of digits a1,a2, e {0, 1, ...,9} as follows: define a1 = [10:17] and
bl = 10:17 — a1 6 [0,1), then a2 = [10b1] and ()2 = 10b1 — a2, and so on. It is an
easy exercise to check that for all n 2 1 we have
<
—
a1
—
a21
_
O-m (10+_1o2 + +10n)<10n’
thus the sequence of rational numbers (‘1‘0+ l—fiv +.. + {IO—"5)“>1 approximates
a: to arbitrary precision. The expression 0.a1a2... 1s called the decimal expan-
sion of at. If a: is an arbitrary real number, we can write lat] = :lzcc = N + z
with N a non-negative integer and z E [0, 1). If N = bk - 10k + + b1 - 10 + be
is the base ten expansion of N and 0.a1a2... is the decimal expansion of 2,
we call :tbk...bo.a1a2... the decimal expansion of as. We say that this decimal
expansion is periodic if the sequence (an)n21 is eventually periodic, i.e. there
is T 2 1 such that for all sufficiently large n we have an = an+T. The decimal
expansion is called purely periodic if it is periodic starting from the decimal
point, i.e. there is T 2 1 such that an = an+T for all n 2 1.
Theorem 7.73. Let :c be a real number.
a) The decimal expansion of a: is periodic if and only if a: is rational.
b) The decimal expansion of x is purely periodic if and only if a: is rational
and the denominator of a: (when written in lowest terms) is relatively prime
to 10.
c) If a: is rational and the denominator of :1: is of the form 2“5”q with
gcd(q, 10) = 1, then the minimal length of a period of the decimal expansion
ofa: is the order of 10 mod q.
Proof. Suppose that the decimal expansion of a: is periodic, say
a: = 'n..a,1...asb1...bkb1...bkb1...bk...
for some integer n and some digits a1,
:1: = n +
,as, b1,
,bk. Then
a—l-Tls
b1-- -bk
b1" bk
103
10k+s
102k+s
436
Chapter 7. Congruences for composite moduli
thus
x=n+
m
108
b1" bk
105(10’“ — 1)’
which is clearly a rational number. Moreover, this formula shows that if the
decimal expansion of a: is purely periodic (thus we can take 3 = 0), then a:
is a rational number whose denominator is relatively prime to 10 (since the
denominator divides 10" — 1). This already shows one implication in both a)
and b).
Let now an be a rational number and choose a large enough 3 so that the
denominator of 10% is relatively prime to 10. Using the Euclidean division
we can write
z
103:1: =
+ ~—
y
(I
for some integers y,z,q with 0 S 2 < q. Let k = 0rd,,(10) be the order of 10
modulo q, thus
z-—1—°k—1
18:
Oz
q
y+—_10—1
_
31+—
10" —1
where 0 S N < 10’“ —— 1 is some integer. Writing
y= 103n+m,
N= 5—1 bk
for some integer n and some digits (1;, bj, we obtain
a1...as
9” = n + 108
b——1...bk
108(10k — 1)
= n.a1...a3b1...bkb1...bkb1...bk...
This shows that the decimal expansion of :1: is periodic, a period being given
by k = ordq(10). Moreover, if the denominator of a: is relatively prime to 10,
then we can take 3 = 0 in the previous argument and deduce that the decimal
expansion of a: is purely periodic. This finishes the proof of parts a) and b)
of the theorem, and it also shows that the minimal length of a period of the
decimal expansion cannot exceed k = ordq(10). On the other hand, if k is
some period of the decimal expansion of as, then the previous arguments show
that we can write
1052:
B
A=-|-10——_1
7.3.
Order modulo n
437
for some integers s, A, B. If the denominator of :r is 2u5vq with gcd(q, 10) = 1,
this shows that q | 10’“ — 1 and so ordq(10) | k. Thus the period k must be at
least ordq(10), which finishes the proof of the theorem.
III
Here is an explicit example. Consider a: = %, then one easily checks that
0rd7(10) = 6 and
10‘5 — 1 = 7. 142857.
Thus
1 _ 142857 _ 142857
7
106_1—
106
+
142857
1012
+...=0.142857142857...
Example 7.74. (Moscow 1990) The decimal representation of a rational number
A is purely periodic with period n. What is the longest possible length of the
period of A2?
Proof. Letting A = %, the hypothesis becomes ordb(10) = n and we need to
find the maximal value of ordbz(10). Write 10" = 1 + kb and observe that by
the binomial formula we have
10% = (1 + kb)” = 1 + kbz +
a 1 (mod b2).
Since b2 | 10"” — 1, it follows that ordb2(10) | bn, in particular ordbz (10) S bn S
n(10” — 1). To see that this is the answer, it remains to prove that we can find
A for which ordb(10) = n and ordb2(10) = 71(10” — 1). Take A = Edi—1’ so b =
10" — 1. Let k = ordb2(10), then clearly n | k and so k = no for some positive
integer 0. Moreover (10” — 1)2 | 10’": —- 1, thus 10" — 1 | 1 + 10” + + 10"(c—1),
which yields 10" — 1 I c and finally ordb2(10) = n(10" — 1).
El
Example 7.75. (USAMO 2013) Let m and n be positive integers. Prove that
there is a positive integer c such that the numbers cm and on have the same
number of occurrences of each non-zero digit when written in base ten.
Proof. Start by choosing a positive integer k: such that 10km—n can be written
10km — n = 29’5yz with 12,111 2 0, z relatively prime to 10 and z > max(m, n).
This is possible, since for k > max(vz (n), 115 (11)) we have vp(10km'—n) = vp(n)
438
Chapter 7. Congruences for composite moduli
if p E {2, 5}, thus 2 2 2,33% and this last quantity exceeds max(m, n) for
k large enough.
Next, let I) be the order of 10 modulo 2 and write 10" — 1 = 20 for some
positive integer c. We claim that this c is a solution of the problem. First,
observe that b is the number of digits in the period of i, and this period is
the b—digit decimal representation of c (with possibly some extra zeroes added
to the left of the usual decimal representation of c). Since 2 > max(m, n), the
decimal expansions of 1:4 and % consist of repeated b-digit representations of
cm and on. Since
10’“flz = 9z + 2x531,
the decimal expansion of g is obtained from that of % by shifting the decimal
to the right 1: places and removing the integer part. It follows that the b-digit
representations of cm and on are cyclic shifts of one another, which shows that
[1
c is a solution of the problem.
Example 7.76. (IMO Shortlist 1999) a) Prove that there are infinitely many
primes p such that the length of the period of 5} is a multiple of 3.
b) If p is such a prime number, write 11, = O.a1a2...a3ka1a2...a3k.... What
is the maximal value of maxlsiskiag + a“), + (1,421,) over all such primes p?
Proof. a) We need to ensure that the order of 10 modulo p is a multiple of
3. If this order is 3d, then p divides 102d + 10" + 1, which suggests looking
at divisors of 1024 + 109 + 1, with q a prime (so that 3q has few divisors).
More precisely, we will prove that for any prime q we can find a prime divisor
p = f (q) of 102‘1 + 10‘1 + 1 which does not divide 103 — 1. Moreover, we will
prove that the order of 10 modulo p is 3q, in particular q —> f (q) is injective,
which will yield part a).
Note that 102‘1 + 10" + 1 E 3 (mod 9), thus if all prime divisors of 102‘] +
10‘1 + 1 divide 103 — 1 = 9 - 111 = 27 . 37, then 1024 + 104 + 1 = 3 . 37k for
some positive integer k, which is impossible (take the equation mod 4). This
proves the existence of 1).
Next, let d be the order of 10 modulo 19. Since p divides 102‘1 + 10‘1 + 1, it
also divides 103g —- 1 and so (1 divides 3q. If d 75 3q, then d = 1, 3 or q. The first
two cases are impossible by the choice of p. If d = q, then 10‘1 E 1 (mod p)
7.3.
Order modulo n
439
and since p divides 1024 + 10‘1 + 1, it follows that p | 3, a contradiction. Hence
d = 3g and we are done.
b) This part is trickier.
As we have already observed, we have p | 102’“ + 10" + 1. Since
103k — 1
= 411-103,“1 +
+ 0,319,
we deduce that
10k — 1 I a1 ° 10319—1 +
+ 0.31,,
which can be rewritten (using that 10“” E 10’ (mod 10’“ — 1) as
10k — 1 | b1-1o’°-1 + b2-10k‘2 +
+ bk,
where b,- = (I, + “1+1: + (154.21,. Note that 0 S bi S 27, thus
b1o10k‘1 + b2-10"‘2 +
+ bk 3 27.
Moreover, we have equality if and only if a1 =
10k—1
= 3(10’c — 1).
= (13;, = 9, which is impossible
(it would force 13 = 1). Thus b1 ~ 10’"—1 + b2 - 10"“2 +
+ bk is a multiple of
b1
|/\
10’“ — 1 smaller than 3(10" — 1), so it cannot exceed 2(10" — 1). In particular
2(1ok — 1)
1019—1
< 20.
On the other hand, since 10" — 1 | 10(b1 - 10’“‘1 + b2 - 10’“2 +
+ bk), we also
obtain 10" — 1 I b2 - 10’“1 + + 10b;c + b1 and so the previous argument yields
b2 < 20. Continuing like this we obtain b3, ..., bk < 20, thus
.
.
.
<
1%(01 + az+k + a1.+2k) _ 19
.
We conclude observing that for p = 7 the maximum is attained, since then
a1=1, (12:4, a3=2, a4=8, a5=5anda6=7, and4+8+7=19.
El
440
Chapter 7. Cong'r'uences for composite moduli
7.3.2
Practicing the notion of order modulo n
In this section we illustrate the previous theoretical results with some con—
crete, but more challenging examples. The result established in the next problem is extremely useful in practice. Roughly, it says that if a, b are integers,
then the prime factors of a? — bp (p being a prime) are of a rather special form.
Example 7.77. Let a and b be different integers and let p be a prime.
a) Prove that any prime factor q of a? — bp is either a divisor of gcd(a, b) -
(a — b) or of the form 1 + kp, with k 2 1.
b) Suppose that gcd(a, b) = 1. Prove that any prime factor q of
aP—bp a— b
IS
either equal to p or of the form 1 + kp with k 2 1.
Proof. a) If q | a, then clearly q | b and so q | gcd(a, b). Assume now that q
does not divide a, then it does not divide b either (since q I ap — bp). Let c be
an integer such that ca E 1 (mod q), then q | (ca)? — (cb)P, thus q | (ob)? — 1.
Ifd=ordq(cb), thendlpandd|<p(q) =q—1. Ifd= 1 thenq | cb—l and
thenq | a—bsince aCE 1(modq). Ifd=ptheaq—1 and we are done
again.
b) Since q | “:2" we have q | a? — bp and so, by part a) and the hypothesis,
q | a — b or q E 1 (mod p). If q E 1 (mod p) we are done, so assume that
q I a — b. We also know that q | alv—1 + ap‘zb + + bp‘l, thus q | pa’"1 and
q | pbp_1. Since gcd(ap_1,bp_1) = 1, we conclude that q | p and finally q = p.
The result follows.
El
Remark 7.78. In part b) if we assume that p,q > 2 then q E 1 (mod 2p) and
so q 2 2p + 1.
A very similar and also very useful result is the following:
Example 7.79. Let a and b be relatively prime integers and let n be a positive
integer. Prove that any odd positive divisor of a2" + b2" is congruent to 1
modulo 2”“.
Proof. It suffices to prove that any odd prime divisor p of a2" +b2" is congruent
to 1 modulo 2"“. Note that p does not divide ab, since gcd(a, b) = 1. Let c be
an integer such that be E 1 (mod p), then p | (ac)2" + 1. Then the order k of
ac modulo p divides 2"“, since p | (ac)?+1 — 1, and does not divide 2", since
7.3.
Order modulo n
441
otherwise we would have p I (ac)? — 1 and p I (ac)2n + 1 — ((ac)2" — 1) = 2, a
contradiction. Thus k = 2”+1 and since k | p — 1 we are done.
CI
The next four examples are illustrations of the result established in the
previous example.
Example 7.80. (Kvant M 1476) Find all primes p and q such that
pq I (2” + 1)(2q + 1).
Proof. If p I 2” + 1 then Fermat’s little theorem yields p I 3 and then p = 3.
Thus if p | 2” + 1 then p = 3 and q I 3(2‘1 + 1). Using again Fermat’s little
theorem we obtain q | 9 and then q = 3, giving the solution (p, q) = (3,3).
On the other hand, if (p, q) 7E (3,3), the previous discussion shows that we
must have p,q 75 3, p 7Q q, p I 2‘1 + 1 and q | 21’ + 1. We will prove that this is
impossible. Since p 75 3 and p | 2‘1 + 1, we have p I fig? and example 7.77
yields p E 1 (mod q), in particular p > q. By symmetry we also obtain q > p,
a contradiction. Thus (p, q) = (3, 3) is the only solution of the problem.
El
Example 7.81. (IMO Shortlist 2006) Find all integer solutions of the equation
277—1
:12—1
=y5—1.
Proof. We will prove that the equation has no solutions, by using twice the
following special case of example 7.77: if p is a prime and a: is an integer then
any prime factor q of ”5:11 is congruent to O or 1 modulo p. It follows that for
any positive divisor d of 3L1
we have d E 0, 1 (mod p).
:v—l
Note that “27:11 > 0 for any :1: aé 1, since 33— 1 and 1127—- 1 have the same sign,
thus y > 1. The previous discussion shows that y—1 and z := y4 +y3+y2+y+1
are each congruent to 0 or 1 modulo 7. If y — 1 E 0 (mod 7), then z E 5
(mod 7), a contradiction. If y—l E 1 (mod 7), then 2 E 24+23+22+2+1 E 3
(mod 7), again a contradiction. Hence the equation has no solution.
[I
Example 7.82. Find all integers a, n > 1 such that n and a" + 1 have the same
set of prime divisors.
442
Chapter ’7. Congruences for composite moduli
Proof. Let p be the largest prime divisor of n. If p = 2 then 11. is a power of
2, as well as a” + 1—
- (cg)2 + 1. Since 4 cannot divide x2 + 1 for any integer
:1: we deduce that a" + 1—
— 2 and a—
— 1, a contradiction. Thus p > 2. Let
b—
— a? and consider
__ (—b)P—1 __ an+1
A= bp+1
,. .
b+1
(—b)—1
a3+1
Any prime factor q of A is either equal to p or congruent to 1 modulo p by
example 7.77. On the other hand, q also divides a” + 1, thus q | n and then
q S p. It follows that q = p and so A is a power of p. Moreover, p I b? + 1 and
so 1) | b+1 by Fermat’s little theorem. Using the lifting the exponent lemma we
obtain vp(A) = 1 and so the only possibility is A = p, that is bp + 1 = p(b+ 1).
Arguing as in the solution of example 6.29 (this is a simple argument based
on inequalities) yields b = 2 and p = 3, then a% = 2 and a = 2, n = 3. Thus
the only solution of the problem is (a, n) = (2, 3).
III
Example 7.83. (IMO Shortlist 2005) Find all positive integers n for which
there is a unique integer a E {0, 1, ...,n! — 1} satisfying n! | a" + 1.
Proof. It is not difficult to see that n = 2 and n = 3 are solutions, so assume
that n > 3. If n! I a" + 1 then 4 | a” + 1 and so 17. must be odd. Hence
a = n! — 1 satisfies n! I a” + 1, which shows that n is a solution of the problem
if and only if b" + 1 is not a multiple of n! for any b e {0, 1, ...,n! — 2}.
Suppose first that n is a prime and that b E {0, 1, ...,n! —- 2} satisfies
n! | b” + 1. Then it | b” + 1 and Fermat’s little theorem gives 77. | b + 1.
On the other hand, choose any prime q < n and let k = vq((n — 1)!), then
qk | (b + 1) b—;_"_"11. Since q < n, example 7. 77 shows that q cannot divide
b_b_}-_|-11 and so q’c I b + 1. It follows that (n — 1)! | b + 1, which combined with
n | b + 1 and gcd(n, (n — 1)!)—
- 1 gives n! l b + 1, a contradiction. Thus all
prime numbers are solutions of the problem.
Suppose next that n is composite and let p be the smallest prime factor of
n. We will prove that b = "3! — 1 E {0, 1, ...,n! — 2} satisfies n! | b” + 1 and so
n is not a solution. But
b"+1=(b+1)(b"'1 —b”‘2+.. .+1=)
nl
p (—b‘"1
bn‘2+...+1)
7.3.
Order modulo n
and so it suffices to prove that p | tin—1 — b"_2 +
443
+ 1. Since p is the smallest
prime factor of n and n is composite, we have p2 S n and so p2 | n!, thus
b E —1 (modp) and b”_1—b”_2+...+1 E 1+1+...+1 = n E 0 (modp), as
desired. Thus the solutions of the problem are exactly the prime numbers.
El
Example 7.84. (Komal) Let n 2 1 and a be integers such that n | a” — 1. Prove
that a. + 1, a2 + 2, a3 + 3, ..., a" + 17. form a complete residue system modulo n.
Proof. We will prove this by strong induction on n, the case n = 1 being clear.
Assume that the result holds up to n — 1 and let us prove it for 72.. Note that
gcd(a,n) = 1 since n I a” — 1, thus we can set d = ordn(a), and we have
d | 90(n), in particular (1 < n. Moreover, since a" E 1 (mod n) we have d | n,
which yields ad E 1 (mod d) (since 0." E 1 (mod n) and d | n). Thus a and d
satisfy the same hypotheses as a and n, and moreover d < n. The inductive
hypothesis shows that (oi + '01n is a complete residue system modulo d.
Assume next that ai +z' E aj + 3' (mod n) for some integers 2', j Z 0, then
a14 +i E aj + j (mod d) (since d | n) and by the previous discussion 2' E j
(mod d). But then ai E aj (mod 12.) (since a"l E 1 (mod n)), which combined
with the congruence ai +i E aj + j (mod n) yields 2' E j (mod n). The result
follows.
'
III
Example 7.85. (India 2014) Let p be an odd prime and let k be an odd positive
integer. Prove that pic + 1 does not divide pp — 1.
Proof. Suppose that this is not the case and let k be the smallest odd positive
integer for which pk + 1 I pp — 1. The order of p modulo pk + 1 divides p and
cannot be 1 (since pk + 1 does not divide p — 1), thus it must be p, which
shows that p | 90(pk + 1). Since gcd(p, pk + 1) = 1, it follows that there is
a prime q | pk: + 1 such that p | q — 1. In particular we have q > 2 and so
2p | q — 1. Write pk: + 1 = qsm with s 2 1 and m 2 1 not divisible by q.
Taking the equation pk + 1 = qsm modulo 2p and using that k is odd and
q E 1 (mod 2p) yields m E 1 + p (mod 219), thus m = 1 +up for some positive
odd integer u. Since m < pk + 1 we have u < k and since m I pk + 1 we also
have 1 + up | p” — 1. This contradicts the minimality of k and finishes the
proof.
El
444
Chapter 7. Congraences for composite moduli
We end this section with some more challenging problems.
Example 7.86. (Romania TST 2009) Prove that there are infinitely many pairs
of distinct prime numbers (p, q) such that p I 297—1 — 1 and q I 21"1 — 1.
Proof. Let F = 22" + 1 be the nth Fermat number. For each n > 1 let pn be
a prime factor of E, and let qn be a prime factor of Fn+1. Then p2, p3,
are
pairwise distinct and pn aé qn for all 17., since the Fermat numbers are pairwise
relatively prime (see example 3.12). Moreover by example 7.61 we have pn E 1
(mod 2"”) and qn E 1 (mod 2"+3). Thus pn | 22" + 1 | 22"+1 — 1 | 2‘11“1 — 1
and qn | 22"+1 + 1 | 22"+ — 1 | 21’"‘ — 1. Thus (pmqn) is a solution of the
problem for all n > 1.
El
Example 7.87. (Russia 2009) Let x and y be integers such that 2 g x, y g 100.
Prove that there exists a positive integer n such that x2" + y2n is a composite
number.
Proof. The result is clear when x = y (take n = 1), so assume that x 7E y. We
first prove that 257 | .732" + y2" for some n 2 1. Since 257 is a prime and y
is not divisible by 257 there is q such that x E qy (mod 257). Note that q is
not congruent 0, :I:1 (mod 257) thanks to the hypothesis 2 S x,y S 100 and
x ;E y. Let d = ord257(q), then d | 256 = 28 and so d = 2’“ for some k. Since
257 does not divide q :l: 1, we have k 2 2. Moreover, since 257 I q2k — 1 and
257 does not divide q2k_1 — 1, we have 257 | qzk—1L + 1. Finally, since :1: E qy
(mod 257), it follows that 257 | x2k_1 + y2k_1 and the claim is proved (take
77. = k — 1 2 1).
Suppose now that x211 + 11/2" is a prime, then necessarily x2" + 312” = 257.
Letting a = x2"_1 and b = gym, we obtain a2 + b2 = 257 and a, b > 1 (since
:13, y > 1). One easily checks by hand that this is impossible (the general result
is that a prime p E 1 (mod 4) can be written in a unique way as a sum of
two squares and in this case 257 = 162 + 12 is that way), which shows that
x2" + y2n is a composite number.
I]
Example 7.88. (AMME 2948) Let x, y be relatively prime integers greater than
1. Prove that 221,012?"1 — yp_1) is odd for infinitely many primes p.
7.3.
Order modulo n
445
Proof. If k > 2 is an integer, by theorem 3.51 and the remark following it
x2k_1 +y2k_1 is neither a perfect square nor twice a perfect square. Thus we can
find an odd prime pk such that vpk(:z:2k_1 + y2k_1) is odd. Since gcd(a:, y) = 1,
pk cannot divide my. Since it divides m2k_1 + y2k_1, example 7.79 shows that
2" divides pk — 1. The lifting the exponent lemma gives
_
_
k
1:
pk - l
k—l
k—l
)’
+ 312
”Pk(wpk 1 _ ypk 1): ”Pk($2 _ 312 )+’Upk (T) = k(x2
and the last quantity is odd by the choice of pk. The result follows by taking
successively k = 3, 4,
and observing that pk 2 1 + 2’”.
El
Example 7.89. (China TST 2005) Prove that for any n > 2 the number 22" + 1
has a prime factor greater than (n + 1) - 2"”.
Proof. The result is clear for n = 3 (note that 28 + 1 is a prime), so assume
that n 2 4. Consider the prime factorization
22" + 1 = pinupgk,
with p1 <
< pk. By example 7.61 there are positive integers q1, ..., k such
that pi = 1 + 2n+2qi. Since 2" 2 2n + 4 (as n 2 4) and p?“ E 1 + 2n+2aiq¢
(mod 22"“), we obtain
76
k
1 E 22" + 1 E H(1 + 2n+2a¢qi) E 1 + 2"+2 Zqiai
(mod 22"“),
thus
a1q1 +
+ aq Z 2n+2.
Assuming that max,-(qz-) S n, we obtain a1 +
+ ak 2 22—”, which gives
k
k
”+2 = 2%.2
n
'n, +2
2 (2n+2)2T
+ 2n+2qi)ai > H(2n+2)a,1 + 22 71 = H(1
i=1
i=1
and so 1 + 22’1 > 22"”, a contradiction.
mam-(pi) > (n + 1)2"+2, as desired.
Thus maxi(q,-) 2 n + 1 and so
El
446
Chapter 7. Congruences for composite moduli
Example 7.90. (Iran 2011) Let k 2 7 be an integer. Find the number of pairs
(15y) such that 0 S $,y < 2k and
7373“ a 99” (mod 2’“).
Proof. We start by finding the possible remainders of the numbers 1, 9, 92,
when divided by 2”, for a given integer N 2 4. We easily obtain (using
proposition 7.68 or, better, by a direct computation) that the order of 9 mod
2N is 2N‘3. Thus there are precisely 2N‘3 distinct residues modulo 2N among
those of 1, 9, 92,
As each of these residues is of the form 8k + 1 and since
there are 2N‘3 such residues, it follows that the remainders of 1, 9, 92,
are
exactly the residues mod 2” of the form 8k + 1.
Since 73 E 1 (mod 8), the previous paragraph gives the existence of u 2 1
such that 73 E 9“ (mod 2’“). Since 73 E 9 (mod 64), it follows that 9“—1 E 1
(mod 26) and the previous paragraph (with N = 6) yields u E 1 (mod 8).
Since the order of 9 modulo 2’” is 2k‘3, the congruence 73732 E 99y (mod 2’“) is
equivalent to u9“ E 97” (mod 2k_3). We need to find the number of solutions
of this congruence with a3,y 6 {0,1,...,2’° — 1} . Fix a: e {0,1,...,2’° — 1}.
Then u9‘“c E 1 (mod 8), hence by the first paragraph we can find 1) such
that 1L9“ E 9” (mod 2k‘3). Now 93’ E 9‘" (mod 2k‘3) if and only if y E 1)
(mod 21°45). There are precisely 26 such numbers y E {0,1,...,2’“ — 1}. Thus
for each a: the corresponding congruence has 26 solutions y, and so the total
number of solutions is 2k+6.
El
Example 7.91. (Iran TST 2009) Prove that for all positive integers n we have
52n—1
32"—1
3 2'":E E (—5) 2"+2
4
(mod 2n+ ).
Proof. Denote for simplicity 52" — 1 = b and 32" — 1 = c. One easily checks,
using either the lifting the exponent lemma or the formula
x2" — 1 = (a: — 1)(11: + 1)(:I:2 + 1)...(:t;
2n—1
+ 1),
that v2(b) = 122(0) = n + 2, thus 2Tb” and 27?}; are odd integers and the
congruence can also be written as
(_3)2—,.'a:2 5 52+” (mod 2n+4).
7.3.
Order modulo n
447
Next, by example 7.60 there is a 2 1 such that —3 E 5“ (mod 2””). The
previous congruence becomes
52+};2 E 52++2
(mod 2”“).
Since the order of 5 modulo 2n+4 is 2’"+2 (see example 7.60), this last congruence is equivalent to
ab
c
W E W
(mod 2714-2)
or ab E c (mod 22"“).
Next, observe that if x,y are odd integers with a: E 3/ (mod 2’“) for some
k: 2 1, then 532’" E y2m (mod 2’7“”) for all m 2 1. This follows immediately
by induction, or using the formula
:62“ — yzm = (a: - y)($ + was2 + y2)~-(562m_1 + :12“)Since —3 E 5“ (mod 2"“), we deduce that 32" E 5”" (mod 22”“). Hence
a
1+CE(1+b)“=1+ab+ (2 )b2 +
(mod 22”“).
Since v2(b) = n + 2, the last congruence is equivalent to c E ab (mod 22““),
which is exactly what we needed.
El
Example 7.92. (China TST 2004) Prove that for any integer m > 1 there is a
prime number p Which does not divide nm — m for any integer n.
Proof. Choose a prime factor q of m. We will prove in the next paragraph that
we can find a prime p such that p | mq — 1, p does not divide m — 1 and finally
gcd(p — 1, gm) | m. We claim that such p is a solution of the problem. Indeed,
assuming that p | nm — m for some n, we obtain nmq E mq E 1 (mod p), so
d := ordp(n) satisfies d | mq. Since d | p — 1, we have d | gcd(mq,p — 1) | m
and so p | nm — 1. Since p | Tim — m, we conclude that p | m — 1, contradicting
the choice of p.
We prove now the existence of p. Letting k = u, (m), the number
A:
mq—l
1 =1+m+m2+...+m‘1‘1
448
Chapter 7. Congruences 'for composite moduli
is congruent to 1+m modulo q,“+1 and so it is not congruent to 1 modulo qk'l'l.
It follows that A has a prime factor p which is not congruent to 1 modulo qk‘H.
Then clearly p | m9 — 1 and gcd(p — 1,mq) | m. We cannot have p | m — 1,
since otherwise p = q (as p | A = 1 + m + + rnq—1 and p | m — 1 force
p | q) and q | m — 1, a contradiction with q | m. Thus p satisfies all desired
conditions and the problem is solved.
III
Remark 7.93. The case when m is a prime was one of the problems given at
IMO 2003.
7.3.3
Primitive roots modulo n
We have already seen that for any positive integer n and any integer a
relatively prime to n the order modulo n of a divides <p(n) and in particular
it cannot exceed go(n). We are interested in this section in characterizing
those it for which this bound is attained, i.e. for which there is a such that
gcd(a, n) = 1 and ordn(a) = Lp(n). Let us give a name to such numbers a.
Definition 7.94. Let n be a positive integer. An integer a is called a primitive
root modulo n if gcd(a, n) = 1 and ordn(a) = <p(n).
It is clear that if a is a primitive root modulo n and if b E a (mod n), then
b is also a primitive root modulo n. Note that an integer a relatively prime
to n is a primitive root modulo n if and only if 1, a, ..., a‘PW-1 give pairwise
distinct remainders modulo n. This yields the following useful observation.
Proposition 7.95. Let a be an integer relatively prime to a positive integer
n. The following statements are equivalent:
a) a is a primitive root modulo n;
b) 1, a, a2, ..., (WU-1 is a reduced residue system modulo n;
c) For any integer a: relatively prime to it there is a positive integer k such
that a: E ak (mod n).
Let us give a few simple examples: the primitive roots modulo 2 are the
odd integers, the primitive roots modulo 3 (respectively 4) are the integers of
the form 3k + 2 (respectively 4k + 3). Similarly, the primitive roots modulo 5
7. 3.
Order modulo n
449
are integers of the form 5k + 2 or 51:: + 3 and the primitive roots modulo 6 are
integers of the form 6k + 5.
The next proposition gives a useful criterion for proving that an integer a
is a primitive root mod n.
Proposition 7.96. Let n > 1 be an integer and let a be an integer such that
gcd(a.,n) = 1. Then a is a primitive root mod n if and only if n does not
M
divide a 4 — 1 for all primes q|<p(n).
M
Proof. If a is a primitive root mod n, then n does not divide a a
— 1 since
otherwise 90(n) = ordn(a) would divide $411.
Conversely, suppose that n does not divide aflq22 — 1 for all primes q|go(n),
and let d = 0rdn ((1). Then d | ¢p(n) and by assumption d does not divide A?
for any prime factor q of cp(n). It follows that Eddy is a divisor of <p(n) which
is not divisible by any prime factor of <p(n), thus Zldfll = 1 and a is a primitive
D
root mod n.
We illustrate the previous proposition with a few concrete examples, some
of which use intensively results about quadratic residues discussed in chapter 4.
Example 7.97. Prove that 2 is a primitive root modulo 29 and solve the con-
gruence
1+a;+...+ar;6 E0 (mod 29).
Proof. By proposition 7.96, it suflices to check that 214 and 24 are not con-
gruent to 1 modulo 29. This is clear for 24, and follows for 214 from
214 E (25)2 - 24 a 32 - 16 = 3-48 5 —30 a —1 (mod 29).
Thus 2 is a primitive root modulo 29 (one could also observe that 29 E 5
(mod 8), hence (525) = —1 and 214 E —1 (mod 29)).
Suppose that x is not congruent to 1 modulo 29, then 1 + .7: +
+ m6 E 0
(mod 29) if and only if x7 E 1 (mod 29). Write a: E 2k (mod 29) for some
0 S k S 27, which is possible since 2 is a primitive root modulo 29. Then
2:7 E 1 (mod 29) if and only if 28 | 7k, that is 4 | k. We deduce that the
solutions of the congruence are 24’“ for 1 g k g 6.
El
450
Chapter 7. Congruences for composite moduli
Example 7.98. (Putnam 1994) For a nonnegative integer a let
na = 101a — 100- 2a.
Prove that if a, b, c,d E {0, 1, ...,99} satisfy na + m, E nC + nd (mod 10100),
then {a, b} = {c,d}.
Proof. The congruence na + nb E nc + nd (mod 10100) is equivalent to the
simultaneous congruences a + b E c + d (mod 100) and 2“ + 2" E 2c + 2"
(mod 101). Since 101 is a prime number, Fermat’s little theorem combined
with a + b E c+ d (mod 100) yield 2“ - 2" E 26 - 2‘1 (mod 101). It follows that
m—rmrdhsm:rmn4%(mnmn
and so (2“ — 2c)(2“ — 2“) E 0 (mod 101). By symmetry, we may assume
that 2“ E 2c (mod 101), thus ord101(2) | a — c. We will prove below that
ord101(2) = 100, which yields a = c and then b = d.
It remains to prove that 2 is a primitive root modulo 101. By proposition
7.96, it suflices to prove that 220 - 1 and 250 — 1 are not multiples of 101. For
220 — 1 we observe that
m=wWEWE%(mmw.
For 250 — 1 one can use a similar computation, or, more elegantly, use Euler’s
criterion (theorem 5.99) and the fact that (1—01)=_1 (use theorem 5.125 and
the congruence 101=
_ 5 (mod 8)).
III
Example 7.99. Let p > 3 be a Fermat prime, i.e of the form 2” + 1 for some
integer n > 1. Prove that 3 is a primitive root mod p.
Proof. Since <p(p)=
— 1—
— 2", by proposition 7.96 it suffices to prove that
3L21— 1 IS not divisible by p, which 1s equivalent by Euler’s criterion (theorem
5.99) to (g) = —1. Using the quadratic reciprocity law (theorem 5.124) we
obtain
(as—veers
the last equality being a consequence of the fact that p E 1 (mod 4) and p E 2
(mod 3). The result follows.
E]
7.3.
Order modulo n
451
Example 7.100. Let q E 1 (mod 4) be a prime such that p = 2g + 1 is also
prime. Prove that 2 is a primitive root modulo p.
Proof. Again, by proposition 7.96 it suflices to prove that 2L
2 — 1 and 21:4 — 1
are not divisible by p. This is clear for 2L
9 — 1—
— 3, so it remains to prove
that (%)_
— —1 (by Euler’s criterion, theorem 5.99). This follows from theorem
5.125 and the fact that p E 3 (mod 8).
III
Remark 7.101. A famous conjecture of Artin implies the existence of infinitely
many primes p for which 2 is a primitive root modulo p. The previous example
shows that this would follow from the existence of infinitely many primes q E 1
(mod 4) for Which p = 2q + 1 is also a prime.
A natural question is whether for any positive integer n there are primitive
roots modulo n. The answer is unfortunately negative: since any odd integer
(1 satisfies a2 E 1 (mod 8), the order of any odd integer modulo 8 is 1 or 2,
so there are no primitive roots modulo 8. Similarly one easily checks that
there are no primitive roots modulo 2" for n > 2. More precisely we have the
following result.
Proposition 7.102. Let n be a positive integer for which there are primitive
roots modulo n. Then n = 1, 2, 4, pk or 2p,“ for some odd prime p and some
positive integer k.
Proof. Suppose that n has primitive roots modulo n and is not of the form
indicated in the proposition. Note that n is not a power of 2 greater than 4,
by the discussion preceding the proposition. It is then immediate to see (by
considering the prime factorization of n) that we can write n = ab for two
relatively prime numbers a, b > 2. Since a, b > 2, the numbers 90(a) and <p(b)
are even, thus for all integers a: relatively prime to n Euler’s theorem yields
mfl'zfl = x‘P(a)'fl2b_) E 1
(mod a)
and similarly a: (Tn) ._
=1 (mod b). Since gcd(a, b)—
— 1, we infer that crfl2fl=
_ 1
(mod n) and so ordn (at) | £21) for any a: relatively prime to n. It follows that
there are no primitive roots modulo n, a contradiction.
III
452
Chapter 7. Congruences for composite moduli
A remarkable theorem due to Gauss states that the converse of the previous
result holds, giving a complete description of all positive integers n for which
there are primitive roots modulo n.
Theorem 7.103. (Gauss) Let n be a positive integer. The following statements are equivalent:
a) There are primitive roots modulo n.
b) n is equal to 1, 2, 4, pk or 2p’c for some odd prime p and some k: 2 1.
We have already established one implication. The other implication lies
deeper and we will establish it in a series of steps, each of which is interesting in
its own right. The most delicate part is establishing the existence of primitive
roots modulo odd primes, a task to which we focus our attention.
Theorem 7.104. Let p be an odd prime. For any positive divisor cl of <p(p) =
p— 1 there are exactly <p(d) numbers n 6 {1,2, ...,p— 1} such that ordp(n) = d.
In particular, there are <p(p — 1) 2 1 primitive roots modulo p.
Proof. Let f(d) be the number of integers n 6 {1,2, ...,p—1} with 0rd,,(n) = d.
We will prove below that f (d) S (,0(d) for all d I p — 1. Assuming this, we
obtain
2 f(d) S 2 $00 =p—1,
dIP-l
dlp-l
the last equality being a consequence of Gauss’ theorem 4.112. Since 0rd,,(n) I
p— 1 for all n 6 {1,2, ...,p— 1}, we clearly have Zd|p_1 f(d) = p— 1. It follows
that all the inequalities f(d) S <p(d) must be equalities and the theorem is
proved.
We still need to prove that f (d) S <p(d). This is clear if f (d) = 0, so assume
that there is n 6 {1,2, ...,p— 1} with ordp(n) = d. By Lagrange’s theorem 5.69
and the fact that 77., n2, ..., nd are pairwise distinct solutions of the congruence
and E (mod p), it follows that all solutions of this congruence are given by
the remainders mod p of n,n2, ...,nd. Hence if m 6 {1,2, ...,p — 1} has order
d modulo p, then m E nj (mod p) for some 1 S j S d. Since ordp(m) =
d, proposition 7.66 gives gcd(j, d) = 1, which proves that f (d) S <p(d): all
numbers m 6 {1,2,..., p — 1} with order d modulo p must be among the
remainders modulo p of the numbers nj with j a totative of d. The theorem
is therefore proved.
III
7.3.
Order modulo n
453
Remark 7.105. 1) The most diflicult part of the proof of theorem 7.104 is the
existence of a primitive root modulo p. Indeed, if a. is a primitive root modulo
p, then any n E {1,2,...,p — 1} is congruent to ak for some 0 S k S p — 2,
and proposition 7.66 shows that ordp(n) = d if and only if god 111* = d, i.e.
k = p;_1 - 6, with e a totative of d. Thus there are cp(d) such integers n.
2) Here is a slightly different, but quite nice way of proving theorem 7.104.
Let f(d) be the number of integers n 6 {1,2, ...,p — 1} with 0rd,,(n) = d. We
claim that for any d I p — 1
EN) = d.
eld
A number a: E {1,2,...,p — 1} satisfies xd E 1 (mod p) if and only if
e := 0rdp (1:) is a divisor of d, thus the left-hand side is precisely the number
of solutions of the congruence azd _=_ 1 (mod p), which is d by theorem 5.78.
Using a version of the M6bius inversion formula (see part 3 of remark 4.125),
we obtain
M) = 2mg = <p(d),
eld
as needed. The same argument is used in the next example.
Example 7.106. (Iran TST 2003) Let a1, ...,ak be all primitive roots modulo
an odd prime p. Prove that
a1 +a2+...+a;c Eu(p— 1)
(modp).
Proof. For each d | p — 1 set
f(d)=
Z
xdal
x (modp),
(mod p)
i.e. f (d) is the remainder mod p of the sum of the solutions of the congru-
ence 33" E 1 (mod p). By theorem 5.78 this congruence has d solutions, say
931, ..., cud. Lagrange’s theorem 5.69 yields
Xd _ 1 E (X — x1)(X — 1132).”(X — zed)
(mOd p):
454
Chapter 7. Congruences for composite moduli
and looking at the coefficient of X‘14 we obtain
f(d) E 231 +
+ :34 E 0
(mod p)
for d > 1. Thus f(d) = 0 for d > 1 and clearly f(1) = 1. On the other hand,
it is clear that
f<d>=zg<u), where g<d>= Z x (mod p)
uld
ordp(:t)=d
is the remainder mod p of the sum of all numbers :1: 6 {1,2, ..., p — 1} with
ordp(:c) = d. Taking into account the values of f, the result follows by a
version of the Mobius inversion formula (see remark 4.125).
El
The next example gives a different proof of the existence of primitive roots
modulo p.
Example 7.107. a) Let n be a positive integer and let a1,...,ad be integers
relatively prime to n. Prove that there is an integer c relatively prime to n
such that
0rd,,(c) = lcm(ordn(a,1), ..., ordn(ad)).
b) Deduce that there are primitive roots modulo 1) for any odd prime p.
Proof. a) Let M = lcm(ordn(a1), ...,ordn(ad)) and assume that M > 1, the
case M = 1 being clear. Let M = p‘l“1...pg" be the prime factorization of
M and fix 1' E {1,2,...,k}. Since p?“ | lcm(ordn(a1),...,ordn(ad)), there is
9:; E {(11, ...,ad} such that pf“ | ordn(a;i). By proposition 7.66 the number
ordngzi)
q = xi pi
has order pf" modulo n.
Choosing c = 0162...ck we obtain
ordn (c) = M. Indeed, it is clear that 0M E 1 (mod n), since 01M E 1 (mod n)
N- M.
for all 2'. On the other hand, if ON a 1 (mod n), then c 51-"— E 1 (mod n),
N437
which simplifies to ci p"
E 1 (mod n). This yields pf“ | N - 51%, which in
turn gives pf“ | N for all 12, thus M | N. We conclude that ordnlc) = M, as
needed.
7. 3.
Order modulo n
455
b) Let
k = lcm(ordp(1),ordp(2), ..., 0rd,,(p — 1)).
By part a) we can write k = 0rd,,(s) for some 3 relatively prime to p. By
construction ak E 1 (mod p) for all a E {1, 2, ..., p— 1}, thus for all a relatively
prime to p. Corollary 5.76 yields p — 1 | k and so p — 1 | 0rd,,(s) | p — 1. It
follows that s is a primitive root mod 10.
III
We end this section explaining the proof of theorem 7.103. The key technical ingredient is given by the following result, which is a simple consequence
of the lifting the exponent lemma, more precisely of proposition 7.68.
Theorem 7.108. Let p be an odd prime and let a be a primitive root mod p.
a) a is a primitive root modulo p2 if and only if v1,(al"‘1 — 1) = 1.
b) If a is a primitive root mod p2, then a is a primitive root mod p” for all
n 2 1.
Proof. a) Proposition 7.68 gives
ordp2(a) = (p — 1) -p2'”,
where v = vp(a1"1 — 1). Since a is a primitive root mod p2 if and only if
ordp2(a) = p(p — 1), the result follows.
b) This follows immediately from proposition 7.68 and part a).
El
Remark 7.109. Suppose that a 6 {1,2, ...,p — 1} is a primitive root modulo
p. It can (rarely) happen that p2 | up—1 — 1, in other words it is not true in
general that a is a primitive root modulo p2. For instance one can prove that
5 is a primitive root modulo p = 40487 and 51"1 E 1 (mod p2).
We can now easily finish the proof of theorem 7.103. We need to prove
that there are primitive roots modulo p” and 21)” for any odd prime p and
any n 2 1. Choose a primitive root a modulo p and observe that a + p is also
a primitive root modulo p. We claim that one of the numbers a and a + p is
a primitive root modulo p2. Indeed, if neither of them is then the previous
theorem yields p2 | (JP—1 — 1 and p2 I (a,+p)p_1 — 1. Using the binomial formula
we obtain
—1
(a +p)”‘1 — 1 E a‘"1 — 1 + (p 1 )ap'2p (mod p2)
456
Chapter 7. Congruences for composite moduli
and we conclude that p2 I (p — 1)pap_2, which is clearly impossible. This
proves the existence of a primitive root b (equal to a or a + p) which is also
a primitive root mod p2. Then b is a primitive root mod p” for all n 2 1
by the previous theorem. Finally, note that one of the numbers b and b + p"
is odd, thus we may assume (possibly by replacing b with b + p") that b
is odd. Since 90(2p”) = <p(p”) and since 0rd,," (b) = <p(p”), we clearly have
ordgpn (b) = <p(2p”) and so b is a primitive root mod 2p". Theorem 7.103 is
thus proved.
We end this rather long section with a few concrete examples in which the
concept of primitive roots modulo 11. plays a key role.
Example 7.110. a) Prove that an odd prime p is congruent to 1 mod 8 if and
only if the congruence x4
—1 (mod p) hasLsolutions.
b) Deduce that if p=
_=
1 (mod 8) then 22 _
=1 (mod p).
Proof. a) If p E 1 (mod 8), take a: = yrs—1 with g a primitive root mod p.
Then ordp(:n) = 8, thus :08 E 1 (mod p) and m4 is not congruent to 1 mod p.
It follows that x4 E —1 (mod p), which proves one implication. Conversely,
suppose that there is a: such that 9:4 E ——1 (mod p). Then ordp(:c) = 8 since
ordp(a:) divides 8 and does not divide 4. Since ordp(:r) | p — 1, we have p E 1
(mod 8) and we are done.
b) Take cc such that :34 E —1 (mod p). Then gcd(p,:z:) = 21, so there is an
integer y such that zy_
= 1 (mod p). Let2 z = a: + y, then 22 E2 + m2 + 3,!2
(mod p). On the other hand x4y2= —y2 (mod p) and $4312.: 51:2 (mod p),
thus p | x2 + y2 and so z2_
= 2 (mod p). It follows that 1_=—zp_1_= 2&5”
(mod p) and we are done.
[I
The next example gives a very conceptual proof of corollary 5.77.
Example 7.111. Prove that for all primes p and all positive integers n we
have 1" + 2” +
+ (p — 1)” E 0 (mod p) if p — 1 does not divide n, and
1"+...+(p—1)nE—1 (modp) ifp—1 In
Proof. If a is a primitive root mod p, then 1, 2, ..., p — 1 are congruent mod p
to a permutation of 1,a, ..., Lip—2, hence
1"+2"+.. .+=(p—1)"
1+a‘" +a2"+...+a(1’2)".
7. 3.
Order modulo n
457
The last expression can be easily computed: if p — 1 | n, then an E 1 (mod p),
hence 1” +
+ (p — 1)” Ep— 1 E —1 (mod p), while ifp— 1 does not divide
n, then a” is not congruent to 1 mod p, and
(an — 1)(1 + a" +
hence 1 + a” +
+ 0.094)") = a(p_1)” — 1 E 0 (mod p),
+ a(P_2)"' E 0 (mod p) and we are done.
III
Example 7.112. Let a, n, k be integers with n, k > 0 and gcd(a,n) = 1. Suppose that there are primitive roots mod 7%., and let d = gcd(k, go(n)).
a) Prove that the congruence x,“ E a (mod n) has solutions if and only if
(1n2 E 1 (mod n), and in this case the congruence has d solutions.
b) For how many integers a E {0, 1, ...,n — 1} relatively prime to n does
the congruence wk E a (mod n) have solutions?
Proof. 3.) Let g be a primitive root modulo n. If at" E a (mod n), then
gcd(m,n) = 1 since gcd(a, n) = 1. Thus we can write a: E gj (mod n) and
a E 9“ (mod n) for unique integers j, u e {0, 1, ..., <p(n) — 1}. The congruence
ark E a (mod n) is then equivalent to 9“” E 1 (mod n) and to kj E u
(mod go(n)). This linear congruence (the "unknown“ being 3') has solutions
if and only if u is a multiple of d, and if this is the case the congruence has
exactly d solutions. On the other hand, the congruence (1491 E 1 (mod n) is
equivalent to gufldfl E 1 (mod n), then to 119%”) E 0 (mod <p(n)) and finally
to u E 0 (mod d). The result follows.
b) By a) we need to find the number of solutions of the congruence afldflz E
1 (mod 77.). By the proof of part a), this amounts to finding the number of
integers u e {0, 1, ...,<p(n) - 1} such that u E 0 (mod d), which is exactly
m
D
Remark 7.113. By taking n = p an odd prime and k = 2, we recover Euler’s
criterion and the formula for the number of quadratic residues mod 1).
Example 7.114. Prove that the number of solutions of the congruence con—1 E 1
(mod n) is ln gcd(p — 1,n — 1).
458
Chapter 7. Congruences for composite moduli
Proof. Let n = p‘flupgk be the prime factorization of n and let a, be the
number of solutions of the congruence 191—1 E 1 (mod pf”). By the Chinese
remainder theorem (more precisely by theorem 7.9), it suffices to prove that
H111 ai= H111 gcd(p,-— 1, n — 1.) We will prove that a,—
— gcd(p,-— 1, n — 1)
for 1 < i < k. If p,- > 2 thenpa‘has primitive roots and so (by the previous
example) the congruence flan—11,2” 1 (modpia“) has
gcd(n —1 <p<p°“>)=gcd(n— 1pa.—1(p,_1))=gcd(,,_1,p,_1)
solutions, as desired. A similar argument works when p, = 2 and a, > 2.
Suppose that p, = 2 and a, e {1, 2}, we need to prove that the congruences
#4 E 1 (mod 2) and (En—1 E 1 (mod 4) have exactly one solution when
112(1).) = 1 and 122 (n) = 2 respectively. This is clear.
El
Example 7.115. (AMM E 3212) Is it true that if n is sufliciently large and
a1, a2, ..., an is an arbitrary permutation of 1, 2, ..., n, then we can find integers
i, d such that 1 S i < i+ d < i+ 2d 3 n and oi, 0.51.4, ai+2d form an arithmetic
progression?
Proof. The answer is negative. If p is an odd prime, let 9 be a primitive
root mod p and consider the permutation a1, ..., ap_1 of 1, 2, ..., p — 1 defined
by a,- E 9i (mod p). If a,,a,~+d,a,-+2d form an arithmetic progression, then
—1)2 E 0 (mod p). This forces gd E
— 29Hd (mod p) and so (gd—
gi + gi+2d=
(mod p), hence p — 1 | d and d 2 p— 1, a contradiction.
III
Example 7.116. (K6mal) Is there a positive integer n such that every nonzero
digit (in base ten) appears the same number of times in the decimal representation of each of the numbers n, 217., 3n, ..., 201677,?
Proof. Suppose that there is a prime p > 2016 such that 10 is a. primitive root
— 101!"1 — 1. Arguing as in
modulo p. Consider an integer n such that n p—
the proof of example 7. 75, we see that the periods of the fractions %, g," "E1?
are obtained by cyclic permutations of the period of 11—), and the decimal representations of the numbers n, 211., 311., ..., 2016n are also obtained by cyclic
permutations of the digits (with an appropriate number of leading zeroes),
hence n is a solution of the problem.
7.3.
Order modulo n
459
We prove now the existence of such a prime p. We will check that p =
216 + 1 works. It is well-known (and not difficult to prove) that p is indeed
a prime. The order of 10 modulo p divides p_—— 1—
— 216, thus if the order is
not p — 1, then it must divideL
2 1and so 10?—
2 —
:1 (mod p). It follows that
(2)
- 1 (as p:
— 1 (mod 8))
p - (§)—
p — (E)—
p — 1, which 1s impossible, since (% )—
and (1—5,) = (g): (g): —1 (we used here the quadratic reciprocity law and
the fact that p=
_ 2 (mod 5)).
III
Remark 7.117. It is not known whether 10 is a primitive root modulo p for
infinitely many primes p. This is a special case of a famous conjecture due
to Artin, stating that any integer a. gé —1 which is not a perfect square is a
primitive root modulo p for infinitely many primes p.
Emample 7.118. (USA TST 2010) Is there a positive integer k such that p =
6k: + 1 is a prime and (3:) E 1 (mod 1))?
Proof. The answer is negative. Suppose that p = 6k+1 is a. prime and (3:) E 1
(mod p). Let g be a primitive root mod p and let 2—
— 9.6 Then 2 has order k
mod p, hence 2:101 2” is 0 modulo p, unless j is a multiple of k. We deduce
that
.-
i=0
we > 55W
1—0 j-O
—o
3
i=0
( 32?) + (3:) + (33:) + (39%
= (2 + 2(3:)) k E 4k
(mod p).
On the other hand, for all 0 S i S k — 1 we have
(1 + zi)3k E (1 + 255—1 E —1,0, 1
(mod p).
However we cannot have k remainders mod p, each of them —1, 0 or 1, adding
up to 4k modulo p. The result follows.
El
460
7.4
Chapter ’7. Congmences for composite moduli
Problems for practice
The Chinese remainder theorem
(Poland 2003) A polynomial f with integer coefficients has the property
that gcd(f (a), f (b)) = 1 for some integers (1 7E b. Prove that there is an
infinite set of integers S' such that gcd(f(m), f (77.)) = 1 whenever m, n
are distinct elements of S.
Prove that for all positive integers k and n there exists a set S of 72
consecutive positive integers such that each a: E S has at least k distinct
prime divisors that do not divide any other element of S.
A lattice point is called visible if its coordinates are relatively prime
integers. Prove that for any positive integer Is: there is a lattice point
whose distance from each visible lattice point is greater than k.
a) Prove that for all n > 1 there is a positive integer a such that
a, 20., ..., no are all perfect powers.
b) (Balkan 2000) Prove that for all n 2 1 there is a set A of n positive
integers such that for all 1 _<_ k S n and all 1:1, :62, ..., wk 6 A the number
W51 is a perfect power.
Let a, b, c be pairwise distinct positive integers. Prove that there is an
integer n such that a + n, b + n, c + n are pairwise relatively prime.
(AMM) Prove that there are arbitrarily long sequences of consecutive
integers, none of which can be written as the sum of two perfect squares.
Let f be a nonconstant polynomial with integer coefficients and let n
and k be positive integers. Prove that there is a positive integer a such
that each of the numbers f(a.),f(a + 1), . . . ,f(o. + n — 1) has at least k
distinct prime divisors.
(IMC 2013) Let p and q be relatively prime positive integers. Prove that
1332—1) ”:3“t _ 0
k=0
1
iq is even
if pq odd
7.4.
Problems for practice
461
(IMO 1999 Shortlist) Find all positive integers n for which there is an
integer m such that 2” — 1 | m2 + 9.
10. (Bulgaria 2003) A finite set C of positive integers is called good if for
any k E Z there exist a 7E b 6 C such that gcd(a + k,b+ k) > 1. Prove
that if the sum of the elements of a good set 0 equals 2003, then there
exists c E C such that the set C — {c} is good.
11. Is there a sequence of 101 consecutive odd integers such that each term
of the sequence has a prime factor not exceeding 103?
12. (USA TST 2010) The sequence (0%)“,21 satisfies a1 = 1 and
an = “Ln/2] + “Ln/31+“-+ aLn/nJ + 1
for all n 2 2. Prove that an E n (mod 22010) for infinitely many n.
13. (China TST 2014) A function f : N —> N satisfies for all m,n Z 1
gcd(f(m),f(n)) S gcd(m,n)2014
and
n S f(n) g n + 2014.
Prove that there is a positive integer N such that f(n) = n for n 2 N.
Euler’s theorem
14. (Iran 2007) Let n be a positive integer such that gcd(n, 2(21386 — 1)) = 1.
Let a1, a2, . . . ’a¢(n) be a reduced residue system modulo n. Prove that
nlaim + @386 + - . - + am;
15. Let n > 1 be an integer and let r1,r2, ""r<p(n) be a reduced residue
system modulo n. For which integers a is n + a, 7'2 + a, ..., 77pm) + a a
reduced residue system modulo n?
16. Prove that any positive integer n has a multiple whose sum of digits is n.
17. For which integers n > 1 is there a polynomial f with integer coefiicients
such that f (k) E 0 (mod n) or f (k) E 1 (mod n) for any integer k, and
both these congruences have solutions?
Chapter 7. Congruences for composite moduli
462
18 (Saint Petersburg 1998) Is there a nonconstant polynomial f with integer
coefficients and an integer a > 1 such that the numbers f (a), f ((12),
f(a,3), are pairwise relatively prime?
19. a) (IMO 1971) Prove that the sequence (2” — 3)n21 contains an infinite
subsequence in which every two distinct terms are relatively prime.
b) (Romania TST 1997) Let a > 1 be a positive integer. Prove the same
result as in a) for the sequence (a.""’1 + a” — 1)n21.
20. (China TST 2005) Integers ao,a1, ..., an and $0,131, ...,xn satisfy
(103:8 + alw’f +
+ 01156:: 0
for all 1 S k S 7‘, Where 7' is a positive integer. Prove that m divides
aoxgn+a1x’f‘+...+anzvgn for all r+1 _<_ m S 2'r+1.
21. (Hong Kong 2010) Let n be an integer greater than 1 and let 1 3 (11 <
< oh 3 n be the totatives of n. Prove that for any integer a relatively
prime to n we have
¢(’n) _
k
.
a__1 E Z i [3%]
n
i=1 aaz-
(mod n)
n
22. (Kamal) Let 3:1, (1:22 ..., xn be integers such that gcd(x1, ..., (on) = 1. Prove
that if 35 = $3 + 23% +
+ as?“ then
gcd(sl,32, ...,sn) | lcm(1,2, ....,n)
23. (Brazil 2005) Let a and c be positive integers. Prove that for any integer
b there is a positive integer a: such that
a” +a: E b
(mod c).
24. (Ibero American 2012) Prove that for any integer n > 1 there exist n
consecutive positive integers such that none of them is divisible by the
sum of its digits.
7.4.
Problems for practice
463
Order modulo 11
25. (Russia 2006) Let a: and y be purely periodic decimal fractions such that
:1: + y and my are purely periodic decimal fractions with period length T.
Prove that the lengths of the periods of a: and y are not greater than T.
26. (Iran 2013) Let p be an odd prime and let (1 be a positive divisor of p— 1.
Let S be the set of integers a: E {1, 2, ...,p — 1} for which the order of a:
modulo p is d. Find the remainder of 111.63 113 when divided by p.
27. Let a, b, n be positive integers with a 7E b. Prove that
n_ n
2n|go(a"+b") and n|<p(aa_;:).
28.
Find all primes p and q such that p2 + 1|2oo34 + 1 and q2 + 1|2003P + 1.
29. (MOSP 2001) Let p be a prime number and let m, n be integers greater
than 1 such that n|mp(“_1) — 1. Prove that gcd(m"_1 — 1, n) > 1.
30. a) (Pepin’s test) Let n be a positive integer and let k = 22" + 1. Prove
that k is a prime if and only if 1643? + 1.
b) (Euler-Lagrange) Let p E —1 (mod 4) be a prime. Prove that 2p + 1
is a prime if and only if 2p+ 1|2p — 1.
31. Let p > 2 be an odd prime and let a be a primitive root modulo p. Prove
—1
that are— E —1 (mod p).
32. Suppose that n > 1 is an integer for which there are primitive roots modulo n. Prove that the set {1, 2, ..., 77.} contains exactly <p(<p(n)) primitive
roots modulo 77..
33. Let p be an odd prime. Prove that p is a Fermat prime (i.e. of the form
2” + 1 with n 2 1) if and only if every quadratic non-residue mod p is a
primitive root mod p.
464
Chapter 7. Congruences for composite moduli
34. Let Mn) be the least positive integer k such that 11:,“ E 1 (mod n) for all
a: relatively prime to n. Prove that
a) If k is a positive integer such that 33’“ E 1 (mod n) for all a: relatively
prime to n, then k is a multiple of Mn)
b) A(mn) = lcm()\(m), A(n)) for m, n relatively prime.
0) We have A(n) = 90(n) when n = 2, 4 or a power of an odd prime, and
M2”) = 2"—2 for n 2 3.
d) For each n, the set of numbers ordn(a:) (over all a: relatively prime to
n) is precisely the set of positive divisors of /\(n).
35. Let p > 2 be a prime and let a be a primitive root mod p. Prove that
—a is a primitive root mod 1) if and only if p E 1 (mod 4).
36. (Unesco Competition 1995) Let m,n be integers greater than 1. Prove
that the remainders of the numbers 1”, 2”, ..., m" modulo m are pairwise
distinct if and only if m is square-free and n is relatively prime to <p(m).
37. (adapted from Tuymaada 2011) Prove that among 2500 consecutive positive integers there is an integer n such that the length of the period of
the decimal expansion of 51- is greater than 2011.
38. Is there a positive integer which is divisible by the product P of its digits
and such that P is a power of 7 greater than 102016?
39. Let m,n be positive integers. Prove that there is a positive integer k
such that 2’“ E 1999 (mod 3'") and 2’” E 2009 (mod 5").
40. (Iran 2012) Let p be an odd prime. Prove that there is a positive integer
a: such that a: and 4:1; are both primitive roots modulo 10.
41. (Brazil 2009) Let p,q be odd primes such that q = 219 + 1. Prove that
there is a multiple of q whose sum of digits is 1, 2 or 3.
42. (Brazil 2012) Find the least positive integer n for which there is a positive
integer k such that the last 2012 decimal digits of n,“ are all 1’s.
7.4.
Problems for practice
465
43. (Nieuw Archief voor Wiskunde) Suppose that a 2 113021—50 = 143067....
Prove that for any n 2 1, any sequence of n digits (between 0 and 9)
occurs as a sequence of consecutive digits in the last [an] digits of some
power of 2.
44. Find all sequences of positive integers (an)n21 such that
a) m — n I am — an for all positive integers m, n;
b) If m, n are relatively prime, then am and an are relatively prime.
45. (adapted after China TST 2012) Let n > 1 be an integer. Find all
functions f : Z —) {1,2,...,n} such that for each 16 E {1,2,...,n — 1}
there is j(k) E Z such that for all integers m we have
f(m+j(k)) E f(m+k) — f(m)
(mod n+ 1).
Chapter 8
Solutions to practice
problems
8.1 Divisibility
1. Prove that the last n + 2 digits of 52n'l'"‘"2 are the digits of 5””, completed on the left with some zeros.
Proof. This is equivalent to the congruence
L">2n"'”"'2 E 5”+2
(mod 10””).
Thus it suffices to show that 52" E 1 (mod 2“”). This follows from
theorem 2.31, i.e. from the equality
52" — 1 = 22 . (5 + 1)(52 + 1)...(52"‘1 + 1).
D
2. Is there a polynomial f with integer coefl'lcients such that the congruence
f (m) E 0 (mod 6) has 2, 3 as solutions, but no other solution in the set
{0, 1, ..., 5}?
Proof. The answer is negative. Indeed, suppose that f is such a polyno-
mial, then 3f (2) — 2f (3) is a multiple of 6.
468
Chapter 8. Solutions to practice problems
On the other hand f(2) E f(0) (mod 2), thus 3f(2) E 3f(0) (mod 6).
Similarly 2f(3) E 2f(O) (mod 6), thus 3f(2) — 2f(3) E f(O) (mod 6)
and so 6 | f (0), a contradiction.
III
. (Iran 2003) Is there an infinite set S such that for all distinct elements
a, b of s we have a2 — ab + b2 | «#19?
Proof. There is no such set S. Assuming that 8' exists, fix a E S and
choose any b > a in S. Then a.2 — ab + b2 | a2b2, but a2 — ab + b2 |
a2 (a2 — ab + b2). Taking the difference, we deduce that
(12—a,b+b2|a3b—a4
and so
a2 —ab+b2 S (13b—a4 < a3b.
Since the left-hand side is greater than or equal to $, we conclude that
b < %. Since b > a was arbitrary in S, we conclude that S is finite, a
contradiction.
I]
(Russia 2003) Is it possible to write a positive integer in every cell of an
infinite chessboard in such a manner that for all integers m, n > 100, the
sum of numbers in every m x n rectangle is divisible by m + n?
Proof. The answer is negative: assume that we managed to write positive
integers as in the statement of the problem and choose any integer n >
100, as well as an arbitrary cell of the chessboard.
Consider the (2n + 1) x (2n + 1) square centered at that cell. One can
partition this square into four n x (n + 1) or (n + 1) x n rectangles
R1, ..., R4, plus the central cell. By hypothesis the sum of the entries
in the cells of R,- is a multiple of 2n + 1 for 1 S t g 4. Also, the sum
of the entries in the cells of the square is a multiple of 4n + 2, thus a
multiple of 277. + 1. It follows that the number in the central cell is a
multiple of 2n + 1. Thus the number in each cell is a multiple of 2n + 1,
and this for all n > 100. It follows that all numbers in the cells are 0, a
contradiction.
El
8.1.
Divisibilz'ty
469
5. Prove that if k > 1 is an integer then there are infinitely many positive
integers n such that nlk" + 1.
Proof. If k is odd, then n = 2 is a solution, while if k is even, then
n = k + 1 is a solution of the problem. Starting with a solution n we
will create another one which is larger. Namely, let m = k" + 1, which
is certainly larger than n. Let us check whether n1 is a solution, i.e.
whether m | km + 1, or equivalently k” + 1 | km + 1. This will happen
if flnl (which is an integer) is odd. This is automatic if k is even, as then
m is odd.
Things are a little bit more complicated when k is odd, as then n1 =
k” + 1 is even, so it is not a priori clear that flnl is odd. However, if we
know that n is even, then k” + 1 is not a multiple of 4 (as this is the case
with any number of the form 1:2 + 1), thus "—7:- is odd and we are done.
The strategy is now clear: let no = k + 1 when k is even, and no = 2
when k is odd. Then, for j 2 0, define nj+1 = kni + 1. The previous
discussion shows that no, 721,
are all solutions of the problem.
El
(Kvant M 904) For each positive integer A with decimal representation
A=m
we set
F(A) = an + 2an_1 + - - - + 2"_1a1 + 2nao
and consider the sequence A0 = A, A1 = F(Ao), A2 = F(Al), . . . .
(i) Prove that there is a term A* of this sequence such that A* < 20 and
F(A*) = A*.
(ii) Find A* for A = 192013.
Proof. (i) If A is an one-digit number or A = 19, then one easily checks
that F(A) = A. We will show that for any other A, F(A) < A. From
this it follows that the sequence A0, A1, . . . is strictly decreasing until
the number 19 or an one digit number appears. If we denote this number
by A* we have F(A*) = A*.
470
Chapter 8. Solutions to practice problems
Suppose A has two digits and satisfies F(A) 2 A. Writing A = 10a + b,
this becomes the inequality 10a + b 3 2b + a or equivalently 9a 3 b.
Since a in nonzero, and b is a single digit, we have 9 3 9a 3 b S 9, hence
we must have equality throughout, thus a = 1 and b = 9 and A = 19. If
A has n + 1 digits for some n 2 2, then A 2 10”. Hence
F(A)=an+2an—1+-~+2”‘1a1+2"ao39+2.9+...+2n.9
=9(2"'+1 —1)< 72-2‘n-2 < 10” SA.
Thus we have shown that F(A) < A unless A is a single digit or A = 19,
as desired.
(ii) Note that
2"A — F(A) = (20" — 1)an + 2(20’1-1 — 1)an_1 + - - - + 2n-1(20 — 1)a1
is divisible by 19. So, if A is divisible by 19 then F(A) is also divisible
by 19 and therefore all terms of the sequence are divisible by 19. Now
if A = 192013 then all terms of the sequence are divisible by 19 and
therefore A* = 19.
[I
Are there infinitely many 5-tuples (a, b, c, d, e) of positive integers such
that1<a<b<c<d<eanda|b2—1,b|c2—1,c|d2—1,d|e2—1
and e | a2 — 1?
Proof. The answer is positive. The easiest way to ensure that b | c2 — 1,
cl d2—1 andd | 62—]. istotakeb=c—1,c=d—1 andd=e—1. This
reduces the problem to finding infinitely many pairs (a, b) with 1 < a < b
and b+3 I a2—1, a | b2—1. Simplytakeb=2a—1witha> 1 and
observe that a | b2 — 1 and b+3=2(a+1) | a2 — 1 ifa is odd.
El
(Romania JBMO TST 2003) Let A be a finite set of positive integers
with at least three elements. Prove that there are two elements of A
whose sum does not divide the sum of the other elements of A.
8.1.
Divisibz'lity
471
Proof. Let a1 < a2 <
< a], be the elements of
a, + aj divides 21¢,”- a; for all i 79 j. Then a,- +
a1 + a2 + + a], for all 2' 7E j. In particular, there
:13,- such that S = xi(ak+a,-) for 1 S i < k. Since (11
follows that .731 > 332 >
> xk_1. Moreover at, > 1
A, and assume that
a,- also divides S =
are positive integers
< (Q <
< ak_1, it
for all i, and am, <
S' < Isak, thus x,- < k for all 2‘. It follows that {2,3, ..., k — 1} contains at
least k — 1 distinct positive integers x1, x2, ..., mk_1, a contradiction.
III
(Iran 2005) Prove that there are infinitely many positive integers n such
that
nl3n+1 _ 2n+1_
Proof. We will look for n of the form 3“ — 2“ for some a > 1. The
condition n | 3""“1 — 2"+1 is satisfied if a | n + 1 = 3“ — 2“ + 1. We claim
that a = 2 - 3’“ works for all k 2 1. It suflices to prove that 3" | 43k — 1.
But
43" — 1 = (4 — 1)(42 + 4 + 1)(42'3 + 43 + 1)...(4’-"‘3’°'1 + 43’”1 + 1)
and each of the factors in the above product is a multiple of 3.
El
10. (Mathematical Reflections S 259) Let a, b, c, d, e be integers such that
a(b+c)+b(c+d)+c(d+e) +d(e+a)+e(a+b) = 0.
Prove that a+b+c+d+e divides (15+b‘r’+c5 +d5 +65 — 5abcde.
Proof. Let A, B, C, D, E be integers such that
(X—a)(X—b)(X—c)(X—d)(X—e) = X5+AX4+BX3+CX2+DX+E
as polynomials. Thus
A = —(a+b+c+d+e),
B = ab+ac+ad+ae+...+de, ..., E = —abcde.
Note that
B=a(b+c)+b(c+d)+c(d+e)+d(e+a)+e(a+b)=0
472
Chapter 8. Solutions to practice problems
by hypothesis. For each :1: E {a, b, c,d, e} we have
x5+Ax4+Cx2+Dx+E=0.
Adding these 5 equations yields
0.5+b5+c5+d5+e5 —5abcde
+ A(a4 +
+ e4) + (:‘(a2 +
+ e2) + D(a +
+ e) = 0.
Since the last term of the sum is a multiple of A, as is A(a,4 +
+ 64),
it suffices to prove that C(a2 + b2 + (32 + d2 + e2) is a multiple of A. But
A2 = (a+b+c+d+e)2 = a2+b2+c2+d2+62+2B = a2+b2+c2+d2+e2,
yielding the desired result.
El
11. (Kazahstan 2011) Find the smallest integer n > 1 such that there exist
positive integers a1, a2, . . . ,0,” for which
a¥+...+a§|(a1+...+an)2—1.
Proof. Let n be a solution of the problem and write
(a1 +
+ an)2 — 1 2 Ida} +
+ a2)
for some positive integer k. We claim that a1 +
for contradiction that this is not the case. Since
a2; +
+ a: — (a1 +
is even and since a1 +
+ an) = a1(a1 — 1) +
(1)
+ an is odd. Assume
+ an(a,.n — 1)
+ an is even, we deduce that of +
(2)
+ 0% is
even, which contradicts relation (1) (the left—hand side is odd, while the
right-hand side is even). Thus a1 +...+an is odd and so (a1 +... +an)2 — 1
is a multiple of 8. Relation (2) combined with the fact that a1 + + an
is odd shows that a? + + of, is odd too. Since Mag + + a2) is a
multiple of 8 and a? + + (1% is odd, we deduce that k is a multiple of 8
and so k 2 8. On the other hand, the Cauchy-Schwarz inequality yields
k(a§+...+ai) = (a1+.--+an)2—1 S n(a§+...+a§)-1 < ”(“¥+'”+a"21)'
8.1. Divisibility
473
We deduce that n > 8 and so the smallest solution of the problem is
at least 9. To see that this is indeed the solution, choose a1 = a2 = 2,
a3=...=a9=1.
El
12. (Kvant 898) Find all odd integers 0 < a < b < c < (1 such that
ad=bc, a+d=2k, b+c=2m
for some positive integers k and m.
Proof. We first prove that k > m. Indeed, we have
2k—2m=a—b+d—a—d=—(b_a)(d_b)
>0.
b
b
Next we prove that a + b = 2m_1. To do this we write the identity
ad = be as a(2’° — a) = b(2m — b), Le. b2 — a2 = 2m(b —- 2k‘ma). Hence
2’" divides (b— a)(b+a) and since b and a are odd one of b— a, and b+a
is divisible by 2 and the other by 2""‘1. But
b—a<b<
b+c
=2“-1
and therefore b + a, is divisible by 2m_1.
On the other hand b+a < b+c = 2m and we conclude that b+a = 2m‘1.
Hence b = 2m_1 — a,c= 2m — b = 2m—1 +a and ad: bc= 22’”—2 — 0.2.
This shows that a divides 22m—2 and therefore a = 1 since a is odd. Thus
a = 1,b = 2m_1 — 1,c = 2"""‘1 + 1,d = 22m—2 — 1,19 = 2m — 2, where
m 2 3 is an arbitrary integer.
El
13. f is a polynomial with integer coefficients such that f (n) > n for
every positive integer n. Define a sequence (xn)n21 by $1 = 1 and
n+1 = f (x1). Assuming that each positive integer has a multiple among
$1,132, ..., prove that f(X) = X + 1.
474
Chapter 8. Solutions to practice problems
Proof. By hypothesis we have as,“ > :13,- for all z' 2 1, that is, the sequence (xn)n21 is increasing. Moreover, again by hypothesis given n 2 2
we can find m such that xn — xn_1 | mm. Choose a minimal such m and
suppose that m 2 n. Let us note that $14.2 — rug-+1 = f ($j+1) — f (mj) is
a multiple of avg-+1 — any for all j, therefore 11:14.1 — 93,- | mk+1 — ask if k 2 j.
Thus :13" — xn_1 | mm — wm_1 and so xn — xn_1 | mm_1, contradicting the
minimality of m. Thus m < n and so 93,, — xn_1 S :rn_1. We conclude
that f (mn_1) S 2xn_1 for all n 2 2. If deg f 2 2, then for a: large
enough we have f (as) > 23:, which contradicts the previous inequality.
Thus f(X) = aX + b for some integers a, b. Since f(n) > n for all n, we
deduce that a 2 1. Since axn_1 +b S 21:"-1 for all n > 1, we have a S 2.
Thus a = 1 or a = 2. Ifa = 1, then 513,, = 1+ (71— 1)b and by assumption
there is n such that b l as”, which yields b = 1 and f(X) = X+1. Ifa = 2,
an easy induction shows that zn = 2”_1(1 + b) — b. By assumption there
is n such that 1 + b | at”, which forces 1 + b | b and then 1 + b | 1. This
can only happen if 1 + b = 1, i.e. b = 0 and hence 33,, = 2"‘1. But then
trivially 3 does not divide any term of the sequence, a contradiction.
El
14. (Iran 2013) Suppose that a,b are two odd positive integers such that
2ab+ 1 | a2 + b2 + 1. Prove that a = b.
Proof. Arguing as usual by infinite descent, we consider a pair (a, b)
satisfying the hypothesis of the problem and failing to satisfy the con—
clusion, such that a + b has the smallest possible value. We may assume
that a > b. Write
0,2 +152 +1 = c(2ab+ 1)
and note that c 75 1, since a aé b. Consider the other solution
a’ = 2bc — a =
b2+1—c
a
of the equation
m2—2bcx+b2+1—c=0.
Note that a’ = 2bc—a is odd and a’ 7g b (since c 75 1 and (a’)2 +b2 + 1 =
c(2a’b + 1)). Also, note that a’ > 0, since otherwise a’ S —1 and so
8.1. Divisib’ilz'ty
475
b2+1—cS—a,thus
2
<
b +“+1—c
:0,2 + b2+1
2a2+b2
2ab+1 <
2ab
S a + b2,
a contradiction. By minimality of (a, b), we obtain a’ 2 a. This is
however impossible, since (recall that c > 1)
, b2 + 1 — c
b2
a = — <—Sa.
a
a
The result follows.
III
15. (Kvant) Prove that n2 + 1 divides n! for infinitely many positive inte-
gers 11.
Proof. We start by choosing n so that n2 + 1 admits a nontrivial factor-
ization. For instance, choosing n = 2162 yields
n2+1 = 4k4+1 = (2k2)2+4k2+1—(2k)2 = (2k2—2k+1)(2k2+2k+1).
Note that 2k2 — 216 + 1 < n for k > 0. The problem is that 212:2 + 2k + 1
is not less than n, so we still have to work a little bit. Namely, we will
choose k: such that 2192 + 219 + 1 is a multiple of 5, for instance choose
k = 5t + 1, then
21:2 + 2k + 1 = 5(10t2 + 6t + 1).
Thus
n2 + 1 = 5(101:2 + 6t + 1)(2k2 — 2k + 1)
and the numbers 5,10t2 + 6t + 1, 2’62 — 2k + 1 are pairwise distinct and
less than n for t 2 1. Thus their product divides nl.
II!
Remark 8.1. Problem 11358 in AMM generalizes the previous result as
follows: for any d 2 1 there are infinitely many positive integers n such
that dn2 + 1 I 71!. We leave it to the reader to check that for each k 2 2
the number
714, = dk2(d+ 1)2 + k(d+ 1) + 1
476
Chapter 8. Solutions to practice problems
satisfies
dni + 1 = (dk2(d+ 1)2 + 1)(d + 1)(d2k2(d+ 1) + 2dk + 1)
and to deduce that dnfi + 1 | nk! for all k > 1.
16. (Vietnam 2001) Let (047,)”; be an increasing sequence of positive integers such that an“ — an S 2001 for all n. Prove that there are infinitely
many pairs (2,1) with i < j such that ailaj.
Proof. Replace 2001 by an arbitrary positive integer k and image the
following infinite matrix with k: columns: the first row consists of the
numbers a1 + 1,0,1 + 2, ..., a1 + k. If the jth row is a: + 1, a: + 2, ..., a: + k,
then the j +1th row is N+sc+ 1,N+a;+2,...,N+x+k, where
N = (a: + 1)(x + 2)...(a: + k2)
is the product of the numbers on the jth row. Clearly if a < b are on the
same column then a | b. By assumption, among k consecutive positive
integers greater than a1 there is at least one term of the sequence, so
each row of this matrix contains at least one term of the sequence. On
the other hand, if we choose any k + 1 consecutive rows of the matrix,
there will be at least two terms of the sequence in the same column
(as there are at least k + 1 terms of the sequence in the corresponding
sub-matrix, and only k columns). These two terms are distinct and one
of them divides the other one. Since the k + 1 consecutive lines were
arbitrary, it is clear that this procedure generates infinitely many pairs
of distinct terms of the sequence in which one divides the other.
El
17. (Tournament of the Towns) Define a sequence (an).n20 by 0.0 = 9 and
an+1 = ai(3an + 4) for n 2 0. Prove that an + 1 is a multiple of 102”
for all n.
Proof. We prove this by induction, the case n = 0 being clear. Assume
now that an + 1 = k - 102" for some integer k. A brutal expansion shows
that
ai=(k-102" — 1)3 E 319-102" — 1 (mod 102"+1 ).
8.1.
477
Divisibz’lz’ty
Therefore
an+1 E(319102"-1)(3k-102"+1)= 9k2-102"“— E —1 (mod 102"“),
as needed.
We remark that the identity
w3(3:1: + 4) + 1 = (a: + 1)2(3m2 — 2a: + 1),
which can be checked by a direct inspection of both sides, shows that
(an + 1)2 divides an+1 + 1, yielding also the result immediately.
El
18. Find the largest integer k which divides 8"+1 — 7n — 8 for all positive
integers n.
Proof. Taking n = 1, we obtain k | 49 and so k S 49. We will prove
that 49 | 8”“‘1 — 7n — 8 for all n, which will show that the answer of the
problem is 49. Using the binomial formula, we have
sn+1 = (1 +7)"+1 = 1 +7(n+1)+(n_2l_1)72 ++7"+1
a 1+7(n+1) = 7n+8 (mod 49),
as desired.
B
19. Let a, b be distinct integers and let n be a positive integer. Prove that
(a—b)2 | an—b” ifand onlyifa—b | nbn’l.
Proof. Write a —— b = k, then (a. — b)2 | a" — b” if and only if k2 |
(k + b)” — b". Using the binomial formula, we obtain
(k+b)”—b" = k"+ (71‘) kn‘1b+...+ (17,7: 1)kb"-1 a nkbn‘l (mod k2).
Thus k2 l (k + b)” — b" if and only if k2 | nkb"_1, or equivalently (since
[6750) k |nb'""1.
1:1
478
Chapter 8. Solutions to practice problems
20. (BAMO 2012) Let n be a positive integer such that 81 divides both n
and the number obtained by reversing the order of the digits of n. Prove
that 81 also divides the sum of digits of n.
Proof. The binomial formula yields 10" = (1+9)’° E 1+9k (mod 81) for
all k 2 0. Writing n = a0 + 10a1 +
+ IOkak for the decimal expansion
of n, we obtain
k
k
k
n E 20.41 + 971)= Za, + 92m;
i=0
i=0
Let n’ = ak + 10ak_1 +
(mod 81).
i=0
+ 10kao be the number obtained by reversing
the order of the digits of n. Then similarly
k
k
n’ E 2a;- + 92(k — i)a.,:.
i=0
i=0
Since n and n’ are multiples of 81, so is n + n’, and using the previous
congruences we deduce that
k
A:
22:04- +9k2ai = (9k +2)S
i=0
i=0
is a multiple of 81, where .S' is the sum of digits of n. Thus 81 | (9k+2)S
and it is an easy exercise left to the reader to deduce that S is a multiple
of 9 (since 25' is a multiple of 9) and then that 81 | S.
III
21. Prove that for all n 2 1 the number (Ziggy is an integer multiple of
(n + 1)2.
Proof. We have
(2n)!(3n)! _
1
2n
(n+1)2n!5_
51—1
n
2
3n
I
n
and n + 1 | (2:) by example 2.54, yielding the desired result.
El
8.1. Divisibz’lity
479
22. Find all integers a such that n2 divides (n + a)” — a for all positive
integers n.
Proof. The binomial formula shows that
(71+ (1)" — a E a" — a (mod n2).
Thus we must find a such that n2 divides a,” — a for all n 2 1. Clearly
a = 0 and a = 1 are solutions, while a = —1 is not (choose n = 2).
Assume that k = |a| > 1 and choose n = k, so that k2 | (1" — a. However
k2 | ak (since k: > 1), thus we must have k2 | a and then k2 | k. This
is however impossible‘for k > 1. Therefore the solutions of the problem
area=0anda=1.
El
23. (P. Erdos) Prove that every positive integer is a sum of one or more
numbers of the form 2’" - 33, where r and s are nonnegative integers and
no summand divides another.
Proof. We proceed by induction, with base case 1 = 2030. Suppose all
integers less than n — 1 can be represented. If n is even, then we can
take a representation of n/2 and multiply each term by 2 to obtain a
representation of n. If n is odd, take m so that 3"” S n < 37"“. If
3’” = n, we are done. Otherwise, choose a representation (n — 3m) /2 =
31 +
+ 3;, in the desired form.
Then 77. = 3m + 231 +
+ 23k,
and clearly none of the 23,-, divide each other or 3'". Moreover, since
2.3,- S n — 3’” < 3"“H — 3’", we have s,- < 3’”, so 3’” cannot divide
23,- either. Thus 72 has a representation of the desired form in all cases,
completing the induction. Finally, note that the representations need
not be unique: for instance, 11 = 2 + 32 = 3 + 23.
El
24. (Kvant M 2274)) Let k 2 2 be an integer. Find all positive integers n
such that 2" divides 1” + 2" + - - - + (2k — 1)".
480
Chapter 8. Solutions to practice problems
Proof. We will prove that the solutions of the problem are the odd numbers n 2 3. Suppose first that n is odd, then
1n+2n+m+(2k_1)n
= (1” + (2" — 1)”) + - - - + W“1 — 1)" +(2""1 + 1)") + (2“?
and each term in the sum except for the last one is a multiple of 21"
(recall that a” + b" is divisible by a + b for all integers a, b). Thus the
sum is a multiple of 2" if and only if (2k‘1)" is a multiple of 2'“, which
happens if and only if n 2 3.
Now let n be even. We shall prove by induction on k that
SM := 1‘" + 2" +
+ (2k — 1)"
is not divisible by 2’“. This is true for k = 2 since
SW2 = 1" + 2” + 3" E 2
(mod 4)
when n is even. Suppose that 2" does not divide Smk. Since
an E (2k+1 _ a)",
(mod 2k+1)
for all integers a, it follows that
Smk+1 E 2(1” + 2” + - ~ ~ + (2k — 1)") + 2"" E 2S,”c
which proves that Smk+1 is not divisible by 2k“.
(mod 2k“),
El
25. Let k be an integer greater than 1 and let a1, ..., an be integers such that
0.1 + 21.02 + 3.0.3 +
+ nian = 0
for all 'i = 1, 2, ..., k — 1. Prove that a1 + 2ka2 +
kl.
+ nkan is divisible by
8.1.
Divisibih'ty
481
Proof. If ()0, b1, ..., bk_1 are integers, then
(70((11 + 20,2 +
+ nan) + b1(a,1 + 220,2 +
+bk_1(a1 + 2k'1a2 +
+ nzan) +
+ ilk—Ian) i 0.
We can rearrange this as
a1(bo + b1 +
+ bk_1) + a2(2b0 + 22b1 +
+an(nb0 +
+ 2’k_1) +
+ nk'lbn) = 0.
It follows that for any polynomial P(X) = boX + b1X2 +
+ bk_1Xk‘1
with integer coefficients, degree not exceeding k — 1, and constant term
0 we have
a1P(1) + a2P(2) +
+ anP(n) = 0.
The polynomial P(X) = Xk — X(X — 1) . . . (X — k + 1) satisfies all
previous conditions, and the previous relation can be written
In
11
.
al+2kaz+...+nkan=Zaii(i—1)...(i—k+1)=k!zai(l:),
i=1
i=1
The right-hand side being a multiple of k!, we are done.
El
26. Prove that for any integer k 2 3 there are k pairwise distinct positive
integers such that their sum is divisible by each of the given numbers.
Proof. It suffices to prove the existence of pairwise distinct positive integers a1, a2, ..., ak such that
1
1
1
(11
a2
Gk
—+—+...+—=1,
as then setting
(110.2...ak
b1=—,
a1
a1a2...ak
a1a2.-..ak
b2=—,"')bk=——
a2
ak
482
Chapter 8. Solutions to practice problems
yields the desired result. Let us now prove by induction the existence of
a1, ...,ak. For k = 3 choose (11 = 2, a2 = 3 and a3 = 6. Assuming that
al, ...,ak are pairwise distinct positive integers whose sum of inverses
is 1, and (1], = max(a1,...,a,k), the numbers a1, a2,..., ak_1, a], + 1,
oh (049 + 1) are pairwise distinct positive integers and the sum of their
inverses is 1.
El
27. (Kvant) Prove that for any integer n > 1 there exist 71 pairwise distinct
positive integers such that for any two a, b among them the number a + b
is divisible by a — b.
Proof. We prove this by induction on n. For n = 2 consider the numbers
1, 2. Assume that the result holds for n, thus there are integers 1 3 a1 <
(12 < . . . < an such that a; +aj is divisible by a,- - a,- for all z' 75 j. Define
b0 = a1a2...an-
H
(aj — ai)
lgi<jsn
and b,- = a, + be for 1 S t S n. We will prove that bo,b1, ...,bn satisfy
the desired properties. For all 1 S t S n we have bi — b0 = a,- | b, + b0
since ai divides b0. Next, for 1 S t < j S n we have
bj—bi=aj—ailai+aj+2bo=b¢+bj,
since a,- —aj divides a; +aj and a, —aj divides be. The result follows.
III
28. (Romania TST 1987) Let a, b, c be integers such that a + b + c divides
a2 + b2 + 02. Prove that a + b + c divides a” + b" + c" for infinitely many
positive integers n.
Proof. Since (a + b + c)2 = a2 + b2 + c2 + 2(ab + be + ca), it follows that
a + b + c divides 2(ab + be + ca). Next,
(a2 + b2 + c2)2 = a4 + b4 + c4 + 2(a2b2 + b2c2 + c2a2)
and
2((12b2 + bzc2 + c2a2) = 2(ab + bc + ca)(ab + bc + ca) — 4abc(a + b + c)
8.1.
Divisibilz'ty
483
is a multiple of a + b + c. Thus a + b + c divides 2(a2b2 + b2c2 + czaz)
and also a4 + b4 + 04. We will prove by induction on n that a + b + c
divides a2" + b2" + 02" and 2((ab)2n + (be 2" + (0a)”) for n 2 1. This
has already been established for n = 1, so assume that it holds for n and
let us prove it for n + 1. The proof is exactly as above, based on the
identities
a?“ + 122"“ + 8"“ = (a2" + b2" + c2”)2 — 2((ab)2" + am)?" + (ca)2")
and
(ab)2
+1
+ (M2
+1
+ (ca)2
+1
= ((ab)2n + (bc)2n + (0092")2 — 2(abc)2u (112" + b2" + c2”).
We also present an alternate solution suggested by Richard Stong. Let
S = a+b+c. Note that since (a+b+c)2 = a2+b2+02+2(ab+bc+ca),
it follows that S | 2(ab + bc+ ca). Let P = a” + b" + c”. Since a,b,c
are the three roots of
(X — a)(X — b)(X — c) = X3 — 3X2 + (ab+ bc+ ca)X — abc,
we see that
Pn+3 = SPn+2 — (ab + be + ca)Pn+1 + aba.
Note that by the hypotheses of the problem S divides P1 and P2. We
want to show S divides Pn for infinitely many n.
Now we consider two cases. If S is odd, then S I ab + be + ca. Hence
it follows from the recursion above that if S divides Pn, then S also
divides Pn+3. Hence by a trivial induction S divides P3k+1 and P3k+2
for all k 2 0. If S is even, then Pn is even for all n, hence S always
divides (ab + bc+ ca)Pn+1. We again conclude that if S divides P”, then
S divides Pn+3 and hence S divides P3k+1 and P3k+2 for all k 2 0.
El
29. (Russia 1995) Let (11 be an integer greater than 1. Prove that there is
an increasing sequence of positive integers (11 < a2 <
such that
a1+a2+...+a.k | a%+...+ai
for 3.11192 1.
484
Chapter 8. Solutions to practice problems
Proof. We will construct such a sequence inductively. Assume that
al, ...,a,k_1 have already been constructed and let us try to construct
(1],. To simplify notations, let
a: = a1 +
+ ak_1,
y = a} +
+ ail.
We want to ensure that ak + a: | oi + y. Since ah +1: I 0% — :32, it suflices
to ensure that
ak+z l (a%+y) —(a%—x2) =az2+y
and the easiest way to realize this is to take
a], =azz+y—a:=:r(z—1)+y.
Since ak_1 > 1 and :1: 2 ak_1, y 2 a%_1, it is clear that ak > ak_1. By
construction, we have a1 + a2 +
+ ak | a? +
+ oi and the result
follows.
D
30. Let n be a positive integer. Prove that
a) All multiples of 10” — 1 which do not exceed 10"(10"‘ — 1) have sum
of digits 9n.
b) The sum of digits of any multiple of 10“ — 1 is at least 9n.
Proof. a) Consider a multiple N = (10" — 1)k of 10” — 1 that does not
exceed 10”(10” — 1), thus k S 10". Deleting the last zeros of k does not
change the sum of digits of N, so we may assume that k is not a multiple
of 10. In particular, k < 10“ and so we can find digits a0, ..., an_1 such
that k = a0 +
+ (1,,,_110"_1 and a0 7E 0 (we do not impose an_1 76 0).
Now the subtraction algorithm or a direct algebraic manipulation show
that
N = (10" — 1)k = a,,_1...a000...0 — m
= an_1...a1(ao — 1)(9 — an_1)...(9 — a1)(10 — a0).
The sum of digits of the last number is clearly 9n.
8.1.
Divisibz'lz’ty
485
b) Let s(a:) be the sum of digits of :r. We wfll prove by strong induction
on k that s((10" — 1)k:) 2 9n for all k 2 1. For k S 10" this has already
been seen in a). Assume that k > 1 and s((10"—1)j) 2 9n for 1 S j < k
and write (10" — 1)]: in base 10'” as
(10" — 1)]: = be + b1-10” +
+ bd - (10”)d
for some b,- E {0,1,...,10” — 1} with bd aé 0. Since 10'” — 1 divides
10"“ — 1 for all s 2 1, the previous equality shows that 10” — 1 divides
b0+b1+...+bd. Note that bo+...+bd < b0+10‘"'b1+...+10”dbd unless d = 0,
but then k: = 1, contradiction. So we can write bo+b1+...+bd = j(10"—1)
for some 1 S j < Is. Now, since b,- < 10‘”, we obtain
s(lc(10” — 1)) = 3(bo) + San) + + 3(1).) 2 3(bo + + bd)
and by the inductive hypothesis the last quantity is greater than or equal
to 9n. The result follows.
El
Remark 8.2. We have freely used the inequality
s(a + b) S 3(a) + 3(b)
in the previous solution. We invite the reader to supply a proof.
31. (USAMO 1998) Prove that for each n 2 2 there is a set S of n integers
such that (a — b)2 divides ab for every distinct a, b E 3.
Proof. We will construct such a set, consisting of nonzero integers, by
induction. Take for n = 2 the set {1,2}. Assume that such a set S =
{(11, ...,an} has been constructed. The new set T will be taken of the
form
T={a1+k,...,an+k}U{k}
for a suitable integer k.
We need (ai — {1,-)2 | (a; + k)(a.j + k) and a? I k(a,- + k) for all i aé 3'
between 1 and n. The divisibility a? I k(a,- + k) certainly holds if we
impose a? | k for all 12 (even a.,; | k would suffice). On the other hand,
486
Chapter 8. Solutions to practice problems
since (a,- — aj)2 | aiaj, the divisibility (a, —aj)2 I (a,- + k) (aj + k) holds if
we impose (a,- — a,-)2 | k for all i aé j. Thus it suffices to take any nonzero
integer k which is a multiple of 112:, a? - H15t<jgn(ai — (raj-)2.
[:1
32. (Romania JBMO TST 2004) Let A be a set of positive integers such that
a) if a E A, then all positive divisors of a are also in A;
b) ifa,b€Asatisfy 1 < a< b, then 1+ab6A.
Prove that if A has at least 3 elements, then A is the set of all positive
integers.
Proof. We start by proving that A contains 1, 2, 3,4, 5. It is clear that
1 E A. If 2 ¢ A, then by a) all elements of A are odd. Since A has at
least three elements, we can choose a,b e A with 1 < a < b. By b),
1 + ab 6 A, but 1 + ab is clearly even, a contradiction. Hence 2 E A.
Next, we prove that A contains a multiple of 4, and hence 4 E A. Choose
any a > 2 in A (possible, since |A| Z 3). Then applying successively
property b) we obtain 1 + 2a 6 A, then 1 + 2(1 + 2a) = 3 + 4a 6 A and
finally b = 1 + (1 + 2a) (3 + 40,) E A. Note that b > 2 is even. Applying
the same argument, c = 1 + (1 + 2b) (3 +4b) E A, but this last number is
a multiple of 4, hence we are done. It also follows that 1 + 2 - 4 = 9 e A,
hence36A, then 1+2-3=7EA, 1+2.7=15 EAand5EA. Also,
1+5-7=36€A,hence6€A.
It is now time to conclude: we will prove by strong induction on n that
n E A. By the previous work, we may assume that n 2 7 and that
1,2, ...,n— 1 E A. Ifn is odd, say n = 2k+1 for some k > 2, then 77. E A
by property b), since 2, k E A. So assume that n = 2k is even, with k >
3. Again, since k, k — 1 e A are greater than 2, we have 1 + 2k 6 A and
1+2(k—1)= 2k—1 e A. But then 1+(2k—1)(2k+1)= 4192 e A, hence
n = 2k 6 A. The inductive step is proved and the result follows.
El
33. (USAMO 2002) Let a,b be integers greater than 2. Prove that there
exists a positive integer k and a finite sequence n1, n2, . . . , n], of positive
8.1., Divisib'ilz'ty
487
integers such that m = a, 774, = b, and mfg-+1 is divisible by n, + 11,-4.1
for each i (1 S i < k).
Proof. If a, b are positive integers, say that they are linked if there is a
positive integer k and a finite sequence n1, n2, . . . ,nk of positive integers
such that n1 = a, 12;, = b, and nah-+1 is divisible by n, + 77444 for each 72
(1 g i < k). It is clear that if a, is linked to b and b is linked to c, then
a. is linked to c. Next, if a > 1 is odd, then a is linked to a + 1, since
we can use the sequence a, a2 — a,a2 + a,a + 1. Also, if a > 2 is even,
write a = 2k and use the sequence a, 2k:2 — 2k, 2k;2 + 2k, 2k + 2 = a + 2
to link a and a + 2. We deduce that all even numbers are linked, and
since any odd a is linked to the even number a + 1, it follows that all
numbers greater than 2 are linked.
El
Remark 8.3. We suggest the reader to try to solve the following very
similar problem (proposed in an Iranian Mathematical Olympiad in
2006): let m,n be integers greater than 2. Prove that there is a sequence a0, ..., (1;, of integers greater than 1 such that 0.0 = m, a}, = n and
ai+a¢+1|aiai+1+1 forall OSi< ’9.
34. Is it true that for any integer k > 1 we can find an integer n > 1 such
that k divides each of the numbers (’1‘), (3),..., ”’11)?
Proof. The answer is negative. We will show that for k = 4 there is no
such n. Assume by contradiction that 4 divides each of the numbers ('1‘),
(Z),..., (nil). Then 4 also divides their sum, which is 2" — 2. This can
only happen if n = 1 (as if n > 1 the number 2" is a multiple of 4),
however in this case (’1‘) = 1 is not a multiple of 4.
El
35. (Catalan) Prove that m!n!(m + n)! divides (2m)!(2n)! for all positive
integers m, n.
Proof. Let
(
) ( )
2m ! 2n !
f(m, n) = m!n!(m +n)!'
488
Chapter 8. Solutions to practice problems
We will prove by induction on m the following statement: for all n 2 1
we have f (m, n) E Z. The case m = 1 follows directly from exercise
2.54. Assume now that the result holds for m and let us prove it for
m + 1. Fix n > 1. Then direct computations yield
_
(2m)!(2n — 2)!
f(m, n — 1) - W
and
(2m + 2)'(2n — 2)’
f(m+1,n- 1) = W
_
(2m + 1)(2m + 2)n= 2m + 1
— f(m’”)' 2n(2n — 1)(m+ 1)
2n-1 f(m n)
We deduce that
f(m+ 1,n— 1) = 4f(m,n— 1) — f(m,n).
The right-hand side is an integer by the inductive hypothesis. Thus
f (m + 1, n — 1) is an integer for all n > 1, which proves the inductive
step and finishes the solution.
El
Remark 8.4. The previous solution is not natural and not easy to come
up with, but with the tools we have developed so far it is not easy
to find a natural solution for the previous problem. Once the theory
of prime numbers and p-adic valuations is established (and this will
occupy us quite some time in the book!), this problem will become a
straightforward exercise.
36. Let .731 < £2 <
< xn_1 be consecutive positive integers such that
so], | 1:03) for all 1 S k S n — 1. Prove that {1:1 equals 1 or 2.
Proof. Let a: 2 51:1 — 1 and assume that a: > 1, i.e. that the conclusion
fails. Note that w,- = :1: +1 for 1 S 12 g n — 1. The key ingredient is the
8.1.
Divisib'ilz'ty
489
following identity
77’!
_Z(_1)k—1 k__(1l:) .
(:1:+1).. .(m+n)
k_1
x+k
Let us take this for granted for a moment and see how to conclude. By
assumption all terms but the last one in the above sum are integers. We
deduce that
n!
n
= (x+1)...(a:+n)+(_l)nx+n
is an integer. However, since a: 2 2 we have
n!
n
|a|< 2-...-(n+1)+n+1 =
’
thus a = 0. This already shows that n is odd, and also that
(a:+1)...(:c+n— 1) = (n—l)!.
This is clearly impossible, since the left-hand side is greater than (n— 1)!.
Thus the problem is solved, once the identity is proved.
Let us prove now the identity. Multiplying by (as + 1) . . . (a: + n), we are
reduced to proving the identity
(m+2)...(x+n)(:’) —(x+1)(w+3)...(m+n)2(:) +
+ (-1)”'1n(:)(w + 1) . . . (x +n — 1) = n!.
The difference f (3:) between the left-hand side and the right-hand side
is a polynomial of degree at most n — 1 in 51:, and one immediately checks
that f(—1) = f(—2) =
= f(—n) = 0 (note that the complicated
sum in the left-hand side has only one nonzero term when a: is one of
the numbers —1,—2, . . . , —n). Therefore the polynomial f is the zero
polynomial, which finishes the proof of the identity.
III
490
Chapter 8. Solutions to practice problems
37. Prove that for any n > 1 there are 2n — 2 positive integers such that the
average of any n of them is not an integer.
Proof. Choose arbitrary positive integers a1, ..., an_1 which are divisible
by n and arbitrary positive integers b1, ..., bn_1 congruent to 1 modulo
n. It is clear that the numbers a1, ..., an_1, b1, ..., bn_1 have the property
that the average of any n of them is not an integer, since the sum of
the 71. numbers gives a remainder between 1 and n — 1 when divided by
72.
El
38. Let n be a positive integer. Find the remainder of 32" when divided by
2n+3.
Proof. We have
32"—1 = (3—1)(3+1)(32+1)...(32"‘1+1) = 8(32+1)(34+1)...(32"‘1+1).
Each of the numbers 32 + 1, 34 + 1, ..., 32"_1L + 1 is even and not divisible
by 4, thus their product is of the form 2"‘1(2k + 1) for some k > 0.
Then
32" — 1 = 2"+2(2k + 1) = 2n+3k + 2"+2
and so the required remainder is 2"""2 + 1.
III
39. (Saint Petersburg 1996) Let P be a polynomial with integer coefficients,
of degree greater than 1. Prove that there is an infinite arithmetic pro-
gression none of whose terms belongs to {P(n)| n e Z}.
Proof. Since deg P > 1, the polynomial P(X +1) —P(X) is not constant,
thus we can find a: > 1 such that the number d = |P(a: + 1) — P(x)|
satisfies d > 1. Since P(m) and P(x + 1) give the same remainder when
divided by d, there is r between 0 and d—l such that none of the numbers
P(m), P(ac + 1), ..., P(ac + d — 1) gives remainder T when divided by d. If
m is any integer, we can find y E {x,a:+ 1, ...,a:+d— 1} such that m E y
(mod d). Then P(m) E P(y) (mod d) and so the remainder of P(m)
8.1.
Divisibil'ity
491
when divided by d is not r. It follows that {P(n)| n E Z} has empty
intersection with the infinite arithmetic progression 1' + dZ consisting of
numbers congruent to 1' modulo d.
III
40. (Baltic Way 2011) Determine all positive integers d such that whenever
d divides a positive integer n, d also divides any integer obtained by
rearranging the digits of n.
Proof. Let d be a solution of the problem. Choose a large integer N
such that ION > n. Among the consecutive integers
101W1 +2.10N,10N+1 +2-10N+ 1,...,10"’+1 +2 - 10” + 10” — 1
there is a multiple of n. Such a number is of the form m for
some digits a1, ..., an. By assumption d divides any number obtained by
permuting the digits of m, in particular it divides m and
m. Therefore d also divides the difference of these two numbers,
which is 9. It follows that d = 1, 3 or 9. Conversely, any divisor d of 9
is a solution of the problem. Indeed, assume that d | n and that n’ is
obtained from n by permuting its digits. Then 77/ and n have the same
sum of digits, say It. Since n E k (mod 9) and n’ E k (mod 9), we
have n E n’ (mod 9) and so n E 17/ (mod d), yielding d | n’. Thus the
solutions of the problem are 1, 3, 9.
El
41. (Russia) A convex polygon on the coordinate plane contains at least
m2 + 1 points with integer coordinates in its interior. Show that some
m + 1 of these points lie on a line.
Proof. For each point P with integer coeflicients inside the polygon,
consider the pair of remainders obtained by dividing the coordinates of
P by m. We have at least m2 + 1 pairs associated to the points with
integer coordinates inside the polygon. On the other hand, since there
are m remainders mod m, there are m2 pairs of remainders mod m. Thus
we can find two points P with coordinates a, b and Q with coordinates
c, d such that a E c (mod m) and b E d (mod m). Then the points A,
492
Chapter 8. Solutions to practice problems
with coordinates c + £01 — c) and d + %(b — d), for O S k g m, are
on the segment with endpoints P, Q, have integer coordinates and are
inside the polygon (since the polygon is convex).
El
42. (IMO 2001) Let n > 1 be an odd integer and let c1, C2, . . . ,cn be integers.
For each permutation a = a1, (12,. . . , an of 1, 2, . . . ,n, define
8(a) = clal + czaz +
+ cnan.
Prove that there are permutations a 7E b of 1,2, . . . ,n such that n! ]
5(a) — S(b).
Proof. Suppose that for all permutations a and b of 1, 2, . . . ,n the num-
ber n! does not divide S(a) —S(b) Since there are n! remainders modulo
n! as well as n! permutations of 1, 2, ...,n, it follows that the remainders
of the numbers 8(a) (over all permutations a) when divided by n! are
0,1, ...,n! — 1 in some order, thus
23(0)51+2+...+(n!—1)=
n!(n! — 1)
2
(mod n!).
On the other hand,
2301) =Ziaflj = i% Eat-a
j=1
j:]_
a
For each k E {1, 2, ...,n} there are precisely (n — 1)! permutations a for
which aj = k, thus
Zaj=i(n—1)!k=(n—1)!-@=nl'n7+150
a
(modnl),
13:1
the last congruence uses the hypothesis that n is odd. Combining these
congruences, we deduce that n! divides w, which is clearly absurd,
since n! — 1 is odd. Hence our assumption was wrong and the result
follows.
III
8.1. Divisib'ility
493
43. Let n,k > 1 be integers. Consider a set A of k integers. For each
nonempty subset B of A, compute the remainder of the sum of elements
of B when divided by n. Assume that 0 does not appear among these
remainders. Prove that there are at least k distinct remainders obtained
in this way. Moreover, if there are only k such remainders, then all
elements of A give the same remainder when divided by n.
Proof. Let a1, ...,ak be the elements of A. We claim that a1, a1 + a2, ...,
a1 + +0.;c give pairwise distinct remainders when divided by n, which is
enough to conclude for the first part of the problem. Indeed, if a1 + ...+a,~
and a1 + + aj give the same remainder for some 1 S 2' < j S k, then
(1,-4.1 + + aj is a multiple of n, contradicting the hypothesis.
Assume now that there are exactly k: remainders, which must be the
remainders of 04,111 + a2, ...,a1 +
+ (1],. Assume that a1 and (12 give
different remainders when divided by n. Thus there is i 2 2 such that
0.2 E a1 +a2 +
meaning that a1 + a3 +
+a¢
(mod n),
+ a,- is a multiple of n, a contradiction. Thus
a1 E (12 (mod 72.). But since the order of £11,...,a;c is not relevant in the
previous argument, we deduce that any two ad’s are congruent mod n,
and the problem is solved.
III
44. (IMO 2005) A sequence a1, a2,
of integers has the following properties:
a) a1, a2, ..., an is a complete residue system modulo n for all n 2 1.
b) there are infinitely many positive and infinitely many negative terms
in the sequence.
Prove that each integer appears exactly once in this sequence.
Proof. It is clear that each integer appears at most once, for if am = an
for some m < n, then 04, ...,an cannot be a complete residue system
modulo n. Hence it remains to prove that each integer k actually appears
(which
in the sequence. By considering the sequence a1 — k, 0.2 — k,
494
Chapter 8. Solutions to practice problems
satisfies the same properties as the original sequence), we reduce to the
case k = 0.
Assume now that an is nonzero for all n. Replacing an by —a,, for
all n, properties a) and b) are still satisfied, so we may assume that
a1 > 0. Let n be the smallest positive integer for which an < 0 and
let i E {1,...,n — 1} be such that a, = max(a1,...,an_1). Note that
a,- 2 n— 1, since an, ..., an_1 are pairwise distinct positive integers. Hence
N = a,- — an 2 n. Since a,- E on (mod N), it follows that a1,...,aN
cannot be a complete residue system modulo N, a contradiction. Hence
an = 0 for some n and, as explained in the first paragraph, we are done.
Here is an alternate solution, due to Richard Stong. We will prove by
induction on n that any sequence (11, a2, . . . satisfying condition (a) has
the property that for all n the numbers (11,. .. ,0,” are consecutive inte-
gers in some order. Then from condition (b) the requested conclusion is
almost immediate: by (b), the sequence contains arbitrarily large magnitude positive and negative integers, and since it has blocks of consecutive
integers it must contain every integer in between.
For the inductive proof, the base case n = 1 is trivial. For the inductive
step, suppose a1, . . . ,0." are consecutive. That is, they are the numbers
a,,a,-+1,...a,+n— 1 = aj for some 1 g i,j S 17..
Clearly, an+1
cannot be a repeat of one of these 71. numbers, otherwise a1,...a.n+1
would not be a complete residue system mod n + 1. If an+1 > a, + n,
then let N = on“ — a,- Z n + 1. Since an“ E a,- (mod N), we see that
0.1, . . . ,aN is not a complete residue system modulo N, a contradiction.
Similarly, if an+1 < a,- — 1, then we let N = aj — an+1 2 n + 1 and
an“ E aj (mod N) gives a contradiction. Thus an+1 must be either
(11— 1 or a¢+n = aj+1. In either case we see that al, . . . , an+1 are n+1
consecutive integers.
III
45. For a positive integer n, consider the set
S:{0,1,1+2,1+2+3,...,1+2+3+...+(n—1)}
Prove S is a complete residue system modulo n if and only if n is a power
of 2.
8.1. Divisibz'lz’ty
495
Proof. First, assume that n is a power of .2, say 17, _= 2". We need to
prove that ifO S i <j 3 12—1 satisfy M
modn , then
2 E JJLIZ
2
2' = j. Note that
i(z'+1) _j(j+1) _i2—j2+i—j _ (i—j)(z'+j+1)
2
2
‘
2
’
2
'
So, assume that 2’c+1 divides (12 — j)(i + j + 1). One of the numbers i— j
and i+ j + 1 is odd, hence 2’c+1 divides either j —z' or i+j + 1. Since both
these numbers have absolute value less than 2"“, this is only possible
when one of them is 0, that is i = 3'.
Next, assume that n is not a power of 2 and write n = 2km with k 2 0
and m > 1 odd.
Choose an integer j E {0,1,...,m — 1} such that
m l 23' + 1 + 2""‘1 (this is possible since m is odd) and set i = j + 2"“.
Then 72 E {0, 1, ...,n—l}, n does not divide i—j = 2’”1 and yet n divides
73(i+1) _j(j+1) = (i-J')(i+j+1)
2
2
2
’
since 2k divides ”—31 and m divides z'+ j + 1 by construction. Thus 5’ is
not a complete residue system modulo n, a contradiction.
III
46. (Argentina 2008) 101 positive integers are written on a line. Prove that
we can write signs +, signs x and parentheses between them, without
changing the order of the numbers, in such a way that the resulting
expression makes sense and the result is divisible by 16!.
Proof. By example 2.89 for any integers a1, ..., am we can find 2' < j such
that m divides (1,-4.1 + + 11,-. In particular
m|(a1+...+a,-)><(a,+1+...+aj)x(aj+1+...am).
We deduce that if a, b are positive integers and m = ab, n = a + b, then
for any sequence of n integers we can insert parentheses and signs +, x
around the first a terms to make the result divisible by a, and around the
last b terms to make the result divisible by b, and finally enclose these
496
Chapter 8. Solutions to practice problems
two within parentheses and add a multiplication operation to make the
result divisible by m. The result follows by observing that
m=16!=215x36x53x72x11x13
and
30+18+15+14+11+13=101.
El
47. (adapted from Kvant M33) Consider the remainders of 2” when divided
by 1,2, ...,n. Prove that their sum exceeds cnlogn for some constant
c > 0 (independent of n > 1).
Proof. If k: > 1 is odd, then the remainder of 2“ when divided by 2%
is divisible by 22' and nonzero, hence it must be at least 21'. Let 11:; be
the number of positive integers of the form 2i(2k + 1) with k: 2 1 and
2i(2k + 1) g n. Then clearly
_ 12—2i
>n—3-2i
xi- W —W
for all i. If N is chosen such that 3 - 2” S n < 3 - 2”+1, the previous
observations show that
n
2(2" (mod k)) 2 x0 + 2331 +
N n — 3 - 2'i
+ 2NxN 2 2T
k=1
i=0
n
3
( + 1) ———
2 2(2N+1—1>.
= N
Using the inequalities 3 - 2” S n < 3 - 2”+1, it is easy to see that the last
expression exceeds %(log2 (n) — 4), which yields the desired result.
8.2
GCD and LCM
1. Prove that for all positive integers a, b, c we have
gcd(a, bc) | gcd(a, b) - gcd(a, c).
III
8.2.
GOD and LCM
497
Proof. Let (1 = gcd(a, b) and write a = d’u and b = d'v with gcd(u, v) =
1. We need to prove that dgcd(u, 11c) | dgcd(a,c), or equivalently
gcd(u, 1m) | gcd(a, 0). But gcd('u,, vc) divides u, so it is relatively prime to
22 (since gcd(u,v) = 1). Since gcd(u,vc) also divides vc, Gauss’ lemma
yields gcd(u,vc) | c. Since it is clear that gcd(u,vc) | u I a, the result
follows.
III
2. (Romania TST 1990) Let a, b be relatively prime positive integers. Let
1:, y be nonnegative integers and let n be a positive integer for which
ax+by=an+b".
Prove that
1% + [a = VTJ + VijProof. Reducing the first equation modulo (1 and b and using the fact
that gcd(a, b) = 1 we obtain y E b”_1 (mod a) and m E a,"-1 (mod b).
Thus we can find integers c, d such that y = b”—1 +ca and w = tin—1 +db.
Replacing these relations in the equation ax + by = a” + b”, we obtain
c+ d = 0. But then
m=laT+dJ+l+cl
and the result follows from the 1-periodicity of the floor function.
E]
3. (Kvant M 1996) Find all n > 1 for which there exist pairwise different
positive integers a1, a2, . . . ,an such that
a
a
02
0.3
_
a
_1 + _2 + . . . + (in—1 + _"
is an integer.
an
01
498
Chapter 8. Solutions to practice problems
Proof. For every n 2 3 consider the positive integers a1 = 1, a2 =
n—1,..., an=(n—1)"‘1. Then
a1
a2
a2+a3+
an_1
an
1
72—1
+ an +111: 11—1_|—(17,—1)2+
(n—l)”_2
(71—1)”—1
+(n—1)"—1
1
is an integer, equal to 1 + (n — 1)n—1. Suppose now that 0.1 31$ (12 and
—1 + 92 is an integer. Dividing a1 and 0.2 by their gcd, we may assume
that they are relatively prime.
Then a1a2 | a? + a3 and gcd(ahaf + a3) = gcd(a1,a§) = 1, thus necessarily a1 = 1 and similarly a2 = 1, a contradiction.
4. Let m, n be positive integers greater than 1.
We definethesetsP = {i
l ...,m7'1} andPn= {1
3
m’m’
n’n’
Find
min{|a — b| :a 6 Pm,b E Pn}
III
’
”—4}.
In
Proof. We need to find the smallest value that f(t, j
take when 1 S i < m and 1 S j < n. If gcd(m,n) = d > 1, then we
can take i = % and j = g and get f(z‘,j) = 0, thus the answer of the
problem is 0 if gcd(m, n) > 1.
Assume now that gcd(m, n) = 1. We cannot have f(i, j) = 0, since if
in = jm then m | in and m | 1' (since gcd(m, n) = 1), contradicting the
inequalities 1 S i < m. Thus
lin- jml>_>%f(2 j)= —n
We will prove that we can find i,j such that lin— jm|—
— 1, which will
imply that the answer of the problem 1s—”when gcd(m, n)—
— 1. Since
n, 211,“ .,(m — 1)n give pairwise distinct and nonzero remainders when
divided by m, one of them say in gives remainder 1 and so in = 1 + jm
for some integer j . Since 1 _<_ 1' < m, we have 1 S j < n and the problem
is solved.
El
8.2.
GOD and LCM
499
5. (Saint Petersburg 2004) Positive integers m, n,k are such that 5“ — 2
and 2’“ — 5 are multiples of 5"" — 2m. Prove that gcd(m, n) = 1.
Proof. Let d = gcd(m, n). Then 5d — 2d|5m — 2m and 50l — 2dl5’m — 2“.
But
5"" — 2’°'n a (5")’c — (2")" a 2’6 — 5" a 5 — 2 = 3 (mod 5’” — 2'").
It follows that 5‘1 — 2d | 3 and so d = 1.
El
6. (Russia 2000) Sasha tries to find a positive integer X S 100. He can
choose any two positive integers M, N less than 100 and ask for gcd(X +
M, N). Prove that he can find X after 7 questions.
Proof. Let f (n) be the remainder of X modulo 2”. Since X S 100, we
have X = f(7). Note that f(n+ 1) = f(n) or f(n+ 1): f(n) +2",
the last equality happening if and only if gcd(a: + 2" — f (n), 2”“) = 2”.
Thus Sasha can find f (6) after 6 questions, since he knows f (0) = 1
and the previous discussion shows that if he knows f (n), then he also
knows f(n + 1), as long as n + 1 S 6 (to ensure that 2”+1 < 100). Thus
after 6 questions Sasha knows that X is either f (6) or f(6) + 64. His
final question will be to compute gcd(X + M, 3), Where M 6 {1,2, 3} is
chosen such that 3 | f (6) + M. If he gets the answer 3, then X = f (6),
otherwise X = f(6) + 64. Hence after this new question Sasha knows
X.
El
7. (Poland 2002) Let k be a fixed positive integer. The sequence {an}n21
is defined by
a1=k+1,an+1=a,21—kan+k.
Show that if m 75 n, then the numbers am and an are relatively prime.
Proof. Write the recurrence relation as
an+1 — k = an(a,,,, - k).
500
Chapter 8. Solutions to practice problems
An immediate induction using this relation shows that an > k for all
k and also that an E 1 (mod k) for all n. Next, multiply the previous
relations to get
n—1
n—1
n—1
H(az‘+1 - k) = H “z” HW — ’6),
i=1
i=1
i=1
which, after division by H251 (a,- — k), can be written as
an — k = a1a2...an_1.
Now, if d divides an and am for some m < n, then it divides a1a2...an_1 =
on —— k and an, thus it also divides k and an. Since an E 1 (mod k), it
follows that d divides both an and an — 1 and so d = 1.
III
(Romania TST 2005) Let m, n be relatively prime positive integers with
m even and n odd. Prove that
n—l
Z(_1)l"‘7’°l {21k} = l _ i,
k=1
n
2
2n
We denoted by {x} the fractional part of (1:, i.e. {9:} = a: — Lac].
Proof. Write the Euclidean division of mk by n as mic = qkn+rk for 1 S
k S n — 1. Since gcd(m, n) = 1, the remainders r1, ..., rn_1 are pairwise
distinct and nonzero, thus they must be a permutation of 1, 2, ..., n — 1.
On the other hand we have
[k
— = 9k,
{ mk }
mk
rk
— = — — (II: = E.
Thus the equality is equivalent to
Z(_1)qk'rk = %
k=1
8.2.
GOD and LC'M
501
Now, since m is even and n is odd, we have
Osmk =qkn+rk Eqk+rk
(mod 2),
thus (—1)‘1’° = (—1)” and we are reduced to proving that
11—1
1
_:";_
Z(—1) Th T'k—
2 .
k=1
Taking into account the first paragraph, this is equivalent to
n—l
— 1
z(_1)kk = ”IT:
k=1
which follows immediately by induction on n (going from n to n + 2,
since n is assumed to be odd).
III
An infinite sequence 04, a2, . .. of positive integers has the property that
gcd(a.m, an) = gcd(m, n) for all m aé n 2 1. Prove that on = n for all
n 2 1.
Proof. Taking m = 2n yields gcd(a2n,an) = n, thus n | an. Suppose
that an aé n for some n. Then gcd(aan,a,n) = gcd(an,n) = n, the last
equality being a consequence of the fact that n | an. On the other hand,
0.“,1 is a multiple of an, thus gcd(aan, an) = an and so we obtain an = n,
a contradiction. Thus an = n for all n.
[I
10. (Iran 2011) Prove that there are infinitely many positive integers n such
that n2 + 1 has no proper divisor of the form k2 + 1.
Proof. We say that n is good if n2 + 1 has no proper divisor of the form
k2 + 1. We will prove that Fn = 22" + 1 has a good divisor for all n.
Since gcd(Fn, Fm) = 1 for all n 76 m, the result follows.
Now, assume that there is n such that all positive divisors of Fn are bad.
In particular E, is bad, hence it has a proper divisor of the form k2 + 1.
502
Chapter 8. Solutions to practice problems
This new divisor is also bad, so it has a proper divisor of the form 12 + 1.
Continuing like this, we create an infinite decreasing sequence of divisors
of F”, which is clearly absurd. The result follows.
III
11. a) (Romanian Masters in Mathematics 2009) Let a1, ...,ak be nonneg—
ative integers and let d = gcd(a1, ...,ak) and n = a1 +
+ ak. Prove
that
d
n!
TL
a1!...ak!
— - — e 2.
b) Prove that (n)!kk!|(nk)! for all positive integers n, k.
Proof. a) Writing d = alxl +
have
k
d
n!
n
a1....ak.
—' l
+ akxk for some integer x1, ...,xk, we
a'
n!
n
a1....ak.
I=§:%'J'—T—T
i=1
thus it sufl‘ices to prove that $3 - fl is an integer. This is clear if
az- = 0, and if oi > 0 we have
0.1-
n!
(n — 1)!
_'
I
I = a1....ai_1.(a,,I
I — 1).ai+1....ak.
I
I
I e Z’
n a1....ak.
since b1!...bk! | (b1 +...+bk)! for all nonnegative integers b1, ..., bk (this follows by an immediate induction from the case k = 2, which is equivalent
to (“at”) e Z).
b) We have
WM!_Tf
mw—ofi
k!(n!) k _ [:0 (k _ l)n!(n(k _ e _ 1))!
and by a) each of the numbers
(WC - 3))!
(k: — l)n!(n(k — Z — 1))!
is an integer.
One can also give a combinatorial proof, observing that % equals
the number of ways one can divide nk people in k (unordered) groups
of n people.
[I
8.2.
GCD and LCM
503
12. (Brazil 2011) Are there 2011 positive integers on < (12 < . .. < a2011 such
that gcd(a¢,aj) = aj — a,- for any 72, j such that 1 S i < j S 2011?
Proof. For all 2' < j we must have gcd(ahaj) g aj — (1,, since aj —— a, is
a positive multiple of gcd(ai, (1]). The condition gcd(ai, (1,) = a,- — a,- is
equivalent to aj — a,- | a,- (as this automatically implies a,- — a, | aj and
so aj — a,- | gcd(ai,aj)). We will now prove by induction that for any
n 2 2 we can find positive integers (11 <
< an such that aj — a,- | az- for
all i < j. For n = 2 choose (11 = 1 and a2 = 2. Assuming that we have
already constructed a1, ..., an, define bl = alman and b,- = a1...an + a¢_1
for 2 S i S n + 1. Then clearly b1 <
< bn+1 and it is not difficult to
check that they satisfy bj — b,- | b, for i < j. Indeed, if z' > 1 this comes
down to aj_1 — «11.1 | 04.1 + a1...an, which is clear since a,-_1 — 04-1
divides both (15-1 and alman. If i = 1, this reduces to aj_.1 | almam and
it is also clear.
Cl
13. (Tournament of the Towns 2001) Are there positive integers 0.1 < (12 <
. . . < (1100 SUCh that
gcd(a1,a2) > gcd(a2,a3) >
> gcd(a99,a100) > gcd(a100,a1)?
Proof. First, we will build a sequence bk for 1 S k S 100 such that
nah, 52) > n(bz,b3) >
> n(be9,b100) > nUhoo, 51),
not worrying about the relative sizes of the bk. This is easy. For example,
we can take bk = (203 — 2k) (205 — 2k). Then we compute
gcd(bk, bk+1) = gcd((203 —— 2k)(205 — 2k), (201 — 2k)(203 — 2k))
= (203 — 2k) gcd(205 — 2k, 201 — 2k)
= (203 — 2k) gcd(205 — 2k, 4)
= 203 — 2k,
since 205 — 2k is odd and hence relatively prime to 4. Also
gcd(bloo, bl) = gcd(15,201 - 203) = 3gcd(5, 67 - 203) = 3,
504
Chapter 8. Solutions to practice problems
since 67 - 203 = 13601 = 2720 - 5 + 1 is relatively prime to 5.
Next we fix the relative sizes without changing any of the greatest
common divisors. To do this we inductively define a1 = b1, then
ak = bk(1 + ak_1bk+1) for 2 S k S 99, and finally (1100 = b100(1 + a99b1).
Note that this clearly gives (11 < a2 < . . . < (1100. To see that it doesn’t
change any of the greatest common divisors, we compute
g0d(ak, ak+1) = gcd(ak, bk+1(1 + akbk+2)) = gcd(ak, bk+1)
= n(bk(1 + ak—lbk+1): bk+1) = n(bk, bk+1),
for 2 S k S 99. The computation for the remaining cases is similar.
III
14. (Russian Olympiad 2012) Let n be an integer greater than 1. When (1
runs overs all integers greater than 1, what is the maximum number of
pairwise relatively prime numbers among 1 + a, 1 + a2, ..., 1 + azn‘l?
Proof. We first prove that no more than n of these numbers can be
pairwise relatively prime. To do this note that if k is odd then 1 + am
divides 1 + akm. Note also that each of the numbers 1, 2, 3, . . . ,2" — 1
has the form 2%, where 0 S t g n — 1 and k: is odd. Hence each of
the given numbers is divisible by one of the numbers 1 + a, 1 + a2,1 +
a4,... ,1 + a2"_1. Therefore among any n + 1 of the given numbers
there are two which are not relatively prime. Since Fermat numbers are
pairwise relatively prime, for a = 2 we obtain n pairwise relatively prime
numbers, namely 1 + 2,1 + 22, 1 + 24,...,1 + 22'“. Hence the desired
I]
number is n.
15. (Brazilian Olympic Revenge 2014) a) Prove that for all positive integers
n we have
gcd (n, [rm/2D < v4 871.2.
b) Prove that there are infinitely many positive integers n such that
god (n, [Tn/2D > V4 7.99122.
8. 2.
GCD and LCM
505
Proof. a) Let d = gcd (n, lnx/ij) and write n = kd and [nx/ij = md
for some positive integers k, m. Then
mdSkdx/E<md+ 1.
The first inequality gives m S k\/§ and so m2 S 2162. This cannot be
an equality since x/i is irrational, hence m2 S 2k2 — 1. Now the second
inequality can be written as
d(k\/§ — m) < 1 or equivalently d(2l<:2 — m2) < m + kx/2_.
Since 2k2 — m2 2 1 and m S lax/5, we'obtain d < 2\/§k, which is
equivalent to d < V4 8112.
b) Part a) suggests how to take n: with the previous notations, we
need to ensure that 2k2 — m2 = 1. This equation has infinitely many
solutions in positive integers: the number (1 + x/i)2N+1 can be written
as mN + kNx/i, and we have m%, — 2162 = — . If (m, k) is such a
solution, we look for n = kd such that [nx/fij = md, which by the
inequalities in part a) is equivalent to d < [ex/5 + m. On the other hand,
the inequality gcd (n, lm/ij) > v4 7.9977,2 is equivalent to d > \/7.99k.
But if k is large enough, then we can find an integer d between v7.99k
and Isa/5 + m = k\/§ + V219E — 1, and setting n = kd gives a solution of
the problem for any such k.
D
16. (AMM) The greatest common divisor of a set D of positive integers is 1.
Prove the existence of a bijection f : Z —> Z such that If(n) — f(n— 1)| 6
D for all integers n.
Proof. First of all, we claim that we may assume that D is finite. Indeed,
if D is infinite, arrange its elements in increasing order a1 < (12 <
Setting 33,, = gcd(a1,...,an) we have can 2 sen“, thus the sequence
(xn)n21 is eventually constant and this constant divides all elements
of D, so it must be 1. In other words, D contains a finite subset whose
gcd is 1.
506
Chapter 8. Solutions to practice problems
Assuming that D is finite, we will prove by induction on the number |D|
of elements of D that we can find a bijection f : Z —> gcd(D) - Z such
that |f(n) — f(n — 1)| E D for all n. The case |D| = 1 is obvious: if
D = {d}, simply set f (n) = nd. Assume now that the result holds for
all finite sets of cardinality smaller than k and consider D of cardinality
k. Fix some element b e D and consider D’ = D \ {b}. To simplify
notations, write d = gcd(D), d’ = gcd(D’) and k = ”’3'. Applying the
inductive hypothesis to D’, we find a bijection g : Z —> (1’Z such that
|g(n) — g(n — 1)| E D’ for all integers n. We will construct the function
f in the next paragraph.
Pick any integer n and write n = qk + 1' with 0 S r < k.
Define
f(n) = g(q) + br if q is even and f(n) = g(q) + b(k — 1 — r) if q is
odd. It is not difficult to check that any multiple of d can be uniquely
written d’u + br with u e Z and 0 S r < 19 (it suffices to use the equality
d = gcd(d’, b)). From this it follows immediately that f is bijective. On
the other hand, let us check that I f(n) — f(n — 1)| E D for all n. If It
does not divide n, then by construction I f (n) — f (n — 1)| = b E D. On
the other hand, if n = [cm is a multiple of k, then again by construction
|f(n) — g(n — 1)| = |g(x) — g(n: — 1)| E D’ C D. This shows that f has
all desired properties and finishes the proof.
El
17. (China TST 2012) Let n be an integer greater than 1. Prove that there
are only finitely many n—tuples of positive integers (a1,a2, ...,a,n) such
that
a) a1 > (12 >
> an and gcd(a1,a2, ...,a,n) = 1;
b) a1 = n(al, a2) + n(02, as) +
+ n(an—1,an) + gcd(an, a1).
Proof. The essential part consists of course in understanding what con—
dition b) really says. Since gcd(ai,a,-+1) 3 (ii — (rt-+1 for 1 S 2' < n (this
uses part a)), it follows that
n(al, a2)+---+n(am 01) S 01 -a2+az—aa+---+an—1-an+n(am 01)
8.2.
GOD and LCM
507
hence 0.1 3 a1 — on + gcd(an,a1) and an S gcd(an,a1). Since an 2
gcd(an, 0.1), this means that all previous inequalities must be equalities.
Thus ai = a¢+1 + gcd(a¢,ai+1) for 1 S i < n and an | 0.1.
Let bi = m for 1 S i < n. Then az- = ai+1(1 + 31;) and so
— =
an
(
1 + —
b1
1 +
bn—l
is an integer. Note that this integer is less than or equal to 271—1 since
each factor of the product is less than or equal to 2. The following lemma
implies that there are only finitely many such tuples (b1, ..., bn_1).
Lemma 8.5. For any positive real number a: and any positive integer Is
there are only finitely many (maybe zero) k-tuples (b1, ..., bk) of positive
integers such that
(1+%)-(1+%)...(1+é)=x.
Proof. This is easily proved by induction on k, the assertion being clear
for k = 1. Assume that it holds for k — 1 and let us prove it for k. Of
course, we may assume that a: > 1, as otherwise there is no solution. If
1
1
1
(1+E)'(1+E)...(1+E)—x,
then some bi must satisfy 1 + bl,» > ” x, and this bi can only take finitely
many possible values. By the inductive hypothesis, for each possible
value of bi we can find only finitely many k — 1—tuples (bj)j¢i satisfying
1] 1+i
— x ’
b,_1+%
J'sé‘i
.
yielding the desired result.
III
508
Chapter 8. Solutions to practice problems
We haven’t used so far the hypothesis gcd(a1,...,an) = 1. Note that
b1b2...bn_1a,- is a multiple of on for all 1 3 1' S n. Thus an must divide
blbz...b _1 gcd(a1, ..., an) = b1b2...bn_1
and so on can only take finitely many values. Since b1, b2, ..., bn_1 also
take only finitely many values, it follows that all ai’s have the same
property and the problem is solved.
El
18. Integers a, b and rational numbers as,y satisfy y2 = x3 + ax + b. Prove
that we can write a: = 3“; and y = ”1% for some integers u,v,w, with
gcd(u,'u) = gcd(w,v) = 1.
Proo. Write x = 2 and y = 58 with p, q,'r,s integers, q,s > 0 and
gcd(p, q) = gcd(r, s) = 1. Clearing denominators, the equation
y2 = x3 + ax + b
is equivalent to
r2q3 = p332 + apqzs2 + bq332.
The right-hand side is a multiple of 32, hence $2 | r2q3. Since gcd(1‘, s) =
1, it follows that 32 | q3. On the other hand, taking the equation modulo
q3, we obtain 1232(1)2 + aq2) E 0 (mod q3). Since gcd(q,p) = 1, we have
gcd(q,p(p2 + aq2)) = 1, hence the previous congruence yields q3 | 82.
We conclude that q3 = 32. But then q is a square, say q = 122, and
necessarily s = v3. The result follows.
El
19. (Kvant M 905) Let :1: and n be positive integers such that 4:17” + (a: + 1)2
is a perfect square. Prove that n = 2 and find at least one so with this
property.
Proof. Let 4x" + (a: + 1)2 = 312. Then
(y—m—l)(y+x+1)=4a:"
8.2.
GCD and LCM
509
and since y — m — 1 and y + m + 1 have equal parity we conclude they
are even. Set y—m—l = 2a. Theny+m+1 = 2(a+m+1) and
we get a(a + m + 1) = 11:". But a and a + m + 1 are relatively prime
since otherwise m + 1 and :13” would have a common divisor. Hence
a = u”, (1 +53 + 1 = v”,m = M) and therefore m; + 1 = v” — u”. But this
is not possible for n = 1 (since on > 'u — u) or n 2 3 since in this case
on — u” = (v — u)(v"'1 + vn'zu + - - ' + un‘1)2 uv + 2.
Hence n = 2 and for m = 2 we have that y = 5 (this is not the only
solution, for instance for m = 104 we have that y = 233).
El
20. Solve in positive integers the equation
1
1
1
Proof. The equation is equivalent to
2
2
m+y
2: (z).
fl
Since z2 | (mg/)2, we have 2 | my, hence there is a positive integer t such
that my = zt, and then the previous equation yields 51:2 + y2 = t2. By
theorem 3.50 and by symmetry in m and y we may write
:1: = d(m2 — n2),
y = dn,
t = d(m2 + n2)
with m > n > 0 of different parities and relatively prime. Then my = zt
can be written as
z(m2 + n2) = 2dmn(m2 — n2).
Note that m2 + n2 is odd and relatively prime to m, n, m2 — n2, since
m, n are relatively prime and of different parities. Thus m2 + 712 must
divide (1. Writing d = k(m2 + 77,2) and recalling that z = it! we obtain
the solutions
m = k(m4 — n4),
y = 2km‘n(m2 + n2),
2 = 2I<:mn(m2 — n2)
510
Chapter 8. Solutions to practice problems
and (recalling the symmetry in a: and y)
x = 2km’n(m2 + n2),
y = I<;(m4 — n4),
2 = 2kmn(m2 — n2).
III
21. (Romania TST 2015) A Pythagorean triple is a solution (x, y, z) of the
equation x2 + y2 = 22 in positive integers, where we count (as, y, z) and
(y, :13, 2) as the same triple. Given a non-negative integer n, prove that
some positive integer appears in precisely n distinct Pythagorean triples.
Proof. We will prove that 3‘" appears in precisely n Pythagorean triples.
This is clear when n = 0, so assume that n > 0. First, the equation
x2 + 3,12 = 32” does not have solutions with x,y > 0. Indeed, it is not
difficult to see that m, 3/ must be multiples of 3, thus a: = 3:31, y = 3y1 and
a}? + yf = 32("‘1), thus we can repeat the argument and obtain positive
integers wn, yn such that 93,2, + 31,2, = 1, which is obviously impossible.
Let us deal now with the equation 32'"+'y2 = 22.Then (z—y) (z+y) = 32”,
thus 2 — y = 3“ and 2 +31 = 3b with (1+ b = 277.. This gives us 3/ = 333“
and z = 3b+3°. Note that since y > 0, we must have b > a. Conversely,
for each b E {n + 1,...,2n} setting a = 2n — b and defining y,z by
the formulae above we obtain a solution.
Pythagorean triples containing 3”.
We obtain thus exactly n
El
22. Find all triples (x, y, n) of positive integers with gcd(a:,n + 1) = 1 and
:13” + 1 = yn+1_
Proof. If n = 1 we obtain a; = y2 — 1 and since a: must be odd, 3/ can be
any even positive number. Assume that n > 1 and that :11" + 1 = 34”“,
with gcd(:c,n + 1) = 1. Then
(11 - 1)(y"' + 31’“ +
+y+ 1) = x”-
If d is a common divisor of y — 1 and y” +
n + 1 (since y” +
+ y + 1, then d divides
+ y + 1 E n + 1 (mod y — 1)) and d divides 51:", but
then d | gcd(a:",n+ 1) = 1. Thus y — 1 and y" +
+3] + 1 are relatively
prime. Since their product is an nth power, we deduce that both are
8.2.
511
GCD and LCM
nth powers. Say 3;" + + y + 1 = a" for some positive integer a. Since
n > 1, the binomial formula shows that
y"<y"+...+y+1<(y+1)",
yielding y < a < y+ 1, a contradiction. Thus there are no solutions with
n 2 2.
El
23. Let n be a positive integer such that n2 is the difference of the cubes of
two consecutive positive integers. Prove that n is the sum of the squares
of two consecutive positive integers.
Proof. Let n2 = (m + 1)3 — m3. Then n is odd and n2 = 3m2 + 3m + 1
which can be written as (217. + 1)(2n — 1) = 3(2m + 1)2. Since 2n — 1
and 2n + 1 are relatively prime it follows that one of them is a perfect
square. But n is odd and 211. + 1 E 3 (mod 4), so 2n + 1 is not a perfect
square. Hence 2n — 1 = (2l + 1)2 and n = l2 + (l + 1)2.
El
24. (Vietnam 2007) Let x,y be integers different from —1 such that a;4:11 +
9% is also an integer. Prove that m4y44 — 1 is a multiple of a: + 1.
Proof. Let a = ”34—1
and b = 3’3.
By assumption a, b are rational
a:+1
y+1
.
.
4-
numbers and a + b 1s an integer. Note that ab = 2:11 - 35¢? is also an
integer, since u4 — 1 is a multiple of u + 1 for any integer 11.. Thus the
polynomial (X — a) (X — b) = X2 — (a + b)X + ab has integer coefficients
and rational roots a, b. We deduce that a, b are integers, thus a:+1 | y4—1.
Then clearly a: + 1 | 3144 — 1 and since :34 E 1 (mod :1: + 1), the result
E!
follows.
25. (Balkan 2006) Find all triplets of positive rational numbers (m, n, p) such
that the numbers m +—-n1p, n +—
1pm, 1) +—
1—n are all integers.
Proof. Clearly mnp plays a key role in the problem, so denote a— mnp.
a._-_|—_1 a_+1 a__+1
By assumption up, pm , mn are integers, hence so is their product, i.e.
Chapter 8. Solutions to practice problems
512
Egg is an integer. Write (a + 1)3 = ka2 for some integer k, then
a is a rational root of the monic polynomial with integer coefficients
(X + 1)3 — s. Thus a is an integer. But then a | 142a2 = (a. + 1)3, thus
a | 1 and so a = 1. It follows that % = n1 = 2m is an integer and similarly 2n and 2p are integers. Moreover, the product of 2m, 2n, 2p equals
8. Considering the possible decompositions of 8 as a product of three
positive integers, we obtain the solutions (1,1,1), (4, %, %) , (2, %,1) and
their permutations.
26. A polynomial f has integer coefficients and satisfies | f(a)| = | f (b)| = 1
for some distinct integers a, b.
a) Prove that if |a — b| > 2, then f has no rational root.
b) Prove that if |a — bl = 2, then the only possible rational root of f is
m
2 .
Proof. a) Assume that x = 2 is a rational root of f, with p, q relatively
prime integers. By example 3.64 we know that we can write
f(X) = (qX —p)g(X)
for some polynomial g with integer coefficients. Then
|(qa—P)| ' |9(a)| = |f(a)l = 1
and so |qa —p| = |g(a)| = 1. Similarly |qb —p| = 1. But then
|qa—qb| = |(qa—p)-(qb—p)l S |qa-p|+|qb-p| =2,
thus la — b| S 2 (as |q| 2 1), a contradiction.
b) We still obtain |qa. — qb| S 2 and since la — bl = 2 we must have
|q| S 1. Since trivially |q| Z 1, we deduce that all previous inequalities
must be equalities. In particular |q| = 1 and the numbers qa — p and
p — qb must have the same sign. Since both have absolute value 1, we
must have qa — p = p — qb, thus a: = g = “T”, as desired.
El
8.2.
GOD and LCM
513
27. (Turkey 2003) Find all positive integers n for which 22"+1 + 2" + 1 is a
perfect power.
Proof. Assume that 22"+1 +2n+ 1 = ak for some integers a, k > 1. First,
I:
assume that k is even and let b = 0.5, so that
2"‘(2"+1 + 1) = b2 — 1 = (b — 1)(b+ 1).
Since gcd(b — 1,b + 1) = 2, we deduce that 2‘”—1 | b — 1 or 2"—1 I b + 1.
Write b — r = 2n‘1c with 7' e {—1, 1} and c > 0. The previous equality
is equivalent (after division by 2”) to
27““1 + 1 = c(r + 2"_2c),
or equivalently
2”_2(02—8)+c'r— 1:0.
Hence c2—8 I cr—l | (9—1 andsoc2—8 I7. Thiseasilyimpliesc=3
(the case 0 = 1 is easily excluded by going back to the equation) and
then r = —1 and n = 4, which is indeed a solution of the problem, and
the only solution for which R: is even.
Suppose now that k is odd. Then
2"(2"+1 + 1) = ak — 1 = (a — 1)(1 + a +
+ a“).
Clearly a is odd, hence 1+a.+...+a'°_1 is also odd. The previous relation
implies that 2" | a— 1 and 1+a.+
and 1 +a +
+al°_1 | 2"+1 + 1. Thus a 2 2" + 1
+0!“1 3 2"+1 + 1. But
1+a+...+ak_121+a+a2>1+2n+2zn>1+2n+1,
a contradiction. Hence there are no solutions in this case and n = 4 is
the only solution of the problem.
El
Remark 8.6. The equation 22""'1 + 2” + 1 = x2 was proposed at IMO
2006 (D.
514
Chapter 8. Solutions to practice problems
28. Let f be a polynomial with rational coefficients such that for all positive
integers n the equation f (at) = n has at least one rational solution. Prove
that deg(f) = 1.
Proof. Clearly f cannot be constant, so assume that d = deg(f) > 1. Let
mn be a rational solution of the equation f(:1:.n) = n. Choose a positive
integer N such that the polynomial Nf = g has integer coeflicients.
Then g(:rn) = nN and by the rational root theorem the denominator
of (on (when written in lowest form) divides the leading coefiicient C' of
g. Letting an = 0%, we obtain a sequence of integers an such that
g (961) = nN. Note that an aé am for all n aé m by the previous equality.
Thus a1, ..., on are pairwise distinct integers, and so any positive integer
appears at most twice among |a1|,|a2|,.... On the other hand, since
deg(g) = d > 1, there is M such that for lzl > M we have |g(x)| 2 :32.
For n large enough we have lanl > cM and so
we»
an2
0
We deduce that Ianl S ex/n—N = D\/fi. But then among |a1|, |a2|, ..., |an|
there can be at most Dfi + E (E being another constant independent
of n) distinct integers, contradicting the fact that each positive integer
appears at most twice in this sequence. Thus d = 1.
El
29. (Kyiv mathematical festival 2014)
a) Let y be a positive integer. Prove that for infinitely many positive
integers a: we have
lcm(a:,y + 1) -1cm(:1; + 1,y) = x(:r + 1).
b) Prove that there exists positive integer 3/ such that
lcm(x,y + 1) - lcm($ + Ly) = My + 1)
for at least 2014 positive integers a3.
8. 2.
GOD and LCM
515
Proof. a) Note that lcm(x,y + 1) is a multiple of :1: and lcm(a: + 1, y) is
a multiple of :1: + 1, thus the equality in the statement of the problem is
equivalent to the simultaneous equalities lcm(x, y + 1) = :1: and lcm(x +
1,y)=:z:+1,i.e. toy+1|az andy | a:+1. Look forw=k(y+1), the
condition y | a: + 1 is equivalent to y | Icy + k + 1, or y | k + 1. It is thus
enough to take a: = (ry — l)(y + 1) for 1' > 1.
b) The same remarks as in part a) show that the equality is satisfied
ifand only ifcc | y+1anda3+1 | y. Takingy = 22N—1withN
large enough, any a: = 22d with 1 S d S N — 1 satisfies m | y + 1 and
x + 1 | y.
El
30. (Kvant M 666) Find the least positive integer a for which there exist
pairwise different positive integers a1, a2, . . . ,ag greater than a such that
lcm(a, a1, a2, . . . , a9) = 10a.
Proof. We may assume that a < (11 < - - - < a9.
Set A =1cm(a,a1,a2,...,a9). Then
A
A
-
are positive integers and therefore 3 2 10. Since 3 = 10 we conclude
that
é=m 4=,,W _=1
A
0,
a1
0:9
Hence
a9—
— A7
a8—21'”:
- é
a 1—9)
— A
— A
a—IO
and A is divisible by lcm(2, 3, . . . , 10) = 2332.5.7. The least a is equal
to 23312—65'7 = 252. In this case the numbers ak = 213615;;7, k = 1,2, . . . ,9
satisfy the given condition.
III
516
Chapter 8. Solutions to practice problems
31. (Korea 2013) Find all functions f : N —) N satisfying
f(mn) = lcm(m) 77') ' gcd(f(m), f(n»
for all positive integers m, 77..
Proof. Taking m = 1 and setting a = f(1) we obtain
f(n) = n ' gcd(a, f(m)In particular n | f(n) for all n. Next, replacing n by an we obtain (taking
into account that a | f((112))
f (an) = an . gcd(a, f (an)) = 0,217..
Finally, replacing n by an in the original relation, we obtain
f(amn) = 10m(m, an) - gcd(f(m), f(0%)),
which can be rewritten
azmn—— m gcd(f(m) f(m))
Dividing this last relation by amn, we deduce that a | gcd(f (m), f (an))
and so a | f (m) for all m. But then gcd(a, f(n)) = a and so f(n) =
n - gcd(a, f (77.)) = an for all 71.. Conversely, it is not difficult to see that
for any positive integer a setting f(n) = an we obtain a solution of the
problem.
El
32. (Romania TST 1995) Let f(n)= lcm(1, 2,. ..,n). Prove that for any
n 2 2 one can find a positive integer a: such that
f(m) = f($+ 1) =
= f(w +71)-
8.2. GCD and LCM
517
Proof. It suffices to find :3 such that 9: + 1, a: + 2, ..., :1: +n are all divisors
of lcm(1,2, ...,x) = f(a:). Choose a: = 1 + N! for some N to be chosen
later. Then for all j 6 {1,2, ...,n} we have
N!
x+'='+1+N!='+1(,—+1).
J J
(.7 ) a + 1
If we manage to ensure that j+1 and % + 1 are relatively prime integers
between 1 and x, it will follow that a: + j divides f(a:). But this is very
easy to realize: simply take N such that N! is a multiple of (j + 1)2 for
all j S n, which is certainly possible.
[I
33. Prove that for all positive integers a1, ..., an
lcm(a,1, ...,an) 2 &_
HISKa nWi, 03')
Proof. If n = 2, the desired inequality is an equality. Next, we prove
the result by induction. Assuming that it holds for n — 1, denote m =
lcm(a,1, ..., an_1) and observe that
10m(a1,
man
,an) = lcm(m,an) = —.
gcd(m,a,,,)
Using the inductive hypothesis, we are reduced to proving that
an
gcd(m,a,n)
.
a1...a.,,_1
a1...an
ni<jgn—1g0d(ai,aj) _ niqgn nWhaj),
or equivalently
n—l
gcd(m,an) S H gcd(an,ai)i=1
But using exercise 1 (more precisely an n— l-variable version of it, which
follows directly from the cited corollary and an obvious induction) we
obtain
n—l
gcd(m,an) S gcd(a1...an_1,an) S H gcd(a,,,,a,,-).
i=1
III
518
Chapter 8. Solutions to practice problems
34. (AMM 3834) Let n > 4 and let a1 < a2 <
< an S 2n be positive
integers. Prove that
< 6(|_n/2j +1).
Brigg” 1cm(a,-,aj)_
Proof. The key (simple) observation is that for any 1 S t S n we can find
a positive integer k- such that ha, 6 {n + 1, ...,2n}. Indeed, if a,- > n
simply choose 19,: 1, otherwise since 2:: — 4% _>_ 1 there is an integer k,
between”
—, and 2—1‘.
a:
at
Using this observation, it is not diflicult to conclude: if kia, = ij
for some t 75 j, then kiai is a common multiple of a, and aj, thus
lcm(a,', a,-) S kiai 3 2n and we are done (with an even better bound).
If this never happens, then the pairwise distinct numbers k1a1, ..., knan
between n + 1 and 2n must be a permutation of n + 1, ...,2n. Since
n > 4, we have 3( [n] + 1) E {n+ 1,. .,2n} (3(L-2—j + 1) is clearly greater
than 3T” > n and smaller than or equal to—
211+ 3 and this is smaller
than or equal to 2n for n 2 6; one easily checks the claim for n— 5).
Similarly 2( [g] + 1) e {n+ 1, ..., 2n}, thus there are indices 1', j such that
kiaz- = 2([g] + 1) and ij = 3([gj + 1). But then lcm(a,-,aj) divides
I]
6( Lg] + 1) and the result follows.
Remark 8.7. The result does not hold for n = 4: consider the numbers
5,6,7,8. On the other hand, it is not difficult to check that it holds
for n S 3. The expression 6(I3J + 1) is optimal, since one can check
without too much difficulty that we have equality for the sequence n +
1,n+2,...,n+n.
35. Let (an)n21 be a sequence of integers such that m — n I am — an for all
m,n 2 1. Suppose that there is a polynomial f such that |an| S f (n) for
all n 2 1. Prove that there is a polynomial P with rational coeflicients
such that an = P(n) for all n 2 1.
Proof. Let (1 = deg f and define
d+1
P(X)= 2014—1—k=1
jaék
8.2.
GOD and LCM
519
This intimidating polynomial is the unique polynomial of degree 3 d
such that P(n) = can for 1 S n S d + 1. We will prove that an = P(n)
for all n.
Note that P has rational coefficients, so we can find a positive integer
N such that all coefficients of NP are integers. Consider the sequence
(bn)n21 defined by b = Nan — NP(n) It is a sequence of integers and
it satisfies m — n I bm — bn for all n (since the sequences (Nan)n21 and
(NP(n))n21 have this property, the first by assumption and the second
since NP has integer coefficients. ). Since bl =
= bd+1 = 0, this
implies that n - 1, ...,n — (d+ 1) all divide b", thus
lcm(n — 1, ...,n — d — 1) | bn.
On the other hand, exercise 33 yields the existence of a constant C(d)
(depending only on d) such that for all n > d + 1
lcm(n — 1, ...,n — d — 1) 2 C(d)nd+1.
Since deg f, degP S d, we have
Ibnl S Nf(n) + N|P(n)| < O'(d)nd"'1 S lcm(n — 1, ...,n — d — 1)
for n large enough. Thus we must have bn = O for n large enough, say for
n 2 M. But then for anyn 2 1 andm 2 Mwe have m-n | bn—bm = b",
thus necessarily b, = 0 and so an = P(n) for all n.
36. Let n, k be positive integers and let 1 < 0.1 <
El
< ak S n be a sequence
of integers such that lcm(a,-,aj) S n for all 1 S i, j S k. Prove that
k S 2 [Jr—1,].
Proof. We have
aiai+1
aiai+1
naicmai
ai+1 —a,,-’
gcd(a,-,a,-+1)
( , a-1+1) =—2—
1
ai+1
Z
§|*-‘
.E’IH
which can also be written as
520
Chapter 8. Solutions to practice problems
forlgi<k.GivenlSjSk—1,weobtain
m1- 1 >229,
k-l
i=j
-
a1-
ai+1
n
which simplifies to aij — i 2 16—171. Since ak S n, this last inequality yields
a,- < 76%. On the other hand, since aj > aj_1 >
> a1 2 1, we must
have a,- 2 j. We conclude that for all 1 g j < k we have j(k—j+1) S n.
Write [6+1 = 2q+r for some r 6 {0,1} and some q 2 1 (ifq=0, then
k < 2 and we are done). Then q < [6, hence q(k+ 1 — q) S n. This yields
q2 S n, hence q S [W] and then k 3 2q 3 2 [fl].
III
37. (AMM E 3350) For n 2 1 and 1 S k S n define
A(n, k) = lcm(n,n — 1, ...,n — k + 1).
Let f(n) be the largest k such that A(n, 1) < A(n, 2) <
a) Prove that f(n) S 3%.
< A(n, k).
b) Prove that f(n) > k if n > k! + k.
Proof. We need to make a few observations before embarking on the
proof. The first and most important observation is that since
A(n, k + 1) = lcm(n — k, A(n, k)),
we always have A(n, k + 1) 2 A(n, k), with equality if and only if n — k
divides A(n, k). We deduce that if A(n, k) = A(n, k + 1), then
A(n+j,k+j) =A(n+j,k+j+1)
for alljz 1 and so f(n+j) Sf(n)+j for all n,j21.
a) We claim that it suflices to prove that f (n2) _<_ n for all n. Indeed, if
this happens, then for any n we can find k such that k2 S n < (k + 1)2,
thus
f(n)gf(k2)+n—k2gk+n—k2gk+k2+2k—k2=3kg3¢fi,
8.2.
GOD and LCM
521
as needed. In order to prove that f (n2) 3 n, it suffices to prove that
A(n2,n) = A(n2,n + 1), or equivalently that n2 — n | A(n2,n). This is
very simple, since n2 — n already divides A(n2, 2) = n2 (n2 — 1).
b) We have
(n — k)A(n, k)
A(n, k + 1) = lcm(n — k, A(n, k» = W
(n— k)A(n, k)
>gcd(n— k, n) --gcd(n k,n—1)..-gcd(n — k,n — k + 1)
>-A(n,k) (n— k)
>—k!
_
Thus for n > k! + k we have A(n, 1) <
< A(n,k + 1) and so f(n) >
k.
[I
38. Let a1 < (22 <
< an be an arithmetic progression of positive integers
such that a1 is relatively prime to the common difference. Prove that
alaz...an divides (n — 1)! . lcm(a1, ..., an).
Proof. Let d be the common difference, so ai = a1+(z'— 1)d for 1 S i S n.
The key ingredient is the identity
can-1m — 1)! = iHYH
alag...an
(3:3)
a1 + (k — 1)d'
This follows from the identity
(33+1)?.!(a:+n)
=2<—1>’Hfl
a:+k,
k_1
that has already been established during the solution of practice problem
36 in chapter 1, by letting a:— —1 and by observing that 16(2): 710:3
The right—hand side 1s clearly ofalthe form —5
for some integer s.
cm(a1
Thus alag. .an divides d"_1(n — 1)!lcm(a1,.. .,.an) But a1 and hence
all the a,- are relative prime to d, so we may cancel off the factor of d"_1.
I]
The result follows.
522
Chapter 8. Solutions to practice problems
39. Let n > 1 and let (10 < (11 <. .< an be positive integers such that
111—0," ., a—1 is an arithmetic progression. Prove that
211.
a >
0 - n+1
.
Proof. Let M = lcm(ao,...,an) and write M = (Lib,- for positive integers b0 > b1 >
> bn. By assumption b0,...,bn form an arithmetic
progression and b,- | M for all 2', thus M 2 1cm(bo, ..., bn) and so
ao 2
lcm(bo, ..., bn)
b0
.
It suffices to prove that for any arithmetic progression bn <
< be of
positive integers we have
lcm(bo, ...,bn) > 2"
b0
- n + 1'
Let d be the common difference of bn <
< b0.
Dividing each bi
by gcd(d,bn) does not change the quotient m, thus we may
assume that gcd(d,bn) = 1, in which case gcd(d,bbbg—
— 1 for all i (since
bi—
— bn + (n—i)d) Thus gcd(d, b0" .bn)- 1 and so gcd(d, bo.. .bk) = 1 for
all k < 71. Let k—
— |_—J and apply the previous exercise to the arithmetic
progression b0 > b1 > .> bk. Since gcd(d, b0. .bk)—
— 1, we deduce that
lcm(bo,...,bn) > lcm(bo,...,bk) > b1...bk
b0
_
b0
_
k!
'
Observe now that bn 2 1, bn_1 2 2, in general bj 2 n — j + 1, thus
bk 2n—k+1,,... b1b>n. Thus
b1...
>n(n— 1)...(n— Ic+1)= n
klbk _
k!
k '
Since the binomial coefficient (2) is the largest among (7:) with 0 S t S n,
and since these binomial coefficients add up to 2'", we have
The result follows.
2n
n
>
R:
_n+1
.
E]
8.3.
8.3
The fundamental theorem of arithmetic
523
The fundamental theorem of arithmetic
1. Prove that if a is an integer greater than 1 and if n > 1 is not a power
of 2, then a” + 1 is composite.
Proof. Since n is not a power of 2, we can write n = 2k - m with m > 1
odd and k 2 0. Then a2k + 1 divides (a2'°)m + 1 = a” + 1 and 1 <
azk + 1 < a" + 1, hence a" + 1 is composite.
El
. (St. Petersburg 2004) Prove that for any integer a there exist infinitely
many positive integers n such that a2" + 2” is composite.
Proof. If a = 0 we can choose any integer n > 1, so assume that a 75 0.
Replacing a with —a, we may assume that a > 0. If a = 1 choose any
n > 1 which is not a power of 2 and use the previous exercise, so assume
that a > 1. Then choose any odd integer k > 1 and set n = 2k. We
have
a2" + 2” = a2" +4 -4""1 = x4 +4314,
where a: = a2"_2 and y = 2k2;1. Note that say > 1 and
m4 + 4314 = (x2 + 2:142)2 — (2mg)2 = (x2 — 2333/ + 2:1,12)(:132 + 2mg + 23/2)
is composite.
El
. Find all positive integers n for which at least one of the numbers n" + 1
and (2n)2" + 1 is composite.
Proof. n = 1 and n = 2 are not solutions of the problem since 22 + 1 and
44 + 1 = 28 + 1 are primes. We will prove that all n > 2 are solutions.
Suppose that n > 2 and that n” + 1 and (2702” + 1 are primes. By
problem 1, 17. must be a power of 2, say n = 2’“. Then n” + 1 = 2“" + 1
is a prime, hence k - 2k is a power of 2 and so k is a power of 2. Next,
(2n)2n+1 = 2(7“H)2k+1 +1 is prime, hence (k+1)2k+1 is a power of 2 and
so k + 1 is a power of 2. But then k and k + 1 are consecutive numbers
and both powers of 2, thus k = 1 and n = 2, a contradiction.
III
Chapter 8. Solutions to practice problems
524
4. For which positive integers n the numbers 2" + 3 and 2” + 5 are both
primes?
Proof. It is not difficult to check that n = 1 and n = 3 are solutions,
while 11. = 2 is not a solution. We claim that no n > 3 is a solution.
Assume that n > 3 and that both 2" + 3 and 2" + 5 are primes. If
n — 1 (mod 3), then 7 | 2" + 5 and 2” + 5 > 7, a contradiction. If
n _ 2 (mod 3) then 7 l 2" + 3 and 2" + 3 > 7, again a contradiction.
Hence n is a multiple of 3. Also, 17. is clearly odd since otherwise 2“ + 5
would be a multiple of 3. Thus 72. E 3 (mod 6), say n = 6k + 3. If k
is odd, then 2“ + 3 = 82“1 + 3 is a multiple of 5, impossible. Hence k
is even, but then 13 | 2” + 5 = 82“1 + 5 and 8%"1 + 5 > 13, again a
contradiction.
[I
(St. Petersburg 1996) Integers a, b,c have the property that the roots
of the polynomial X3 + aX2 + bX + c are pairwise relatively prime and
distinct positive integers. Prove that if the polynomial aX2 + bX + c has
a positive integer root, then |a| is composite.
Proof. Let x1, 932,1:3 be the roots of the polynomial X3 + aX2 + bX + c.
Then :31 +932 +553 = —a, thus |a| Z 3 since x1,a:2,:1:3 2 1 by assumption.
If a is even, then clearly |a| is composite, so assume that a is odd.
Then :01 + 3:2 + x3 is odd, so either $1,332,533 are all odd, or exactly
one of them is odd. This latter case is excluded by the assumption that
.731, x2, x3 are pairwise relatively prime. Thus :61, x2, :33 are all odd. Since
b = 561.162 +x2x3 +w3x1 and —c = $193293, it follows that b and c are odd.
But then axz + bx + 0 cannot have integer roots, since if y is an integer
root then cry2 + by + c E y2 + y + 1 E 1 (mod 2). Thus a is even, and
we are done.
III
(Vojtech Jarnik Competition 2009) Prove that if k > 2 then 22L1 —2’6 — 1
is composite.
8. 3.
The fundamental theorem of arithmetic
525
Proof. Let N = 22L1 — 2" — 1, then
2N = 22" —1—(2’“+1+1)=(2—1)(2+1)(22+1)...(22’“'1+1)—(2’°+1+1).
If k + 1 = 2mn with m 2 O and n odd, then 2’6+1 + 1 is a multiple of
22'" + 1, and (2+ 1)(22+ 1)...(22"‘1 + 1) is also a multiple of 22’” + 1, since
m S k — 1 (indeed m < 2"" g 2mn = k: + 1). Thus 2N is a multiple of
22m +1 and so 22m +1 I N. On the other hand, suppose that N = 22m +1,
then since N E —1 (mod 4) we must have 22'" E —2 (mod 4) and so
m = 0, but then N = 3 which is impossible since N > 3.
I]
7. A positive integer which is congruent 1 modulo 4 has two different representations as a sum of two squares. Prove that this number is composite.
Proof. Let n be our positive integer and consider two representations
n = :62 + y2 = U2 + v2 as a sum of two squares. Since 77. E 1 (mod 4),
exactly one of m,y is odd, and similarly exactly one of u, v is odd. We
may assume that :13, u are odd and, without loss of generality, that a: > a.
Note that gcd(m—u, v—y) is then an even integer, say 2d for some positive
integer (1. Write a: — a = 2ad and v - y = 2bd with gcd(a, b) = 1. Since
(x—u) (x+u) = (v—y)(v+y), we easily obtain au+a2d = by+b2d. Note
that this common value is divisible by a and b, thus (since gcd(a, b) = 1)
it is divisible by ab. Write on + a2d = by + b2d = abc for some c.
Therefore a = bc — ad and y = ac — bd. But then a: = u + 2ad = be + ad
and v = y + 2bd = ac + bd. We finally obtain
n = x2 + y2 = (ac — bd)2 + (bc+ ad)2 = (a2 + b2)(c2 + d2),
which clearly shows that n is composite.
III
Remark 8.8. By Euler’s theorem (which will be discussed later on) each
prime of the form 4k: + 1 can be represented as a sum of two squares.
Hence the problem above implies that a number n = 4k + 1 is a prime
iff it has only one representation as a sum of two squares.
526
Chapter 8. Solutions to practice problems
8. (Moscow Olympiad) Is there an 1997—digit composite number such that
if any three of its consecutive digits are replaced by any other triplet of
digits then the resulting number is composite?
Proof. Such a number does exist. Let A be the product of all odd numbers from 1001 to 1997. Since each of these numbers is less than 2000
we see that
A < 2000500 = 2500101500 = 32100101500 < 100100101500 = 101700.
Now we write several 0’s and an 1 to the end of A and then three more
0’s so that the total number of digits be equal to 1997. This number, call
it N, is composite since it is even and has the desired property. Indeed,
if the last digit of N is not replaced then the new number is even. If the
last three 0’s of N are replaced by an odd number fl then the last four
digits of the new number form the number W which divides N.
III
(AMM 10947) Prove that 55:—_‘11 is composite for all n 2 1.
Proof. Suppose that n is even, say n = 2k. Then setting a: = 5’“ we have
55n—1_:131°—1_a:5—1 a35+1
5n—1 _ x2—1 _ :13—1
w+1'
Since both factors are clearly integers greater than 1, we are done.
Assume now that n is odd. The key ingredient is the identity
X4+X3+X2+X+1 = (X2+3X+1)2—5X(X+1)2.
Taking X = 5'” with n = 2k + 1 we obtain
5571—1
5” _ 1 = (52” + 3- 5" + 1)2 — (5"+1(5"‘ + 1))2
= (52" + 3 ~ 5‘" + 1 — 5’“+1(5n + 1))(52n + 3- 5" + 1 + 5k+1(5" + 1)).
8.3.
The fundamental theorem of arithmetic
527
It suffices to check that
52" + 3 - 5" > 5k+1(5" + 1),
which is equivalent to 5’“ (5" + 3) > 5'” + 1. Since this last inequality is
clear, we are done.
El
10. Let n > 1 be an integer. Prove that the equation
(a: + 1)(a: + 2)...(m + n) = y"
has no solution in positive integers.
Proof. Assume that (93,31) is a solution. Since (a: + 1)(:1: + 2)..(:1: + n)
is between (a: + 1)" and (a: + n)“, we can write 3; = a: + k for some
k: e {2, 3, ...,n— 1}. p | x+k+ 1 is a prime, then by assumption p | y“
and so 10 | :c + k, a contradiction. The result follows.
III
11. Let n be a positive integer. Prove that if n divides (Z) for all 1 S k: S
n — 1, then 77. is prime.
Proof. Suppose on the contrary that 'n. has a prime factor p < n.
By hypothesis 31:— is a.n integer, in other words
(n-1)(n—2)...(n-p+1)
p!
is an integer, obviously impossible (as the numerator is not a multiple
of p). Hence 7?. must be prime.
El
12. (USAMTS 2009) Find a positive integer n such that all prime factors of
(n+1)(n+2)...(n+500)
500!
are greater than 500.
528
Chapter 8. Solutions to practice problems
Proof. The simplest way to ensure this is to choose 12 such that
(n+1)(n+2)...(n+500)
500!
l
_ 1 (mod 500.),
=
since any prime not exceeding 500 divides 500! and so does not divide
any number congruent to 1 modulo 500!. The previous congruence is
equivalent to
(n + 1)...(n + 500) a 500! (mod (50002).
But it is very simple to find such n’s: simply choose any multiple of
(50002. Indeed, for such n we have n +i E 12 (mod (50002), thus
(n + 1)...(n + 500) E 500! (mod (50002).
El
13. (Russia 1999) Prove that any positive integer is the difference of two positive integers with the same number of prime factors (without counting
multiplicities) .
Proof. If n is even, simply write 77. = 2n — n, so assume that n is odd.
If p is the smallest odd prime not dividing 12 (note that odd primes
not dividing n certainly exist, for instance prime factors of n + 2), then
n = pn — (p — 1)n. Since all odd prime factors of p — 1 divide n (by
minimality of p) and p— 1 is even, pn and (p— 1)n have the same number
of prime factors (and this is equal to the number of prime factors of n
plus 1).
El
14. (Saint Petersburg) An infinite sequence (an)n21 of composite numbers
satisfies
an
an+l=an_pn+—
n
for all n, where 1),, is the smallest prime factor of an. If all terms of the
sequence are multiples of 37, what are the possible values of a1?
8.3.
The fundamental theorem of arithmetic
529
Proof. Since an and an+1 are multiples of 37, so is $7: — pn. If pn 9E 37,
then 9: is a multiple of 37, while 1),, is not, thus it. — pn is not a multiple
of 37, a contradiction. Thus pn = 37 for all n. We deduce that
an+1
_a_n_ 37
(In—37
for all n. Letting b = an — 372, we have
38
bn+1 = fibrin
thus bn = ggéi-bl for all n 2 1. Since bn is an integer, we deduce that
37'“1 | b1 for all n, which forces bl = 0 and a1 = 372. Conversely, if
a1 = 372, then setting an = 372 for all n yields a sequence satisfying all
conditions of the problem.
III
15. Prove that there are infinitely many pairs (a, b) of distinct positive integers a, b such that a and b have the same prime divisors, and a + 1 and
b + 1 also have the same prime divisors.
Proof. Let n 2 2 and let a = 2" — 2 and b = 2”(2n — 2). Then a and b
clearly have the same prime divisors, and b + 1 = (a + 1)2, so a + 1 and
b + 1 also have the same prime divisors.
III
16. Let a, b, c, d, e, f be positive integers such that abc = def. Prove that
a(b2 + 62) + d(62 + f2) is composite.
Proof. Suppose that p = a(b2 + c2) + d(e2 + f2) is a prime. Multiplying
the congruence a(b2 + 02) .=_ —d(e2 + f2) (mod p) by ef and using the
hypothesis yields
aef(b2 + 02) E —abc(e2 + f2)
(mod p).
Note that p > a, so p does not divide a and so the previous congruence
yields
ef(b2 + 02) + bc(e2 + f2) E 0 (mod p).
530
Chapter 8. Solutions to practice problems
The left-hand side factors as (ce + bf)(be + cf) and so 1) divides one of
the numbers ce + bf or be + cf. On the other hand
p=a(b2+c2)+d(e2+f2)2b2+c2+62+f222ce+2bf>ce+bf
and similarly p > be + cf, a contradiction. Hence p is composite.
El
17. (Kvant M 1762) Is there a positive integer n with 2013 prime divisors
such that n divides 2" + 1?
Proof. The answer is positive. We will prove by induction that for each
It 2 1 we can find nk with exactly 1:: prime divisors, such that 3 | nk and
nk | 27% + 1. If k = 1 take m = 3. Assume now that n = nk is a multiple
of 3, has k prime factors and satisfies n | 2” + 1. Clearly n is odd, hence
3|22n—2”+1andso
23" + 1 = (2" + 1x22" — 2” + 1)
is a multiple of 3n. Note that
22n—2"+1=(2"—2)(2“+1)+3
is not divisible by 9 since 2" — 2 and 2" + 1 are both divisible by 3
for odd n. Hence the number 22" — 2” + 1 has a prime divisor p >
3. The number p is not a divisor of n since otherwise it would divide
gcd(2“ + 1, 22" — 2" + 1) = 3. Hence the number nk+1 = 3m has k + 1
divisors and divides 2""°+1 + 1.
El
18. (Poland 2000) Let p1 and p2 be prime numbers and for n 2 3 let pn be
the greatest prime factor of pn_1 +pn_2 + 2000. Prove that the sequence
(pn)n21 is bounded.
Proof. First, observe that
pn S m3X(Pn—1,Pn—2) + 2002
(*)
8.3.
The fundamental theorem of arithmetic
531
Indeed, if pn_1, pn_2 are both odd then pn_1 + pn_2 + 2000 is even and
greater than 2, thus
_
_
2000
Pn S pn_1+rm2—2+_ < maX(Pn—1,Pn—2) + 2002,
while if at least one of pn_1, pn_2 is 2 we have
pn S pn—l +pn—2 ‘l’ 2000 S maX(Pn—1,Pn—2) + 2002-
This being established, let M = max(p1, p2) - 2003! + 2 and let us prove
by induction that pn < M for all n. This is clear for n = 1, 2 and if it
holds up to n — 1, then relation (*) shows that pn < M + 2002. But
since M, M + 1, ..., M + 2001 are all composite numbers, we deduce that
pn < M and we are done.
El
19. (Italy 2011) Find all primes p for which p2 — p — 1 is the cube of an
integer.
Proof. Clearly p = 2 is a solution of the problem, so assume from now
on that p > 2. Let n be an integer such that p2 — p — 1 = 17.3. Then
p(p—1)=n3+1=(n+1)(n2—n+1).
hence p divides n+1 or 'n2 —n+ 1. Assume that p | n+1, thus 11. 2 p— 1
and then p2 — p — 1 2 (p — 1)3, which implies that (p — 1)3 < p(p — 1)
and then p2 — 3p + 1 < 0, impossible since p 2 3.
Hence p | n2 — n + 1, say 71.2 — n + 1 = kp for some positive integer
k. Coming back to the relation p(p — 1) = (n + 1)('n.2 — n + 1) yields
p — 1 = k(n + 1), hence
n2 —n+1 = kp= k(1+k(n+ 1)) = k+k2(n+1).
This can be rewritten as
n2—(1+k2)n+1—k—k2=0.
532
Chapter 8. Solutions to practice problems
Considering this as a quadratic equation in n, its discriminant
A: (1+k2)2+4(k2+k—1)
must be a square, since the equation has an integer root. One easily
checks that A is not a square for k S 2, and it is a square for k = 3, in
which case n2 — 10n — 11 = 0 yields n = 11 and then p = 37. Assume
now that k: > 3. Then an easy computation shows that
A = (k2+3)2+4(k—3) > (k2+3)2
and since A is a square we must have A 2 (k2 + 4)2, which yields
4(k — 3) 2 (k2 + 4)2 — (k2 + 3)2 = 2k2 + 7.
This last inequality is impossible for k > 3, hence the only solutions of
the problem are p = 2 and p = 37.
El
Remark 8.9. A similar problem (with p2 — p + 1 instead of p2 — p — 1)
was proposed in Saint Petersburg in 1995 and later on at the Balkan
Mathematical Olympiad in 2005. The solution to this new problem is
p = 19. Yet another similar problem was proposed at the Tuymaada
Olympiad in 2013: find all primes p,q such that p2 — pq — q3 = 1.
20. (Kvant M 2145) Let a: > 2, y > 1 be integers such that my + 1 is a perfect
square. Prove that :13 has at least 3 different prime divisors.
Proof. Write my + 1 = a2 for a positive integer a. Assume first that a: is a
power of a prime. Thus (a, — 1)(a+ 1) is a power of a prime, in particular
both a. — 1 and a + 1 are powers of that prime, and both are greater than
1. Since they differ by 2, the prime must be 2 and a — 1 = 2, thus a = 3
and my = 8, contradicting the fact that a: > 2 and y > 1.
Assume now that :1: has precisely two prime factors, say 10 < q. We have
(a — 1)(a+ 1) = any. If gcd(a— 1,a+ 1) = 1, then a — 1 and a+ 1 must
be yth powers, say a — 1 = by and a. + 1 = cy, so that cy — by = 2. This
is impossible, since
a?! — by = (c — b)(cy‘1 +
+ by—1)2 2%"1 + 1 2 3.
8. 3.
The fundamental theorem of arithmetic
533
Thus gcd(a — 1, a + 1) is not 1, and since it divides 2 it must be equal to
2. In particular p = 2. Since (a — 1)(a + 1) = my and the prime factors
of a: are 2 and q, we have two possibilities:
i) Either a — 1 = 2quy and a+ 1 = 2"”‘1 for some integers u, 1). But then
2W-2 — 1 = guy, contradicting lemma 8.10 below.
ii) Or a — 1 = 2“y_1 and a + 1 = 2q for some integers u,v. Then
21W—2 + 1 = qW. Using again lemma 8.10 below, we obtain uy — 2 = 3
and vy = 2, impossible. This finishes the proof.
El
Lemma 8.10. a) 2” — 1 is not a perfect power ifn > 1.
b) 2" + 1 is a perfect power only for n = 3.
Proof. 3.) Suppose that 2" — 1 = ab, with a, b > 1. Since 2" — 1 is of the
form 4k + 3, it cannot be a square, so b is odd. Then
2" = (1 + a)(1 — a + a2 —
+ ab_1).
Thus 1 + a and 1 — a + + ab_1 are powers of two. The second number
is odd, since a and b are. Thus we must have 1 — a +
+ ab‘1 = 1
and 2" = 1 + a. This yields 1 + a = 1 + ab, contradicting the inequality
a b > a.
b) Clearly 21 + 1 = 3 and 22 + 1 = 5 are not perfect powers. Assume
that 2” + 1 is a perfect power for some n > 3, say 2‘” + 1, = wk for some
112,]6 > 1. Then a: is odd. If k is odd, then 1 + a: +
+ ark—1 is odd,
greater than 1 and it divides 2", a contradiction. Hence k is even, say
k: = 2l. Then (ml — 1)(xl + 1) = 2" and so 23’ — 1 and 931+ 1 are powers
of 2 difi'ering by 2. This forces 93’ — 1 = 2, then a: = 3 and l = 1, that is
k = 2, and finally n = 3.
III
Remark 8.11. Using more advanced techniques (the Birkhoff—Vandiver
theorem) one can prove that :1: has at least 1 + r(y) prime divisors.
21. (Russia 2010) Prove that for any n > 1 there are n consecutive positive
integers whose product is divisible by all primes not exceeding 2n + 1,
and not divisible by any other prime.
534
Chapter 8. Solutions to practice problems
Proof. All prime factors of (n+2) (n+3)...(2n+ 1) are less than or equal
to 2n + 1. On the other hand, (n + 2)...(2n + 1) is a multiple of n!,
since it is the product of n consecutive integers. Thus if n + 1 is not
a prime, then (n + 2)...(2n + 1) is divisible by all primes not exceeding
217, + 1. Assume that n + 1 is a prime, then n + 2 is not a prime and
(n+3)...(2n+ 1)(2n+2) is divisible by n! (for the same reason as above)
and by n + 1, n + 3,...,2n + 1. Since n + 2 is not a prime, we deduce
that (n + 3)...(2n + 1)(2n + 2) is divisible exactly by the prime numbers
not exceeding 2n + 1, and the problem is solved in all cases.
III
22. (Iran 2015) Prove that infinitely many positive integers n cannot be
written as the sum of two positive integers all of whose prime factors are
less than 1394.
Proof. Let 191, ...,pk be all primes not exceeding 1394 and let 8,, be the
set of numbers 3' E {1, 2, 3, ..., 2"} all of whose prime factors are among
p1, ..., pk. Any such number 3' is of the form p‘l’” mpg" for a unique k-tuple
of nonnegative integers a1, ..., ak. Since p,- 2 2 and j S 2”, we must have
20‘i g 2“ for all z‘, thus a,- S n for all 2'. It follows that there are at most
(1 + n)’° such k-tuples and so
|S,,| s (1 + n)’°.
It follows that there are at most (n+ 1)2k numbers between 1 and 2" that
can be written as the sum of two numbers in Sn. If n is large enough,
then (1 + n)2’° < %2” (note that by the binomial formula 2" > (2131-1) if
n > 219 + 1, and (21:11) is a polynomial expression of degree 2k + 1 in
n). Thus for n large enough more than half of the numbers between 1
and 2" are solutions of the problem, yielding the result. Note that the
proof can be interpretted as saying that the probability that an integer
is a sum of two numbers whose prime factors are S k is 0.
III
23. (China 2007) Let n > 1 be an integer. Prove that 2n — 1 is a prime
number if and only if for any n pairwise distinct positive integers
8. 3.
The fundamental theorem of arithmetic
535
a1,a2, . . . ,an there exist i,j 6 {1,2, . . . ,n} such that
gcd(ai,aj) _
Proof. Suppose first that p = 2n — 1 is a prime and let a1,...,an be
pairwise distinct positive integers. Suppose that
at + a,-
gcd(a.-, aj)
for 12,j E {1,...,n}.
Dividing each of the numbers a1,...,an by
gcd(a1, ...,an), we may assume that gcd(a1, ...,an) = 1.
If there is 2' such that p | at, then we can choose j such that p does not
divide aj and then p does not divide gcd(a¢, aj). Thus p divides W
and we obtain the plain contradiction
PS
at
ai'l'aj
gcd(a1,aj)
gcd(ae,aj)
——-— < —— <
p
.
Suppose now that a1, a2, ..., an are not multiples of p. By the pigeonhole
principle, two of the numbers a1,a2, ...,an, —a1,...,—an must give the
same remainder when divided by p. So we can find i aé 3' such that
p| a + a,- or p | ai — aj. Note that p does not divide gcd(a,,aj), so 1)
divides gc—JQTGZFS for a suitable choice of the sign :1:. We obtain again a
contradiction
10>
a; + aj
n(a'ia aj)—
|—
—aj
az- :|:
|_p.
n(a‘i) aj)
So our initial assumption was wrong and the result follows.
Suppose now that 2n — 1 is composite, so we can write it as any, with
m, y > 1. Define n integers a1,a2, ...,an by choosing the first a; positive
integers 1, 2, ..., :c, then the next 11—51: even numbers x+1, x+3, ..., wy—w.
It is not difficult to check that fig]; < 2n — 1 for all 2', j.
El
536
Chapter 8. Solutions to practice problems
24. (Tournament of the Towns 2009) Initially the number 6 is written on a
blackboard. At the nth step, one replaces the number d written on the
blackboard with d + gcd(d, n). Prove that at each step the number on
the blackboard increases either by 1 or by a prime number.
Proof. This problem is very diflicult!
Let an be the number on the
blackboard at step n, so that a0 = 6 and
an = an_1 + gcd(an_1, n).
Let bn = an — an_1, hence we need to prove that bn is either 1 or
a prime for all n. The first few values of the sequence b1,b2,
are
1,1,1,1,5,3,1,1,1,1,11,3,....
The crucial claim is the following: suppose that on = 3n and that bn+1 =
1. Let k be the smallest positive integer such that bn...;c aé 1. Then bm.)c
is a prime and on“; = 3(n + k). We will prove this claim by induction.
It is not difl'icult to check it for n S 5 using the previous explicit values
for the sequence (bn)n21. It is not diflicult to see that an+1 = 3n + 1,
an+2 = 3n + 2,.., an+k_1 = 3n + k — 1 and so
bn+k=gcd(n+k,3n+k—1)=gcd(n+k,2k+1) | 2k+1.
Suppose that 2k + 1 is not a prime and let p be a prime factor of
gcd(2k + 1,n+ k). Then p 3 L32” < k and
bn+k_p=gcd(n+k—p,3n+k—p—1)=gcd(n+k—p,2k+l—2p)
is a multiple of p, contradicting the fact that k was minimal with bn+k 7E
1. Thus 2k + 1 is a prime and bn+k = 2k + 1, hence
an+k=an+k—1+bn+k=3n+k—1+2k+1 =3(n+k),
finishing the induction. It is clear that the claim implies the desired
result.
El
25. (Komal) Is it possible to find 2000 positive integers such that none of
them is divisible by any of the other'numbers but the square of each is
divisible by all the others?
8. 3.
The fundamental theorem of arithmetic
537
Proof. The answer is positive. Let k =22000, p1, ...,pk pairwise distinct
primes and let P = p1.. .17]; and .731: P—_ for 1 < i < k. Then :31," .,:I:k
are positive integers? _p is not anpinteger if 2 7E j, yet 1:12:11:s
_.-p
is a multiple of P2, which 1s a multiple of any 333-, with 1 < j < k. The
result follows.
III
26. A positive integer n is called powerful if p2 | n for any prime factor p
of n. Prove that there are infinitely many pairs of consecutive powerful
numbers.
Proof. The key observation is that if n and n + 1 are powerful, then so
are 4n(n+ 1) and 4n(n+1)+1 = (2n+1)2. This is clear by the definition
of powerful numbers. Since 8 and 9 are powerful, the result follows.
Cl
27. Let pn be the largest prime not exceeding 77. and let qn be the smallest
prime larger than n. Prove that for all n > 1 we have
1
Z—<§.
Proof. Let r1, r2,
be the increasing sequence of primes and write qn =
rm for some positive integer m. Since pk = ri and qk = n+1 for pg 3 k <
pi“, it follows that
n
1
pm—1
m-l Ti+1—1
m—l
;—<Z_I——=ZZ
35(1
i=1
7";
=Zfl
1)_1_;m 1
n+1
2
’I"
D
2
28. (Russia 2010) Are there infinitely many positive integers which cannot
be expressed as 3%, with x, y integers greater than 1?
538
Chapter 8. Solutions to practice problems
Proof. We will prove that p2 cannot be expressed as iii—i for any odd
prime p, thus the answer is positive. Assume that 5% = p2, that is
51:2—1 =p2(y2—1). Thenpl (ac—1)(:1:+1), hencep | 33—1 orp I x+1.
Moreover, we have gcd(:z: — 1,:1: + 1) = 2, thus necessarily p2 | :1: — 1 or
p2 | x+1. Assume that p2 | x—l, say x—l = kp2, then k(kp2+2) = y2—1,
or equivalently
(kp)2 + 2k + 1 = 11/2.
On the other hand
(kp)2 + 2k + 1 < (kp)2 + 2191) + 1 = (kp + 1)2,
hence kp < y < kp + 1, a contradiction. Similarly, if p2 | a: + 1, say
a: = lap2 — 1 then (lcp)2 —2k+1 =212 and
(kp)2 — 2k + 1 > (kp)2 — 2161) + 1 = (kp — 1)2,
hence kp — 1 < y < kp, a contradiction.
El
29. (Baltic Way 2004) Is there an infinite sequence of prime numbers p1,p2,
such that a+1 — 2pn| = 1 for each n 2 1?
Proof. Suppose that such a sequence exists and suppose that there is i
such that p, > 3. Suppose that p,- E 1 (mod 3), then 2p¢+1 is a multiple
of 3 and greater than 3, thus necessarily pi+1 = 2p,- — 1 E 1 (mod 3).
Repeating the argument yields pi“, = 2Pi+k—1 — 1 for k 2 1, then by
induction pm, = 2’“ ,- —2k+1. Thus 2’6 ,—2’i+1 is a prime for all k 2 1.
Since 1),- is odd, there is k > 0 such that p, | 2" — 1, then p,- l 2%,- — 2k + 1
and so p,- = 2'c i—2’°+1, that is (pi—1)(2k—1) = 0. This is absurd, so we
must have p, E —1 (mod 3). Then 2p,- — 1 is a multiple of 3 greater than
3, hence pi+1 = 21),; + 1 E —1 (mod 3). Repeating the above arguments,
we deduce that 12,-4.1, = 2%,- +2k — 1 for k 2 1. Choosing k; 2 1 such that
p,- | 2k — 1 (which is possible by corollary 4.15) yields a contradiction.
We deduce that p,- S 3 for all i, and this is obviously impossible. Thus
there is no such sequence.
El
8. 3.
The fundamental theorem of arithmetic
539
30. Let a1,a2, ...,ak be positive real numbers such that for all but finitely
many positive integers n we have
gcd(n, [a117,] + [a2nj +
+ Laknj) > 1.
Prove that a1, ..., ak are integers.
Proof. Let N be a positive integer such that for n > N we have
gcd(n, [a117,] + [agnj +
+ Laknj) > 1.
Let p1, p2, be the sequence of primes greater than N, then for all i 2 1
the quotient
x. = [0110i] + [62115] +
z
+ las‘l
Pi
is an integer. On the other hand, since [3:] S a: < Lac] + 1 for all x, we
have
[C
a1+...+ak—;<x¢Sa1+...+ak.
2
Since this happens for all i, it is not diflicult to deduce that (11 + + ak
is an integer and xi = a1 + + ak for all sufficiently large 2', say i > to.
But then
{011%} + + {as'} = 0
for i > to, where {as} is the fractional part of x. This forces ajpi E Z for
1 S j S k and 2' > to. Using Bézout’s theorem, this immediately implies
that al, ..., ak are all integers.
III
31. (IMO Shortlist 2006) We define a sequence a1, a2, a3,
an=%([%]+[;]+-~+ED
for every positive integer n.
a) Prove that an+1 > an for infinitely many n.
b) Prove that an+1 < an for infinitely many n.
by setting
540
Chapter 8. Solutions to practice problems
Proof. a) Assuming the opposite, it follows that the sequence (an), is
bounded (since if an+1 _<_ on for n 2 N, then an S max(a1, ...,aN) for
all n). However
1
an>—(E-1+E-l+...+E—1)=1+1+...+l—1
n
1
2
n
2
n
and the last expression is not bounded. This contradiction settles part
a).
b) Note that an+1 < an is equivalent to
n+1
n+1
n
,2 l—kJ< (1+ %) g; 1%J
or equivalently
1+Z(l"“J-l%J)<%:Z;l%J=anThe key observation is that |_%1J — [fij equals 0 if k does not divide n+1
and 1 otherwise. This is a simple exercise using the Euclidean division
that we leave to the reader. Therefore we can rewrite the previous
inequality as
1+
Z
1 < an.
kSn,k|n+1
This suggests taking n = p — 1 with p a prime, so that the left-hand side
is extremely simple: it reduces to 2. So it suflices to prove that ap_1 > 2
for infinitely many primes p, which is the case, since we have already
seen in part a) that an tends to 00.
El
32. (APMO 1994) Find all integers n of the form 0,2 + b2 with a, b relatively
prime positive integers, such that any prime p 3 fl divides ab.
Proof. If p S \/'r_t then p divides a, or b. Since gcd(a, b) = 1 we have
gcd(a,a2 + b2) = gcd(b,a2 + b2) = 1 and so p does not divide n, which
8. 3.
The fundamental theorem of arithmetic
541
implies that n is a prime number. Next, let p1, ..., pk be all primes less
than fl. Then pk+1 > J17. Assume that k 2 4, then Bonse’s inequality
yields
ab 2 p1...pk > pi” > n = a2 + b2,
a contradiction. Thus k S 3 and so V71 < 7, that is n < 49. If n 2 25,
then k = 3 and 30 = p1p2p3 divides ab, thus n = a2 + b2 2 2ab Z 60,
a contradiction. Hence n S 24 and n is a prime. If n > 9 then k = 2
and 6 | ab, which easily implies that one of a, b is 3 (otherwise 77. > 24)
and then a direct check yields n = 13. If n S 8 then we want n to be a
prime and 2 | ab, which gives n = 2 or 5.
El
33. (Iran TST 2009) Find all polynomials f with integer coefl‘lcients having
the following property: for all primes p and for all integers a, b, if p |
ab — 1, then pl f(a)f(b)— 1.
Proof. Let a be a positive integer and let p > a be a prime. Then a and
p are relatively prime, so there is an integer b such that p | ab — 1. By
hypothesis f(a)f(b) E 1 (mod p). Let f(X) = a0 + a1X +
for some integers ao,...,an with an 5A 0.
+ anX“
Then ab E 1 (mod p) and
a”f (a) f (b) E a“ (mod 13). But
a”f(b) E an(ab)" + an_1(ab)"-1a +
E an + an_1a +
Hence letting g(X) = an + an_1X +
+ aoan
+ aoa”
(mod p).
+ aoX" we obtain
f(60900 E a" (mod 1))Thus infinitely many primes divide f(a)g(a) — a" and so f(a)g(a) = a“
for any positive integer a. It follows that f (X)g(X) = Xn and so f (X) =
:|:Xd for some 0 S d S n. Conversely, any polynomial f (X) = :l:Xd with
d 2 0 is a solution of the problem.
El
34. Prove that there is a positive integer n such that the interval [77.2, (n+ 1)2]
contains at least 2016 primes.
542
Chapter 8. Solutions to practice problems
Proof. Let k = 2015 and assume that for all n there are at most It primes
between n2 and 1(n + 1)2. Pick any N > 1 and observe that
1
21 =z—+ z —+...+
p<N2 p
p<22 p
22gp<32 p
z
_.1
(N—1)n<N2 p
By assumption each of the sums
Z l
1'251r:<(j+1)2 p
has at most k: terms, each smaller than or equal to 3.12, thus the whole
sum is bounded from above by 3"; We deduce that
N
k
1
2— <2 3'2
— < k + k 2— < 2k.
p<N2p
-=1j=2j(j_1)
We know however (see theorem 4.74) that for N large enough we have
1
Z — > 2k.
p<N2 p
This contradiction shows that our original assumption was wrong and
the result follows.
El
35. (IMO 1977) Let n > 2 be an integer and let V", be the set of integers of
the form 1 + kn with k 2 1. A number m E Vn is called indecomposable
if it cannot be written as the product of two elements of V”. Prove that
there is r 6 Va that can be expressed as the product of indecomposable
elements of Vn in more than one way (expressions which differ only in
order of the elements of Vn will be considered the same).
Proof. We have already seen (see example 4.56) that there are infinitely
many primes p not congruent to 1 modulo n. Their remainders modulo
n lie in a finite set, thus we can find two such primes p, q > n which are
congruent modulo n. Let d be the smallest positive integer such that
8.3.
The fundamental theorem of arithmetic
543
pd E 1 (mod n) (it exists, thanks to corollary 4.15). Then pd,q"l,1oqd‘1
and pal—lg are all indecomposable elements of V”. Indeed, it is clear that
they are in Vn (i.e. that they are congruent to 1 modulo n), and that
their proper divisors are not in V", (by minimality of d and the fact that
p E q (mod n)). In order to finish the proof, it suffices to observe that
pd «1“ = (pad—1) - (q-l).
D
36. (German TST 2009) The sequence (an)neN is defined by a1 = 1 and
an+1 =afi—a§,+2a,2,+l
for all n 2 1. Prove that there are infinitely many primes which do not
divide any of the numbers a1, a2,
Proof. The key ingredient in this problem is the study of the sequence
bn = a3, + 1. Note that
“n+1 =(a721.+ 1)2 — a: = bi " an(bn — 1)-
It follows that an“ 5 an (mod bn) and so a§+1 + 1 E a31+ 1 E 0
(mod bn). In other words, bn divides bn+1 for all n. We can actually
refine this observation: we have
a3,“ + 1 E a,2,(bn — 1)2 + 1 E ai(1 — 2b”) + 1 E bn(1 — 2a?)
(mod bi).
Note that gcd(1 — 2a,23,bn) = 1, since any prime dividing 1 — 20% and
bn = ai+1 would also divide 1—2a%+2(a%+1) = 3, but 3 does not divide
ai + 1. We conclude that bn+1 = ncn with gcd(bn, on) = 1. Note that
clearly an+1 > an for all n, thus on > 1 for all n. Let pk be an arbitrary
prime factor of ck, then pk does not divide bk (as gcd(bk, ck) = 1) and so
it does not divide b1b2...bk (since b1 | b2 |
| bk). In particular pk does
not divide c102...ck_1 and so the sequence p1,p2,
consists of pairwise
distinct primes. We Will prove that any of these primes is a solution of
the problem.
Chapter 8. Solutions to practice problems
544
Assume that p | bn for some n 2 1, and that p | ak for some k: 2 1.
Note that for all n 2 1 we have an“ E 1 = (11 (mod an) and then
an+2 E a‘f — a? + 2a? + 1 E (12 (mod on). An immediate inductive
argument shows that an+j E a,- (mod an) for all n, j 2 1. In particular,
(1],, | (1,], for allj 2 1. Choose j such that jk 2 n, then p | en, | ajk and
so p does not divide bjk = 0,3,6 + 1. This is however impossible, since
p l bn I bjk.
El
37. Prove that for all n 2 1 we have
Zoom-2%)» z”—E,”= 2d (d)
dIn
dln
d|n
dln
Proof. Let us prove the first equality. Since both sides define multiplicative functions of n, it suffices to prove that they agree on prime powers,
thus we may assume that n = pk for a. prime p and some k 2 0._ Then
k
2 a(d) = 2 0(1)") = 1+(1+p)+...+(1+p+...+p’°) = (k+1)+kp+...+pk
i=0
dln
and
k
n- Izm=pk 20(z'+1)p"‘ zzopk"i(z'+1)=(k+1)+kp+...+pk,
dn
1:
1;:
thus the two sides agree.
For the second equality we proceed similarly, reducing to the case n = pk
and then computing
71.2%: pkxawi)=pk +(pk+pk_1)+.. +(pk+pk—1+-
dln
i=0 1”
k
= (k+ llpk + kpk—l + _ . _ + 1 = Za+ 1)p‘ = 271d
).
+1)
8.3.
The fundamental theorem of arithmetic
545
Here is also an alternative solution, suggested by Richard Stong and
using the convolution product of arithmetic functions. Let 1 denote the
constant function with value 1 and id the identity function. We already
saw that 1 * 1 = 7' and 1 * id = a. We easily compute that
(id * id) (17.): Z d
dIn
—.nr(n)
—
Now the first equality just reads
1*a=1*(1*id) = (1*1)*id=7'*id,
and the second reads
0*id=(1*id)*id=1*(id*id).
El
38. a) Let f be a multiplicative function with f (1) = 1 (this is equivalent to
f being nonzero). Prove that for all n > 1 we have
2 f(d)u(d) = 11(1 — f(p)),
dln
pl'n
the product being taken over the prime divisors of n.
b) Deduce closed formulae for
Emma), Zu(d)0(d) and Zu(d)<p(d) for n > 1.
dln
dln
dln
Proof. 3.) Let p1, p2, ..., pk be the distinct prime divisors of n. The only
divisors d of n for which f(d)a(d) aé 0 are products of distinct elements
of the set {p1, ...,pk} (including the empty product, which equals 1 by
convention). Hence
Zf(d)M(d)=1-Zf(pi)+ Z f(Pi)+- --+( 1)k 1f(101 mph)
dln
1<i<j<k
546
Chapter 8. Solutions to practice problems
Since f is multiplicative, the right-hand side can further be written as
k
1 - Z f(Pi) + Z f(Pi)f(Pj) + + (—1)k_1f(Pl)---f(Pk)
i=1
lgi<j$k
= (1 — f(P1))---(1 - f(Pk))The result follows.
b) By using a), we obtain
ZMd) = H(1 - T(P)) = (-1)”("),
dln
pln
where w(n) is the number of prime factors of n. Similarly, we obtain
ZM(d)0(d) = H(1 - (1 +p)) = (-1)”(”’) III)
dln
pln
PI”
and
214090“) = H(1 - (p - 1)) = H(2 - p)dln
pln
U
PI“
39. Let f be an arithmetic function such that the function 9 defined by
9(n) = 2 f(d)
dln
is multiplicative. Prove that f is multiplicative.
Proof. By the Mobius inversion formula
f(n) = Dang (g) ,
dln
hence f is the convolution product of the multiplicative functions p, and
9. Theorem 4.99 implies that f is multiplicative.
El
8. 3.
The fundamental theorem of arithmetic
547
40. a) Let f be an arithmetic function and let 9 be the arithmetic function
defined by
9(n) = 2 f(d)dln
For all n 2 1 we have
'n
n
k=1
k=1
n
290:) = : f(k) [E] .
b) Prove that the following relations hold for all n 2 1
Enj¢(k)=:nj[%], 20(16): 2km.
k=1
k=1
k=1
Proof. a) Taking into account that there are [fi] multiples of k in the
set {1,2, ...,n}, we can write
;9(k)=2n22f(d)=2f(d)
Z) 1=zf<k>[g]
k=1 d|n
dSn
dlk,k<n
b) The first formula follows from the proposition by taking f the constant
map 1 (so that g(n) = r(n)). For the second formula, take f (n) = n in
the proposition (so g(n) = a(n)).
III
41. Let f(n) be the difference between the number of positive divisors of n
of the form 3k + 1 and the number of positive divisors of the form 3k — 1.
Prove that f is multiplicative.
Proof. Let m, n be relatively prime positive integers. Then each positive
divisor d of mu can be uniquely written as the product d = ef of a
positive divisor e of m and a positive divisor f of n. We have d E 1
(mod 3) if and only if e E f E 1 (mod 3) or e E f E 2 (mod 3). Thus,
if g(n) (respectively h(n)) is the number of positive divisors of the form
3k + 1 (respectively 3k: — 1) of n, then
90%) = 907090») + h(m)h(n)-
548
Chapter 8. Solutions to practice problems
Similarly, we obtain
h(77m) = 9(m)h(n) + 90071071)We deduce that
f(mn) = 9(mn) - Mm”) = 9(m)(g(n) - h(n)) - h(77%)(901) - h(n))
= f(n)f(m),
proving that f is multiplicative.
El
Remark 8.12. a) Once we know that f is multiplicative, it is not diflicult
to check that f(n) 2 0 for all n. Indeed, if p E 1 (mod 3) then clearly
f(p") = 1 + 77., while ifp E 2 (mod 3), then f(p”) equals 1 if n is even
and 0 otherwise.
b) One can prove that the equation 1:2 — my + y2 = n has exactly 6f (77.)
solutions in integers.
c) Similarly, one can prove that for any k: E {4, 6,8, 12, 24} any positive
integer n has at least as many positive divisors of the form mk + 1 as
positive divisors of the form mk —— 1. Moreover, this property does not
hold for any other k.
42. (AMM 2001) Find all totally multiplicative functions f : N ——> C such
that the function
n
F01) = E f(k)
k=1
is also totally multiplicative.
Proof. There are three such functions: the functions that are identically
0, respectively 1, and the function f such that f(1) = 1 and f (n) = 0
for n 2 2. For k > 1, we have f(2k) = f(2)f(k) and
f(2k — 1) = F(2k) — F(2k — 2) — f(2k)
= F(2)(F(k) - F(k - 1)) - f(2k)
= (1 + f(2))f(k) - f(2)f(k) = f(k)~
8. 3.
The fundamental theorem of arithmetic
549
Therefore, each value f(n) is a power of f(2) Furthermore,
f(2) = f(3) = f(5) = f(9) = f(3)2 = f(2)2Thus f(2) 6 {0,1}, and the result follows.
El
43. Find all nonzero totally multiplicative functions f : N ——) R such that
f(n+ 1) 2 f(n) for all n.
Proof. Clearly for any nonnegative real number k the function f (n) = nk
is a solution of the problem. We will prove that these are all solutions.
Note that f (1) = 1 and so f (n) 2 1 for all n. Consider g(n) = log f (n),
so that g(n + 1) 2 g(n) for all n, g(mn) = g(m) + g(n) and g(n) 2 0 for
all n. Fix different primes p,q and consider arbitrary positive integers
a,b- If p“ S (1", then 9(1)“) S g(q"), which becomes ag(P) S bg(q),
or equivalently a S b%%%. Thus whenever a: =
4% is a positive rational
number such that cc S {£11, we also have :1: S
.Since the number n
can be approximated at any order by rational numbers, we conclude that
l_og q < g_(q)
l—ogp
9—(17)
Arguing similarly (using a, b such that p“ 2 qb) yields the opposite inequality
l_ogq >_
g(q)
l—ogp
g(p)’
SO
logq _ g(q)
logp
——.
g(p)
We deduce that fig}, is independent of the choice of the prime p, say equal
to some k 2 0 for all p. Then g(p) = pk for all p and since g is totally
multiplicative we conclude that g(n) = nk for all n, as desired.
El
44. (Erdos) Let f : N —> R be a nonzero multiplicative function such that
f (n + 1) 2 f (n) for all n. Then there is a nonnegative real number k
such that f (n) = nk for all n.
550
Chapter 8. Solutions to practice problems
Proof. Since f is multiplicative and nonzero, we have f (1) = 1, and
using the hypothesis of the problem we obtain f(n) 2 1 for all n 2 1.
We will prove that f is totally multiplicative, which will be enough to
conclude thanks to the previous example. For this, we will prove that
for any prime p and any I: 2 1 we have
f(Pk+1) = f(P)f(P'“)Fix such p and k 2 1. For any integer n 2 1 not divisible by p we have
f(n +p)f(P")f(P) = 1’0"»10’c +pk+1)f(P) 2 f(P'°n + 1)f(P)
= f(;o’“+1n + p) 2 f(p’“+1n)
= f(p"+1)f(n)Similarly,
f(Pk+1)f(n + p) = f(10k+1n + pk”) 2 f(Pk+1n + P)
= f(10)f(P'°n + 1) 2 f(P)f(p’°n)
= f(P)f(Pk)f(n),
We deduce that setting
a
=f_<20"f>_ b=l=f(p)f(p")
f(p)f(p’°)’
a
f(p"+1)’
we have
f(n+p) Z af(n), f(n +10) 2 WW
for all n relatively prime to p. Iterating the first inequality yields
f(n+J'10) 2 ajf(n)
for all j 2 1 and all n relatively prime to p. Taking j = [g] we have
f (n + J'p) S f(2n) and so
“2") Z aiglfln).
8.3.
The fundamental theorem of arithmetic
551
Choosing 71. odd, the previous inequality becomes (1n S f (2) Choosing
77. very large (relatively prime to 2p), we deduce that a g 1. Similarly,
we obtain b S 1, which yields a = b = 1 and so
f(P"+1)= f(10)f(p")Since 10 was an arbitrary prime and k an arbitrary positive integer, we
III
deduce that f is totally multiplicative, as desired.
45. Are there infinitely many n > 1 such that n l 2“") — 1?
Proof. Let F,- be the ith Fermat number and choose arbitrary prime
factors qo,q1,
of F0,F1, ..., so for instance qo = 3, q1 = 5, etc. Define
nd = qoq1...qd for all d 2 1. We claim that not | 200”) — 1. Since 0(nd)
is a multiple of 2““, it suffices to prove that qoql...qd | 22d — 1. Since the
Fermat numbers are pairwise relatively prime, so are qo, ..., d, thus it
suflices to provedthat each of the numbers qo, ..., qd divides 22 — 1. This
is clear, since 22 — 1 is a multiple of F-_1 for 2' g d.
El
46. An integer n > 1 is called perfect if 0(n) = 2n. Prove that an even
number n > 1 is perfect if and only if n = 2P‘1(2P — 1), with 21’ — 1
prime.
Proof. Suppose first that n = 2P‘1(2P — 1), with 21’ — 1 prime. Since a
is multiplicative, we have
21’ — 1
0(n) = 0(217—1). 0(2p — 1) = fl ' 21) = 2n,
hence n is perfect. The converse is more difficult. Suppose that n = 2km
is perfect, with k 2 1 and m odd. Again, by multiplicativity of a we
have
2k+1m = 2n = 0(2k)a(m) = (2M1 — 1)o(m).
Since gcd(2’°+1,2"+1 — 1) = 1, there is an integer a such that m =
a(2k+1 — 1) and 0(m) = 2k+1a. If a > 1, then 1,a and m are divisors of
552
Chapter 8. Solutions to practice problems
m, hence 0(m) 2 1 + a + m = 1 + 2k+1a, a contradiction. Hence a = 1,
m = 2’”1 — 1 and o(m) = 2"“ = m + 1. The last equality implies that
m is a prime, which finishes the proof, since 72. = 2km = 2k(2k+1 — 1). III
47. Let n be an even positive integer. Prove that o(o(n)) = 2n if and only
if there is a prime p such that 21’ — 1 is a prime and n = 2P_1.
Proof. Suppose that n = 2"—1 with 21’ — 1 prime. Then o(n) = 21’ — 1 and
o(o(n)) = 1 + 2P — 1 = 21’ = 2n. Conversely, suppose that o(o(n)) = 2n
and write n = 2km, with k 2 1 and m odd. Suppose by contradiction
that m > 1 and note that the condition o(a(n)) = 272 can be written
(7((2k'l'1 — 1)o(m)) = 2k+1m.
Since 1, 0(m) and (2’6+1 —1)o(m) are different divisors of (2k+1 — 1)o(m),
we deduce that
2k+1m 2 1 + 0(m) + (2k+1 — 1)o(m) > 2k+lo(m) > 2k+1m,
a contradiction. Hence m = 1 and n = 2"“, with o(2’°"'1 — 1) = 2k“.
This clearly implies that 2"“ — 1 is a prime, hence k + 1 = p is a prime.
The result follows.
III
48. (Romania TST 2010) Prove that for each positive integer a we have
o(an) < o(an + 1) for infinitely many positive integers n.
Proof. The idea is to choose 11. prime (so that an has few divisors) such
that an + 1 has many prime divisors. Suppose that p1, ..., pk are pairwise
distinct primes that do not divide a and that n > a is a prime such that
on + 1 E 0 (mod p1...pk). Then
I:
1
k
1
o(an+1)2(an+1)-H(l+—)>an-H(1+—>.
i=1
p,i=1
pi
On the other hand
0(an) = o(a.)o(n) = o(a)(1 + n) < 20(a)n.
8. 3.
The fundamental theorem of arithmetic
553
It is thus enough to ensure that
fi<1+i)>%‘2
p“
i=1
in order to have 0(an) < 0(an + 1). It is now clear how to proceed: let
p1, p2,
be the increasing sequence of primes that do not divide a. Since
only finitely many primes divide a, by theorem 4.74 there is k such that
fi(l+
+pi>)
i=1
Z_>>_2_"_(‘Q
i=1p"
Fixing such a k, Dirichlet’s theorem yields the existence of infinitely
many primes n such that an+ 1 E 0 (mod plpg...pk). The result follows.
III
49. (IMO Shortlist 2004) Prove that for infinitely many positive integers a
the equation r(an) = n has no solutions in positive integers.
Proof. We will prove that if a = pp‘l, with p > 3, then the equation
has no solutions. Assume that n is a solution and let m = an, so that
ar(m) = m. Since a divides m, we can write m = prs with r 2 p — 1
and s relatively prime to p. Then the equation becomes
(r + 1)T(s)= par-p“
This forces r 2 p (otherwise 1' = p — 1 and the right-hand side is not a
multiple of p, while the left-hand side is divisible by p). Let k = r —p+ 1,
so that k: 2 1 and
(k + 107(5) =
Since 7(3) 3 s, we deduce that k + p 2 pk. Assume that k 2 2, then
pk—p=p(p’“‘1—1)23(3k—1—1)23-2(k—1) >19,
a contradiction. Thus k = 1 and (p + 1)7'(s) = p3. Write now the prime
factorization of s,
a.
a
s =p11...pdd.
554
Chapter 8. Solutions to practice problems
Then for all i we have
p
_T(s)_l—Iaj+1
p+1
j
s
ai+1
a-S pi
pj
ai+1
201'
_
On the other hand
20" 21+ai+((;i).
Combining these inequalities yields
aP<21> S a¢+1
for all 1'. Since p Z 4, this immediately implies a; = 1 for all i. But then
the equation (p + 1)7'(s) = 118 becomes
(13+ 1)2d = p-pl...pd.
We deduce that p | 24(1) + 1), which is obviously impossible. Therefore
for such a the equation has no solution and the result follows.
El
50. (IMO) Let T(n) be the number of divisors of a positive integer n. Find
all positive integers k such that k =
707?)
T0»)
for some n.
Proof. Answer: all odd positive integers k. Let k =
T(n2)
TU»)
for some n. If
17. = 1 then k = 1. If n > 1 and n = p? .. . p? is the prime decomposition
of n then T(n2) = (2T1 + 1) . . . (21's + 1) is an odd number and hence k:
is odd. Conversely, let k = 2m + 1 is an odd number. We shall prove by
induction on m that there are n, . . . ,rs and hence n such that
k: (2r1+1)...(21‘3+1) __ 7(n2)
(r1+1)...('r5+1) _ 7(n)
Ifm=1then
_ (2-2+1)(2-4+1)
3—
(2+1)(4+1)
8.3.
The fundamental theorem of arithmetic
555
Suppose that for all m < M we can write 2m + 1 as a fraction of the
desired form and let 1:: = 2M + 1. If k + 1 = 21 - t, where t is odd then
_k+1<k+1<
2
19.
t—T_
Consider the numbers
7'1 = 21— 20t — 20,1‘2 = 271,. . . ,7“; = 21—17'1.
Then for m = p? . . . p2" we have
_T(n¥)_(2r1+1)...(2n+1)_2r1+1
_2lt—1
_
._
k _
__
7(n1)
1
(r1+1)...(rl+1)
n+1
t
2
Since t < k we now that there is 722 = q1°‘1 . . . qs‘?" such that t = gag.
Then choosing the primes p1, . . . , pl different from q1, . . . , qs we set n 2
mm and get
2
2
2
T(n ) = T(nl) . T012) = klt = 2lt _ 1 = k.
7(7")
7'(711)
T012)
Hence the induction is finished and the statement is proved.
III
51. A positive integer a is called highly divisible if it has more divisors than
any number less than a. If p is a prime number and a > 1 is an integer,
we write vp(a) for the exponent of p in the prime factorization of a.
Prove that
a) There are infinitely many highly divisible numbers.
b) If a is highly divisible and p < q are primes, then vp(a) 2 vp(a).
0) Let p, q be primes such that pk < q for some positive integer k. Prove
that if a is highly divisible and a multiple of q, then a is a multiple of
pk .
d) Let, p,q be primes and let k be a positive integer such that pk > q.
Prove that if p2,“ divides some highly divisible number a, then q divides
0,.
e) (China TST 2012) Let n be a positive integer. Prove that all sufl‘i—
ciently large highly divisible numbers are multiples of n.
556
Chapter 8. Solutions to practice problems
Proof. We will constantly use the formula
TUB) = H(1 + 01268))
plat
for the number of divisors 7(117) of x.
a) Suppose that there is a largest highly divisible number (L. Then for
b > a we have 'r(b) S maxj<br(j), hence the sequence (T(b))b>a, is
bounded. This is clearly absurd.
b) If vp(a) < vq(a), then b = mwfiflqvfia) is less than a and
7'(b) = 7(a), contradicting the fact that a is highly divisible.
0) Let b = Elk. Note that b < a, hence 7'(b) < 7(a), since a is highly
divisible. We deduce that
vq(a)(vp(a) + k + 1) < (1 + vp(a))(1 + vq(a)),
which simplifies to kvq(a) < 1 + 'vp(a). Since vq(a) 2 1 by assumption,
it follows that up (a) 2 k, thus pk divides a and we are done.
d) Suppose that q does not divide a and let b = 1%,? Again, b < a hence
7'(b) < T(a), which translates into
(1 + 'up(a) — k)(2 + vq(a)) < 1 + vp(a).
Since vq(a) = 0, this reduces to 1 + vp(a) < 2k, contradicting the fact
that p2,“ divides a.
e) Let p1, p2, be the increasing sequence of primes. It suffices to prove
that for all n and k, all sufficiently large highly divisible numbers are
multiples of (p1...pn)k. By part b), it suflfices to ensure that such numbers
are multiples of p5,. Suppose that this is not the case, hence infinitely
many highly divisible numbers a,- are not multiples of pfi. Let q be a
prime greater than p2. By part c), a,- are not multiples of q, hence their
prime factors are all less than q by part a). Let q1, ..., qs be all primes less
than q and let m be such that q’l'" > q. If a, is sufficiently large, then at
least one of the numbers vq1(a,), ..., ’q (ai) is greater than 2m. By part
(1) it follows that q divides (1,, a contradiction. The result follows.
III
8. 3.
The fundamental theorem of arithmetic
557
52. Let n > 1 be an integer. Compute
Z(-1)%90(d)dln
Proof. If n is odd, then so is E for all d | n, hence
Zelfimd) = — EN) = —n
dln
dln
by Gauss’ theorem 4.112. Suppose that n is even and write 77. = 2km
with k 2 1 and m odd. Then % is odd if and only if v2(d) = k, that is
d = 2ke with e | m. Hence
Z(-1)%w(d) = Z Md) — Z <P(2’°e) = Z <Mal) - 2 Z 2H<p(e)dln
dln
elm
dln
elm
v2(d)<k
Using Gauss’ theorem 4.112 twice, we obtain
Z(—l)%<p(d) = n — 2km = 0.
El
dln
53. (IMO 1991) Let 1 = a1 < a2 <
< awn) be the totatives of n > 1.
Prove that a1, a2, ..., awn) form an arithmetic progression if and only if
n is either 6, a prime number or a power of 2.
Proof. It is clear that if n = 6, a prime or a power of 2, then a1, ..., awn)
form an arithmetic progression, so let us prove the converse. The case
n g 6 being easy, we assume that n 2 7. Then <p(n) Z 3. If a2 = 2, then
a1, a2, ..., awn) must be consecutive numbers and so, since awn) = n — 1,
we must have <p(n) = n — 1. Thus 71 is relatively prime to 1, 2, ..., n — 1,
and so n is a prime. If a2 = 3, then we must have aj = 23' — 1 for all j,
so n — 1 = 2<p(n) —— 1 and n = 2<p(n). Write n = 2km with k 2 1 and
m odd, then the equation becomes m = <p(m), with the unique solution
m = 1, so n is a power of 2.
558
Chapter 8. Solutions to practice problems
Assume now that (12 > 3. Thus n is a multiple of 3. Moreover,
n — 1 = “$01) = 1 + (<p(n) — 1)(a2 — 1).
Note that 3 does not divide a2, and the last relation shows that 3 does
not divide a2 — 1, thus (12 E 2 (mod 3). But then (13 = 2oz — 1 E 0
(mod 3), contradicting the fact that gcd(a3, n) = 1. Thus this case does
not lead to any solution, and the result follows.
I]
54. Let n 2 2. Prove that n is a prime if and only if <p(n) | n — 1 and
n + 1 I 0(n) (recall that 0(n) is the sum of the positive divisors of n).
Proof. One direction being obvious, suppose that <p(n) | n — 1 and
n + 1 | C(71) and let p1, ...,pk be the (pairwise distinct) prime factors of
n. If there is 2' such that pf | n, then p,- l <p(n) I n — 1, a contradiction.
Hence n = plpz...pk. Suppose that k > 1. Note that n is odd, since
<p(n) is even (the case n = 2 is excluded by the hypothesis k > 1) and
<p(n) | n — 1. Thus all pi are odd, hence 2" | <p(n) = (p1 — 1)...(pk — 1).
In particular 4 | <p(n) | n — 1 and so 4 does not divide n + 1. Also,
2’“ | 0(n) = (111 + 1)...(p;c + 1). Combining the last two observations,
we deduce that 2’“1 divides :43, hence :43 2 2""1. This is however
absurd, since
;(—fl<$=(1+%)wu(i+i)s(§)k<2k—1.
I]
Remark 8.13. A famous conjecture of Lehmer asserts that an integer
n > 1 is a prime if and only if <p(n) divides n — 1 (of course, only one
implication is difficult). This is still open, even though one knows that
the possible counterexamples are huge.
55. Let k be a positive integer. Prove that there is a positive integer n such
that 90(n) = <p(n + k).
Proof. Let p be the smallest prime not dividing k and choose n = (p—1)k.
Then 90(n + k) = <p(pk) = (p — 1)<p(lc). On the other hand,
r(n)=<P((p-1)k)=(P-1)k H (1—1)
ql(p—1)k
‘1
8. 3.
The fundamental theorem of arithmetic
559
and since all prime factors q of p— 1 are prime divisors of k (by minimality
of p) we deduce that
«)(n) = (12— men (1 — 5) = (10— 1W) = <P(n+ k),
qlk
solving the problem.
El
56. Prove that for all n 2 1 we have
<p(1)
21_1
90(2)
<P(n)
————22_1+...+—2n_1<2.
Proof. The key observation is that
WE) _<p_(k)
2k_ 1
1
2
—k
M
2jk'
900$) 2—
_
Hence
22—339“) =2:“"—‘—i’=z;
2 was).
d>1 jk=d,k5n
k=1 j>1
Now for all d 2 1 we clearly have (using Gauss’ theorem 4.112)
Z W?) S Ewe) = d
jk=d,kgn
kld
thus
k
:11: 2‘P(_)1 S
16:1
2‘:
d>1
Since
n+2
1
n+1
x+2x2+Iu+nxn = W,
(x - 1)2
we deduce by choosing a; = 1/2 and letting n —> 00 that
d
E;
= 2,
(1:1
00
and the result follows.
E!
560
Chapter 8. Solutions to practice problems
Remark 8.14. The argument shows that
W»)
2 2n _ 1: 2’
n>1
and, more generally, that for all a: 6 (—1,1) we have
2900+) _xn fig?
'n.>1
57. a) Prove that there are infinitely many integers n > 1 such that
WI) 2 $06) + <p(n - 16)
foralllSkSn—l.
b) Are there infinitely many n > 1 such that <p(n) S 9006) + <p(n — k) for
all 1 S k S n — 1?
Proof. a) We claim that any odd prime p has this property. Indeed, we
have
<P(k)+<P(P—k)Sk—1+P—k—1=P—2<<P(P)=
b) The answer is positive. Let p1,p2,
be the increasing sequence of
primes and define nd = p1p2...pd. We will prove that this is a solution
of the problem for d _>_ 2. Choose any k E {1,2,...,nd — 1} and let
q1 < q2 <
and since
< q; be the prime factors of k. Note that q1 2 p1, Q2 2 p2,
Flu-Pd = not > k 2 ‘11-"n p1p2...p¢
we must have l < d. We deduce that
——fi<1-—>21:< .:=>—
i=1
8. 3.
The fundamental theorem of arithmetic
561
Since a similar inequality holds with nd — k instead of k, we conclude
that
w(k)+<p(nd—k) Zk-M+(nd—k)-M=so(nd),
nd
nd
proving that nd is a solution of the problem.
[I
58. (AMM 11544) Prove that for any integer m > 1 we have
m + k
:‘pa k + 1 )l2k—+1J=m
2
.
Proof. Denote by mm the left-hand side of the equality. Then
m—l
+k+1
m+k
mm+1—xm—so(2m+1)+’;)¢(2k+1) ([ m2k+
1 J_ i2k+1J)'
Recall that in general [n—t—IJ — [fl = 1 if and only if k | n + 1, thus
xm+1 — mm = <p(2m + 1) +
Z
<p(2k + 1).
OSkSm—l
2k+1|m+k+1
The condition 2k: + 1 | m + k + 1 is equivalent to 216 + 1 | 2(m + k + 1)
and also with 2k + 1 | 2m + 1. Since all positive divisors of 216 + 1 are
odd, we obtain
<p(2m+1)+
Z
<p(2k+1)= Z <p(d)=2m+1,
OSkSm—l
2k+1|m+k+1
d|2m+1
the last equality by Gauss’ theorem 4.112. Thus
xm+1 —:z:m = 2m+1
and the result follows by induction.
El
560
Chapter 8. Solutions to practice problems
Remark 8.14. The argument shows that
and, more generally, that for all a: 6 (—1,1) we have
2 ‘P(n)—
—a;" Lfi
n>1
57. a) Prove that there are infinitely many integers n > 1 such that
WI) 2 We) + <p(n - k)
foralllSkSn—l.
b) Are there infinitely many n > 1 such that <p(n) S <p(k) + <p(n — k) for
all 1 S k S n — 1?
Proof. a) We claim that any odd prime p has this property. Indeed, we
have
90(k)+¢(p-k)Sk—1+p—k—1=p-2<¢(P)=
b) The answer is positive. Let p1,p2,
be the increasing sequence of
primes and define nd = p1p2...pd. We will prove that this is a solution
of the problem for d 2 2. Choose any k E {1,2,...,nd — 1} and let
q1 < q2 <
and since
< q; be the prime factors of k. Note that q1 2 p1, q2 2 p2,
Flu-Pd = no! > k 2 glu-QI 2 P1P2n-Pl
we must have I < d. We deduce that
——fi<1——>>n<— gs)—
i=1
q
8. 3.
The fundamental theorem of arithmetic
561
Since a similar inequality holds with nd — 1:: instead of k, we conclude
that
n
n
mowed—k) ale-Mund—m-Mwm),
nd
nd
proving that my is a solution of the problem.
III
58. (AMM 11544) Prove that for any integer m > 1 we have
m+k
2
:¢(2k+1) [Ely—+1]: m.
Proof. Denote by com the left-hand side of the equality. Then
m—l
m+k+l
m+k
Recall that in general |_%1J — [fij = 1 if and only if k | n + 1, thus
xm+1 — (em = <p(2m + 1) +
2
<p(2k + 1).
OSkSm—l
2k+1|m+k+1
The condition 2k + 1 | m + k + 1 is equivalent to 2k + 1 | 2(m + k + 1)
and also with 2k + 1 | 2m + 1. Since all positive divisors of 216 + 1 are
odd, we obtain
<p(2m + 1) +
Z
<p(2k + 1) =
OSkSm—l
2k+1|m+k+1
Z (p(d) = 2m + 1,
d|2m+1
the last equality by Gauss’ theorem 4.112. Thus
xm+1 —a:m = 2m+1
and the result follows by induction.
El
562
Chapter 8. Solutions to practice problems
59. a) Prove that for all n > 1 we have
n
n
n
2
22900:)
= HEM)
[E] .
Ic=1
k=1
b) Prove that for all n > 1 we have
’(p(1)+ ¢(2) + + <p(n) — $112
< 2n+ nlogn.
Proof. a) The identity
dlk
gives
Z¢(k)—ZkZM—(d)=21#7(d)zk
k=1d|k
k<n
d
n L)
d m
=2;
d “2&0 d)= 01:21:14)
2
Thus it remains to prove that
n
n
2
Md)
bl
=
d=1
for n > 1. But with a similar argument we obtain
gm) l3J= 2W1) Z 1—
— ZZMCO—— 1
k<n
d
k=l dlk
since zdlk ,u(d) equals 0 for k > 1 and 1 for k = 1.
8. 3.
The fundamental theorem of arithmetic
563
b) We will use the inequality
which can be proved arguing as in the proof of theorem 4.130. Using
the inequality 3:2 — [xJ2 3 20: for x 2 0, part a) and the result taken for
granted, we obtain
[so(1)+<P(2)+ woo—327»: :|11+Z ”Ml—J2_%n2
n+1
n 1
n2
n 2
"
using the inequality
n
2
3"?"
<T+,§1§(F—ll€_lsn— +;% <2n+nlogn,
_1+logn.
El
k=1
60. Let a1, ..., awn) be the totatives of n > 1.
a)Prove that for all m 2 1 we have
m
a? + a5" +
+ a3“) = 2M(d)dm (1m + 2’" +
+ (g) ).
dln
b) Compute a1 + a2 +
+ a290(n)
Proof. a) Note that
k= Z
Z km=d
Z 2"”dIn 1<k<n
dln
193%
gcd(k,n)=d
gcdu,g)=1
In other words, if
13kg;
gcd(k,n)=1
564
Chapter 8. Solutions to practice problems
then
5111—“)
n—mzlw =S(Z%)(§1) ='d
dln
d|n
The desired identity then follows from Mobius’ inversion formula.
b) Taking m = 2 in part a) yields
a? + a3 +
+ aim) = 2,14s (12 +
2
+ 1%)
d|n
mums“)
=ZM(d)d2'+
dln
=—zfl+”—; Doing Edna)
6dln
2dln
dl"
Using the identities (the second one uses the hypothesis n > 1)
n
dln
and
dlnp,
Zd) = H(1 —p>,
dln
pl'n,
we conclude that
n
(11 + 0/2 +.. -+ a‘P(")=
'n
29:} ) +—
6—H(1
p).
D
6pln
Remark 8.15. The identity obtained in part a) can be used to prove the
.
a
.
.
.
.
equ1d1str1but10n of the numbers 9,11, £712, ..., % as n —} oo. Thls means
that for each interval I C [0,1] we have
n_)oo
<p(n)
= length(I)
8.3.
The fundamental theorem of arithmetic
565
or equivalently
(n)
1‘”:
<p(n)
"1900—
11:1 f (a;) = /01 “mm
for all continuous functions f : [0, 1] —> R. Finally, this reduces (thanks
to the Weierstrass approximation theorem) to proving that
(n)
m
=fi
mw—(ln)q
n->°°
12:1 :(%)
for all m 2 0, which is a not too difficult (but technical enough) consequence of part a) of the previous exercise.
61. (Serbia 2011) Prove that if n > 1 is odd and <p(n), <p(n + 1) are powers
of2, then n+1 is apower of2 orn= 5.
Proof. Observe first that if a is an odd integer such that <p(a) is a
power of 2, then a is squarefree and all of its prime factors are Fermat
numbers. Indeed, if a = p’fl...p,’f' is the prime factorization of a, then
p’f1_1...pf"1(p1 — 1)...(pr — 1) being a power of 2 forces k1 =
= hr = 1
and all pi —- 1 being powers of 2, Le. pi are Fermat primes.
we can write a = p1...pr and assuming that p1 <
Thus
< pr, we obtain
pi+1 — 1 2 (pi — 1)2 (since pi = 22°“. + 1 for some a1 <
< ar). We
deduce that
m
< _a_ = ’
p1 —1 ‘ <p(a)
Pi
i=1Pi—1
_(1+p—1—1_1) (1+W).(1+fl)....=1?fi,
the last equality being a consequence of the general formula (valid for
<17 6 (0,1))
(1 + w)(1 + 9:2)(1 + x4)... = 1::3’
566
Chapter 8. Solutions to practice problems
which follows directly from the difference of squares formula. We con—
clude that if a is an odd integer for which <p(a) is a power of 2, then
111—1
P1
WI) 171— 1 S a S <P(a) - 171-2,
where p1 is the smallest prime factor of a.
Coming back to our problem, write <p(n) = 2A and <p(n + 1) = 23, then
applying the previous discussion to n and to the largest odd divisor of
n + 1, we obtain
2B+1 < 23+1—q1
(11 —
< n + 1 < 2B+1—q1 _ 1,
_
(11 — 2
where p1 is the smallest prime factor of n and q1 is the smallest odd
prime factor of n + 1 (assuming that n + 1 is not a power of 2). Since
p1, q1 2 3, we have 1% S 2 and similarly for q1. We deduce that
2A < n < 23+2,
2B+1 S n < 2A+1,
which yields A = B + 1. Combining this with the previous inequalities
yields
41-1
(11-2
—— >
P1
101—1
and
n+1 > ——
(11 - 131-2 .
q1-1 101—1
n
The first inequality yields p1 > q1 — 1, while the second one can be
rewritten as
P1 — t11 - 1
—1 > —.
n (P1 — 1)(¢11 - 1)
Since gcd(n,n + 1) = 1, we cannot have p1 = q1, thus necessarily pl 2
q1 + 2 (since p1, q1 are odd). We conclude that
n< (p1 —1)(q1 —1) <1)?
Since p1 is the smallest prime factor of n, we deduce that n = p1. Thus
p1 = 1 + 2‘4 and cp(2A + 2) = 23. Since we assumed that n + 1 is
8.3.
The fundamental theorem of arithmetic
567
not a power of 2, we have A > 1, thus <p(2A‘1 + 1) = 23. But then
2""1 + 1 (which is odd) is a product of distinct Fermat numbers. Using
the uniqueness of the binary expansion, we easily obtain that 2"“1 + 1
must itself be a Fermat prime, i.e. A — 1 is a power of 2. But since
1 + 2" = 101 is a prime, A must also be a power of 2. We conclude that
A = 2 and so n = 5. The result follows.
El
62. (Komal A 492) Let A be a finite set of positive integers. Prove that
Z (-2)'S"1 gcd(S) > 0,
SCA
the sum running over all nonempty subsets S of A and gcd(S) denoting
the greatest common divisor of all elements of 3.
Proof. Let a1 <
< an be the elements of A and let N be their least
common multiple. Let lulu; be 1 if u | a; and 0 otherwise. The following
relation follows directly from Gauss’ formula
n(a’i1"")a"ik) =
Z
900‘) = 2 900“) ' Lula,-1 '
ulgod(a.~1,...,a,-k)
' 1u|a¢k -
u|N
We deduce that
n
2 (—2)IS|_1 gcd(S) = Z
SCA
Z
k=1i1<
:2)k_1
= Z(_
z
(—2)k_1 gcd(a,-1, ...,aik)
<12;c
2900“)
ZI-‘uJai1 '
' 1u|aik
lulu,
. 114%
i1<.. <ik uIN
—
_ Z<p(u) ;(—
—2)k 1
Z
u|N1i1<n<ik
(1l — 22
= 290011)} _(1 — 2 - 114
1u|a2)"-(1 — 2 . Lula”) _
uIN
All terms in the previous sum are nonnegative, and the term correspond-
ing to u = an is equal to <p(an). We conclude that
Z(—2)'S'—1gcd(3) 2 man) > 0.
SCA
D
568
8.4
Chapter 8. Solutions to practice problems
Congruences involving prime numbers
1. Prove that for all primes p the number
11...122...2...99...9—12...9
WW
p
p
\-\r—’
p
is divisible by 10.
Proof. The result is clear for p = 2 and for p = 3 it follows by computing
the sum of digits of the numbers involved, so assume that p > 3. By
definition we have
—_
10P—1
. 7P.
11...122...2...99...9—108p._._
9
+210
P
P
109—1
9
+...+9 .
10P—1
9
1’
Therefore, we need to prove that
108P- 10p9_ 1 — 108 + 2 (107P- 10p9_ 1 — 107) +
+ 9 (10p9_ 1 — 1)
is divisible to p. It suffices to check that 10’“0 - % E 10’“ (mod p)
for all k 2 0. By Fermat’s little theorem we have 10’“? E 10" (mod p),
hence it suffices to prove that 10" . w E 0 (mod p). This follows
from Fermat’s little theorem since p aé 3.
El
2. (Baltic Way 2009) Let p be a. prime of the form 6k — 1 and let a, b, c be
integers such that p | a + b + c and p | a4 + b4 + c4. Prove that p | a, b, 0.
Proof. We have a E —b — 0 (mod p) and so
b4 +04 + (b+c)4 E 0
(mod p),
which can be rewritten as 2(b2 + be + c2)2 E 0 (mod p). Thus p |
b2 + be + c2 and then p | b, c by corollary 5.30. The result follows.
III
8.4.
Congruences involving prime numbers
569
3. (Poland 2010) Let p be an odd prime of the form 3k + 2. Prove that
p—1
H(k2+k+ 1) E 3 (mod p).
k=1
Proof. Since p E 2 (mod 3), the map a: I——> 1:3 (mod p) is a permuta-
tion of {0, 1, ..., p — 1} (by corollary 5.30) and induces a permutation of
{2, ...,p — 1}. Thus
(p—2)!-pl:[1(k2+k+1)=3-pfll(k—1)(k2+k+1)
k=1
p—l
k=2
p—l
=3H(k3—1)E3-H(k—1)=3(p—2)l (modp)
and we conclude using the fact that gcd((p — 2)!, p) = 1.
El
4. (Iran 2004) Let f be a polynomial with integer coefficients such that for
all positive integers m, n there is an integer a such that n| f(a,m). Prove
that 0 or 1 is a root of f.
Proof. Let p be a prime and choose n = p and m = p — 1. By hypothesis
there is a such that p | flap—1). Since ap_1 E 0,1 (mod p), we have
flap—1) E f(0),f(1) (mod p) and so p | f(0)f(1). Since this holds for
any prime p, we deduce that f (0) f (1) = 0, hence the result.
5. (Cippola, Rotkiewicz) Prove that if m > 712 >
El
> 71.], > 1 are integers
with k > 1 and 2'“ > m then Fnl-ak and (2F"1 — 1)”_(2F,-.k — 1) are
pseudo-primes, where E, = 22" + 1 is the nth Fermat number.
Proof. Both numbers are clearly composite. Letting n = Fnl...Fnk, we
need to prove that n | 2"—1 — 1. Since F7,1 , ..., Fnk are pairwise relatively
prime (see example 3.12), it is enough to prove that Fm. | 2""1 — 1 for all
1 S i S k. Since Fm. | 27%1 — 1, we are further reduced to 22’Ii+1 — 1 |
570
Chapter 8. Solutions to practice problems
2"—1 — 1, or equivalently 2"""‘1 | n— 1. Since Fnj = 227". + 1 and 2’” > m
we have Fn. E 1 (mod 2%“) for all j and so n - 1 = q-Fnk — 1 E 0
(mod 2nk+f), as desired.
Now let m = (2Fn1 — 1)...(2F"k — 1). Again, since Fm, ..., Fnk are pairwise
relatively prime, so are the numbers 2Fnl — 1, ..., 2F"k — 1 and so it suffices
to prove that 2F"2‘ — 1 I 2"“1 — 1 for all j, or equivalently FM | m — 1
for all j. For this, it suffices to prove that 2Fnu — 1 E 1 (mod Fnj) for
all 1 g u, j g k, or equivalently F”, | 2Fnu-1 — 1. Since F“, I 22"“1 — 1,
we are further reduced to 27‘1“ | Fm, — 1 for all j, u, which is again an
immediate consequence of the hypothesis that 2"’° > 774.
El
(India TST 2014) Find all polynomials f with integer coefficients such
that f(n) and f (2”) are relatively prime for all positive integers n.
Proof. If f is constant, then clearly f is a solution of the problem if and
only if f = 1 or f = —1, so assume that f is not constant. Then there is
N > 1 such that l f(2” )| > 1. Let p be a prime divisor of f (2N) For any
positive integer k we then have p | f (2N + kp) and using the hypothesis
of the problem it follows that p does not divide f (22N‘l'kp). Note that
22N+kp522”.2k (mod p), hence f(22N+"”)Ef(22N-2’“) (mod I»),
thus p does not divide f(22” ~ 2’“). Since p | f(2”) and 22” - 2k — 2” |
f (22N -2k) — f (2N), we deduce that p cannot divide 22” ’2’“ — 2N for any
It 2 1. This is absurd: we can always choose k 2 1 such that 2N +k E N
(mod p — 1) and then p | 221v - 2k —— 2N by Fermat’s little theorem. Thus
no nonconstant polynomial can be solution of the problem and the only
solutions are f = 1 and f = —1.
El
(Rotkiewicz) An integer n > 1 is called pseudo-prime if n is composite
and n | 2” — 2. Prove that if p,q are distinct odd primes, then the
following statements are equivalent:
a) pq is a pseudo-prime.
b)p|2q“1—1andq|2p‘1—1.
8.4.
Congruences involving prime numbers
571
c) (21" — 1)(2’1 — 1) is a pseudo—prime.
Proof. Let n = (21’ — 1)(2‘1 — 1). Suppose that pq is a pseudo-prime and
let us prove b). By symmetry, it suffices to prove that p | 2‘1"1 — 1. But
since pq is pseudo-prime, we have pq | 21"] — 2, thus 21"? E 2 (mod p).
On the other hand, by Fermat’s little theorem 21"? E 2‘1 (mod p) and so
2‘1 E 2 (mod p), as desired. Thus b) holds.
Suppose that b) holds and let us prove that n is a pseudo-prime. Since
21" — 1 and 2‘1 — 1 are relatively prime, it sufl‘ices to prove that each of
them divides 2"“1 — 1, or equivalently that p and q divide n — 1. But by
Fermat’s little theorem n — 1 E 2‘1 — 1 — 1 = 2‘7 — 2 (mod p) and since
b) holds we obtain p | n — 1 and, by symmetry, q | n — 1, as desired.
Finally, assume that c) holds. Then 21’ — 1 | n | 2’“1 — 1, thus p | n — 1.
As in the previous paragraph n — 1 E 2‘1 — 2 (mod p) and so p | 2‘1 — 2
and, by symmetry, q | 2? — 2. Now Fermat’s little theorem and what we
have already established yield
21"] = (21)? E 2‘1 E 2
(mod p)
and similarly 21"? E 2 (mod q), thus pq | 2m — 2 and a) is proved.
El
8. (Gazeta Matematica) Find all odd primes p for which 2—7:;1 is a perfect
power.
Proof. It is easy to check that p = 3 and p = 7 are solutions and we will
show that these are the only solutions.
Write 21"-1 — 1 = p.73” for some as, n > 1. We will discuss two cases.
If n is even, write n = 2k and z = 12’“, then (2%1 — 1X2? + 1) = p22.
—1
—1
Since 2% — 1 and 2&2— + 1 are relatively prime, we deduce that there
is 'r 6 {—1,1} such that
Ed
22
+r=u2,
rd
22
—r=p'02
572
Chapter 8. Solutions to practice problems
for some positive integers u,v with no = 2. If r = 1, then u2 — 1 is
a power of 2, which implies that u = 3 and p = 7. If r = —1, then
—1
2% | 11.2 + 1 and since U2 + 1 cannot be a multiple of 4 we conclude
ps3,thenp=3.
Suppose now that n > 1 is odd, then a similar argument yields the
—1
existence of r 6 {—1,1} and u,v > 0 such that 2'3— + r = u” and
—1
222— — r = p1)". Then
2L;l = u” — r = u” — 7'” = (u —- ’I‘)(’U,n_1 +
and tin—1 +
+ r"_1 is odd. We deduce that u ‘1 +
+ r”"1)
+ r"‘1 = 1 and
this givesu=1,7‘=—1 andp=3.
III
. (IMO Shortlist 2012) Define rad(0) = rad(1) = 1 and, for n 2 2 let
rad(n) be the product of the different prime divisors of n. Find all polynomials f (m) with nonnegative integer coefficients such that rad(f (n))
divides rad(f (nmd(”))) for all nonnegative integers n.
Proof. Let f be such a polynomial and suppose that f is not the zero
polynomial (which is clearly a solution of the problem).
Note that
rad(n’°) = rad(n) for all n and all k 2 1. Let n be a nonnegative
integer and define $0 = n and xk+1 = $28M”). Then by assumption rad(f(ar:k)) divides rad(f(a:k+1)) for all k.
On the other hand,
rad(:z:k+1) = rad(xk) = rad(n) for all k, hence wk = nmd(”)k. We conclude that rad(f (n)) divides rad(f (nm‘d(”)k)) for all n and all k.
Since f is not the zero polynomial and since its coeflicients are nonneg-
ative, we must have f (1) 7E 0. Let p be any prime greater than f (1)
and suppose that p divides f (n) for some nonnegative integer n. We
will prove that p divides n. Replacing n by n + pm for a suitable m,
we may assume that p — 1 divides n. Thus for k large enough we have
p — 1 | rad(n)k and since p does not divide n, Fermat’s little theorem
gives 17,1”"“d(")'c E 1 (mod p), thus f(n’ad(")k) E f(1) (mod p) and so 1)
does not divide rad(f (n’a‘d(”)k)). This contradicts the first paragraph
and the fact that p divides f(n)
8.4.
Congmences involving prime numbers
573
Thus for all primes p > f (1) such that p | f (n) for some n we have p I n.
Writing f (X) = Xkg(X) for some nonnegative k and some polynomial
9 such that g(0) 7E 0, we claim that g is constant. Indeed, otherwise
by Schur’s theorem 4.67 there are infinitely many primes p for which
p | g(n) for some n. By the previous paragraph each such p divides n
and so it also divides 9(0). But then 9(0) = 0, a contradiction. Hence
9 is constant and f (X) = cX" for some nonnegative integer c. Since all
these polynomials are clearly solutions of the problem, we are done.
III
10. (Turkey TST 2013) Find all pairs of positive integers (m, n) such that
2"+(n—<p(n)—1)! =nm+1.
Proof. Let n, m be a solution of the problem, then clearly n > 1. Let p
be the smallest prime divisor of n, then
17.
71—712—
<p() p
since all multiples of p between 1 and n are not relatively prime to n.
If p S n — 90(n) — 1 then taking the original equation modulo p yields
p I 2" — 1. Since p | 219—1 — 1 we obtain p | 2g°d('"’1"1) — 1 = 1, the
last equality being a consequence of the fact that p is the smallest prime
factor of n, thus gcd(n, p— 1) = 1. Hence we must have p 2 n—<p(n) 2 %,
that is n 5 p2. Since p is the smallest prime factor of n, we deduce that
n = p or n = p2. If n = p the equality becomes 2" = 72'" which forces
n = 2 and then m = 2. Suppose that n = p2 for a prime p, then the
equation becomes 21’2 +(p—1)! = p2m+1. If p > 3 then the left-hand side
is a multiple of 4, while the right-hand side is not. Thus p S 3. For p = 2
we obtain m = 2 and for p = 3 we obtain 513 = 9m, with no solution. We
conclude that the solutions of the problem are (m, n) = (2, 2), (2, 4).
11. (Serbia 2015) Find all nonnegative integers ac, 3,1 such that
(22"15 + 1)”‘ + 22015 = 29 + 1.
El
574
Chapter 8. Solutions to practice problems
Proof. There are two obvious solutions, namely (3:, y) = (0,2015) and
(x,y) = (1,2016). Assume now that (9:, y) is a solution with a: > 1.
Then 29 > (22015 + 1)2, so y > 4030. Taking the equation mod 24030
yields
1 + 220151: + 22015 E 1 + 211 E 1 (mod 24030),
which shows in particular that 16 | x+ 1. Next, we work modulo 17. We
have 24 E —1 (mod 17), thus
22015 E 24'503+3 a —8 a 9 (mod 17),
thus we obtain 10“” +8 E 23’ (mod 17). Since a: E —1 (mod 16), we have
by Fermat’s little theorem
10¢ a 10-1 E —5 (mod 17).
We conclude that 2” E 3 (mod 17). Writing y = 4k: + r with 0 S r S 3,
we finally obtain (—1)’° - 2' E 3 (mod 17). A simple verification shows
that there are no such 7‘, Ic, showing therefore that there are no solutions
with a; > 1. Therefore we have already found all solutions.
El
12. (Italy 2010) If n is a positive integer, let
an = 2n3+1 _ 3n2+1 + 5n+1‘
Prove that infinitely many primes divide at least one of the numbers
a1, a2,
Proof. Suppose that this is not the case and let p1,...,pk be all odd
primes dividing at least one of the numbers a1, a2,
Let
n = 8(p1 — 1)...(pk — 1)
for some positive integer 3. Note that since 5 is among p1, ...,pk (as
5 | (11) we have4 | n and so an E 2 (mod4), an E 1 (mod3) and
an E 2"3+1 + 2712‘H E 4 (mod 5). In particular if an > 2 (which is
definitely the case for .9 large enough, actually even for any 3 2 1) then
8.4.
Congmences involving prime numbers
575
an must have a prime factor p greater than 5. By assumption this prime
factor is among p1, ..., pk and so p — 1 | n. Using Fermat’s little theorem
we obtain an E 2 — 3 + 5 E 4 (mod p), a contradiction.
El
13. (China TST 2010) Find all positive integers m, n 2 2, such that
a) m + 1 is a prime number of the form 4k — 1;
b) there is a prime number p and a nonnegative integer a such that
m211—1 _
m_1
=
n
m +p
a.
Proof. Let q = m + 1 and note that by assumption m E 2 (mod 4).
Taking the equation mod 4 yields 3 E q E p“ (mod 4), which forces a
being odd and p E 3 (mod 4).
Next, write the equation as
11
m2_
m_11_(mn+1+1)_
Assume that n + 1 is even, and let v2(n + 1)—
— r, then clearly r < n so
that my + 1 divides both mm_"1 and m”+1 +21. Thus m2 + 1 I mp“ and
since gcd(m2r + 1,m) = 1 we deduce that m2 + 1 is a power of p. But
then p | my + 1, a contradiction with p__
= 3 (mod 4).
Hence n + 1 is odd. Then q= m + 1 divides both mm ‘1and m”+1 + 1,
hence as before q | p“. This forces q= p. Now, write the equation as
q+m2+m3+...+m2”_2=m”+q“.
If n 2 3 then the left-hand side is congruent to q + 4 mod 8, while the
right-hand side is congruent to q“ E q (mod 8), a contradiction. Hence
we must have n—
— 2 and the equation reduces to m + 1—
— p“. We must
have a— 1, hence the answer is given by pairs (m, n): (q — 1, 2) with
q a prime of the form 4k — 1.
El
576
Chapter 8. Solutions to practice problems
14. Let p be a prime. Prove that there is a positive integer n such that p is
the smallest prime divisor of n! + 1.
Proof. Simply choose n = p — 1. By Wilson’s theorem p | n! + 1, and if
q is a prime divisor of n! + 1 then clearly q > n = p — 1 (otherwise q | n!,
a contradiction with q | n! + 1) and so q 2 p.
E!
15. Let n > 1 and suppose that there is k E {0,1,...,n — 1} such that
k!(n — k — 1)! + (—1)!0 E 0 (mod n)
Prove that n is a prime.
Proof. Suppose that n is composite and let p be its smallest prime factor.
Then p S (/77. On the other hand by assumption p does not divide
k!(n — Ic — 1)!, thus p 2 19+ 1 and p 2 n — k. We deduce that 2]) 2
n + 1 2 p2 + 1, that is (p — 1)2 S 0, a contradiction. Hence n is a prime
number.
[I
16. For each positive integer n find the greatest common divisor of n! + 1
and (n + 1)!.
Proof. Suppose that a prime p divides nl+1 and (12+ 1)!. Then p g n+1
(since it divides (71+ 1)!) and p > n (otherwise p divides nl, hence cannot
divide n! + 1). Thus p = n + 1. This shows that if n + 1 is not a prime,
then gcd(n! + 1,(n + 1)!) = 1, while if n + 1 = p is a prime, then
gcd(n! + 1, (n + 1)!) is a power of p. By Wilson’s theorem, p divides
n! + 1 = (p — 1)! + 1. Hence p divides gcd(n! + 1, (n + 1)!). Moreover,
p2 does not divide (n + 1)!, since otherwise p would divide n! and so
n + 1 = p S n, a contradiction. Therefore gcd(n! + 1, (n + 1)!) = p if
n+1=pisaprime.
III
17. Let p be a prime and let a1, a2, ..., ap_1 be consecutive integers.
a) What are the possible remainders of alaz...ap_1 when divided by p?
b) Suppose that p E 3 (mod 4). Prove that 0.1, ..., ap_1 cannot be partitioned into two sets with the same product of their elements.
8.4.
Congr'uences involving prime numbers
577
Proof. 3.) If one of the ai’s is divisible by p, then clearly the remainder
of alag...ap_1 when divided by p is 0, so assume that al, ...,ap_1 are
not divisible by p. Since a1, ..., ap_1 are p — 1 consecutive integers, they
give pairwise difl'erent remainders when divided by p, and by assumption these remainders are nonzero. It follows that the remainders of
a1, ..., ap_1 when divided by p are a permutation of 1, 2, ...,p — 1 and so
by Wilson’s theorem
a1a2...ap_1 E 1 - 2 -
- (p — 1) = (p — 1)! E —1
(mod p).
Hence the answer of the problem is given by 0 and p — 1.
b) Suppose that there is such a partition in two sets A and B and let
a), y be the product of the elements of A, respectively B. By assumption
w = y, thus
(122 = (By = a1a2...ap_1.
If alaz...ap_1 is not a multiple of p, then part a) yields 1:2 E —1 (mod p),
thus p | x2+1, contradicting the fact that p E 3 (mod 4). Thus a1...ap_1
is a multiple of p and so one of the ai’s is a multiple of p. Since an, ..., ap_1
are p — 1 consecutive integers, exactly one of them is a multiple of p. But
then exactly one of the numbers a: and y is a multiple of p, contradicting
the equality :1: = y.
I]
18. Find two primes p such that (p - 1)! + 1 E 0 (mod p2).
Proof. Clearly p = 5 is a solution of the problem. One can tediously
check that p = 13 is also a solution. Here is a rather tricky way to do it
without actually computing 12!: we have
12!:(2-3-4-7)-(6-11-8-2-4)-(5-9-5-3)
and one easily checks that the products in each parenthesis are congruent
to —1 (mod 169): for the second set of parentheses note that
6-11-8-2-4=64-66=652—1_=_—1 (mod132)
578
Chapter 8. Solutions to practice problems
and similarly for the third one note that
5-9-5-3=25-27=262—lE—1 (mod 132).
The only known such primes are 5, 13, 563, all others are > 2 - 1013.
19. Find all sequences a1, a2,
integers m, n
El
of positive integers such that for all positive
m!+n! | am!+an!.
Proof. Clearly n! | an! for all n, thus an 2 n for all n 2 1. Next, if p
is a prime then Wilson’s theorem gives p | 1! + (p — 1)! | all + ap_1!. If
p > a1, then p cannot divide a1! and so p cannot divide ap_1!. Since
(119.1 2 p — 1, we must have ap_1 = p — 1 for all p > an. Thus for all
n 2 1 and all primesp > a1 we have (p—l)!+n! | (p—l)!+an!, thus also
(p — 1)! + n! | an! — nl. Fixing n 2 1 and varying p yields on! = n!. We
conclude that the only solution of the problem is given by the sequence
an=nforalln21.
El
20. Let p be an odd prime. A subset A of Z is called a complete set of
nonzero residue classes modulo p if A consists of p — 1 integers giving
pairwise distinct and nonzero remainders when divided by p. Prove that
if A = {a1,a2,...,ap_1} and B = {b1,b2,...,bp_1} are complete sets
of nonzero residue classes modulo p, then {a1b1, . . . ,ap_1bp_1} is not a
complete set of nonzero residue classes.
Proof. Using problem 17 it follows that for any complete set A of nonzero
residue classes modulo p we have HaeA a E —1 (mod p). Therefore
p—l
—1
H045 Hn—l
i=1
(modp)
1:].
and consequently
p—l
H(a,-bi) E 1 75 —1
i=1
(mod p).
8.4.
Congmences involving prime numbers
579
It follows that {a1b1, . . . ,ap_1b _1} is not a complete set of nonzero
residue classes.
[I
21. (Clement’s criterion) Let n be an integer greater than 2. Prove that n
and n + 2 are both primes if and only if
4((n — 1)! + 1) + n E 0
(mod n(n+ 2)).
Proof. Suppose that n and n + 2 are both primes. By Wilson’s theorem
4((n—1)!+1)+n E 0 (mod n). By theorem 5.49 we have 2(n— 1)! E —1
(mod n + 2), thus
4((n—1)!+1)+nE—2+4+nE0
(mod n+2).
This proves one implication, since gcd(n, n + 2) = 1.
Assume now that 4((n — 1)! + 1) + n E 0 (mod n(n + 2)), in particular
n | 4((n — 1)! + 1). Let us prove that n must be odd. Write 122(93) for
the exponent of 2 in the prime factorization of x. If n is even, then
122 (n) 3 v2 (4((n — 1)! + 1)) = 2. Moreover, if d is the largest odd divisor
ofn, then d < nso d | (12—1)! and since d | n | 4((n—1)!+1) we
deduce that d | 4 and then d = 1, that is n is a power of 2. Since
122 (n) S 2, it follows that n = 2 or n = 4, but neither of these satisfies
4((n — 1)! + 1) + n E 0 (mod n(n + 2)).
Thus 77. is odd, and since n | 4((n— 1)!+ 1) we deduce that n | (n— 1)! + 1
and then that n is a prime. Next, let k: = n + 2, then
k|4((k-3)!+1)+k—2=4(k—3)!+k+2,
thus k | 4(k — 3)! + 2. Since k is odd, we deduce that k | 2(k — 3)! + 1.
But then
(k —— 1)! = (k — 3)!(k — 2)(k — 1) E 206 — 3)! E —1
thus k is a prime and we are done.
(mod k),
El
580
Chapter 8. Solutions to practice problems
22. Let n > 1 be an integer. Prove that there exists a positive integer k and
e 6 {—1,1} such that 2k + 1 | n+€k!.
Proof. Let p be an odd prime divisor of n2 + 1 (such p exists since
n2 + 1 > 4 and is not divisible by 4). Then p E 1 (mod 4) so taking
k = %1 we havep = 2k+1| (k!)2+1 andp | n2+1, hencep| (k!)2—n2.
Since p is a prime, p = 2k + 1 divides one of the numbers n + k! and
n — k!, and the result follows.
III
23. (Moldova TST 2007) Prove that for infinitely many prime numbers 10
there is a positive integer n such that 77. does not divide p— 1 and p I n!+1.
Proof. The key is the congruence
k!(p — 1 — k)! E (—1)"'1
(mod p)
established in theorem 5.49. Take for now an arbitrary even number k:
and assume that p | k! — 1, then necessarily p > k (otherwise p I k!)
and the above congruence shows that p | (p — k — 1)! + 1. We want to
ensure thatp—k— 1 does not dividep— 1. p—k— 1 lp—l, then
p — 1 — k | k. To make our life easier, choose 16 = 2q with q > 2 a prime,
then necessarily p > 3 (since p > k) and so 1) — 1 -— k (which is assumed
to divide k = 2q) equals 2 or 2q. We cannot have p — 1 — k = 2 since in
this casep | 2!+1 =3, thusp—1—2q=2q andsop= 1+4q. It is
now very easy to conclude: for each odd prime q choose a prime divisor
p of (2g)! — 1 of the form 4k + 3 (this is possible since (2g)! — 1 E 3
(mod 4)), then by the above discussion p is a solution of the problem.
Since p > 2q, when q varies over all odd primes we get infinitely many
solutions of the problem.
III
24. Find all polynomials f with integer coefficients such that for all primes
p we have f(p) | (p— 1)! + 1.
Proof. If f is constant, say f = c, then c | 2 and c | 3 thus c = :l:1.
Conversely, the constant polynomials :l:1 are solutions of the problem,
8.4.
Cong'ruences involving prime numbers
581
so assume now that f is not constant. Replacing f with — f we may
assume that the leading coeflicient of f is positive. Thus if p is a large
enough prime, then f (p) > 1. Let q be a prime factor of f (p) and assume
that q 75 p. By Dirichlet’s theorem there are infinitely many primes 7‘ E p
(mod q). Then f(r) E f(p) E 0 (mod q) and so q | f(r) | (r — 1)! + 1,
yielding q 2 r for infinitely many primes r, a contradiction. Hence if p is
a large enough prime, then f (p) is a power of 12, say f (p) = p“? for some
positive integer ap. If d = deg f, then there is a constant c > 0 such that
f (x) < casd for all a: > 1. Thus 1)“? < cpd for all large enough p and so
the sequence (up) is bounded. It follows that there is a positive integer
a such that f(p) = p“ for infinitely many primes p, but then f (x) = as“
for all :17. We deduce that p“ | (p — 1)! + 1 for all primes p and so 2“ | 2.
But then a = 1 and f(x) = 2:. Hence the solutions of the problem are
the polynomials :|:1, :IzX.
El
25. (adapted from Serbia 2010) Let a, n be positive integers such that a. > 1
and a" + a ’1 +
+a + 1 divides a"!+a("_1)!+
+ a“ + 1. Prove that
n=1mn=2
Proof. In general, suppose that a” + (In—1 +
+ a + 1 divides a,“1 +
+ ah" + 1 for some positive integers ki. Let n be the remainder of
kz- modulo n + 1. Since a” +
+ a + 1 | a)“1 — 1, it follows that
a” + + (1+ 1 I a"1 + +a’" + 1. Suppose that C; is the number of rj’s
equal to j. Thus co+...+cn = n and a”+...+a+1 | cna"+...+c1a+co+1.
Consider now an n + l—tuple (b0, ...,bn) of nonnegative integers which
minimizes be + + b" subject to the condition a," + + a + 1 | bna" +
...+b1a+bo. If some b,- 2 a, then replacing b,- by bi—a and b¢+1 by bi+1+1
does not change bnan+ +b1a+b0, but diminishes be + +bn and yields
an n + 1-tuple with a smaller sum, a contradiction. Hence all b,- are less
than a and so bna”+...+b1a+bo = r(a"+...+a+1) for some 7' < (1. But
uniqueness of base a representation then yields b =
= b0 = r. We
conclude that the minimal value of be + + bn = n + 1 and is obtained
only when b0 =
= n = 1.
582
Chapter 8. Solutions to practice problems
Combining the previous paragraphs, we deduce that on =
= co = 1
and so r1, ...,rn are a permutation of 1,2,...,n. Applying this to our
initial problem, we deduce that 1!, 2!, ..., 11.! give remainders 1, 2, ..., n (in
some order) when divided by n + 1. If n + 1 is a composite number and
n > 3, then 77.! gives remainder 0 when divided by n + 1, hence this case
is impossible. If n + 1 = p is a\ prime and p > 3, then Wilson’s theorem
gives (p—2)! E 1 (mod 1)), hence (n— 1)! and 1! give the same remainder
mod n + 1, again a contradiction. Hence necessarily n = 1 or n = 2.
El
26. Let p be a prime. Prove that the sequence of remainders mod p of the
numbers 1, 22, 33, 44,
is periodic and find its least period.
Proof. To prove periodicity, note that
(n + p2 — mm”? a unfit-P s n" (mod p),
the last congruence being a consequence of Fermat’s little theorem. We
need to find the smallest positive integer T for which (n + T)”+T E n“
(mod p) for all 77.. Taking n = p we obtain (p + T)I’"'T E pp (mod p),
which reduces to T E 0 (mod p). But then 71.” E (n + T)""‘T E n"+T
(mod p) for all 12.. Hence p | n'"(nT — 1) (mod p). It follows that nT E
(mod p) for all n relatively prime to p and so (by corollary 5.76) p— 1 | T.
Conversely, if p — 1 | T, then 1) | n”(nT — 1) for all n, by Fermat’s little
theorem. We conclude that T is a period of the sequence if and only if
p(p — 1) | T. Thus the smallest period is p(p — 1).
El
27. (Don Zagier) Somebody incorrectly remembered Fermat’s little theorem
as saying that the congruence a."+1 E a (mod 72.) holds for all integers
0.. Describe the set of integers n for which this property is in fact true.
Proof. The answer is 1, 2, 6,42,1806. Let n be such an integer, then 11. is
squarefree: if p | n we can choose a = p and obtain n | p(p" — 1), thus p2
does not divide 77.. So, assuming that n > 1 (note that n = 1 is clearly
a solution), we can write n = p1...pk with p1 <
< pk distinct primes.
Fix 2' 6 {1,2, ..., k}. By assumption for any a which is not a multiple of
8.4.
Congruences involving prime numbers
583
p,- we have p, | n | a(a" —- 1), thus p,- | a“ — 1. We deduce from corollary
5.76 that p,- — 1 I n. In particular p1 — 1 | n and since p1 is the smallest
prime factor of n, this forces p1 — 1 = 1 and so 131 = 2. Similarly, from
p2—1 | n and gcd(p2— 1,p2...pk) = 1 we obtain p2— 1 | 2 and then p2 = 3
(if k 2 2). Continuing like this we obtain p3 = 7 (if k 2 3), then 124 = 43
(if k 2 4). Assuming that k 2 5 we obtain p5 — 1 | 1806. It is however
easy to see that there is no such prime p5, thus k S 4 and the solutions
are given by 1,2,2 - 3,2 - 3 - 7,2 - 3 - 7 - 43, i.e. 1,2,6,42,1806. It is not
difficult to see, using Fermat’s little theorem, that if n is squarefree and
p — 1 | n for all primes p | n, then n is a solution of the problem.
El
28. Let p be an odd prime. Find the largest degree of a polynomial f with
the following properties:
a) deg f < p.
b) the coeflicients of f are integers between 0 and p — 1.
c) If m,n are integers and p does not divide m — n, then p does not
divide f(m) — f (n)
Proof. First of all, the polynomial f (X) = X1"2 is a solution of the
problem. Indeed, assuming that p l m?"2 — n”—2 and that p does not
divide m — n, we see that p does not divide mn. But then using Fermat’s
little theorem we obtain m‘1 E n"1 (mod p) (where 32—1 is the inverse
of ac modulo p) and then m E n (mod p), a contradiction.
We will now prove that there is no polynomial f of degree p— 1 satisfying
a), b) and c). Suppose that such a polynomial exists, and write
f=cX1"1 +g
with c 6 {1,2, ...,p — 1} and deg(g) S p — 2. By condition c)
f(0)+f(1)+...+f(p—1)E 0+1+...+(p—1)= “10—2—11 5 0 (mod p).
584
Chapter 8. Solutions to practice problems
On the other hand Fermat’s little theorem combined with corollary 5.77
yield
f(O) + f(l) +
+ f(p — 1) = c(11"‘1 + 21"1 +
+ (p — 1)P‘1)
+ 9(0) + 9(1) + + g(p — 1)
5c(1+1+...+1)+OE —c (modp),
a. contradiction since c is not a. multiple of p. Thus the answer of the
problem is p — 2.
El
29. (Iran TST 2012) Let p > 2 be an odd prime. 1ft 6 {0,1,..,p — 1} and
f = a0 + a1X + + 0,a is a polynomial with integer coefficients, we
say that f is i-remainder if
2
ajEi
(modp).
j>0,P_1|j
Prove that the following statements are equivalent:
a) f, f2, ..., fl"—2 are O-remainder and fp‘l is 1-remainder.
b) f (0), f (1), ..., f(p — 1) form a complete residue system modulo p.
Proof. Corollary 5.77 shows that for any polynomial
f = a0 + a1X +
+ 0,a
with integer coefficients we have (with the convention 00 = 1)
f(0)+f(1)+...+f(p— 1) =iaj(0j+1j +...+(p— 1)j)
i=0
E—
Z of
J'>0,P-1|J'
(modp),
hence f is i—remainder if and only if
f(O) + f(l) +
+ f(p— 1) E —i
(mod p).
8.4.
Congruences involving prime numbers
585
Suppose first that f (0), f (1), ..., f (p — 1) form a complete residue system
modulo p. We need to prove that f(0)j + + f(p — 1)j E 0 (mod p)
for 1 S j S p — 2 and f(0)1"_1 + + f(p— 1)1”_1 E —1 (mod p). But
since f(0)j + f(1)j + + f(p — 1)j E Oj + lj + + (p — 1)j (mod p),
the result follows from corollary 5. 77.
Conversely, assume that f, f2,.. ., f? 2 are O-remainder and f? 1 is 1remainder and let aj = f (j) By assumption a0 +.. .+ a;_1 _
=0 (mod p)
forlSjgp—Zandaff1.+ n£+a_IE—1(modp). Thislast
congruence combined with Fermat’s little theorem shows that exactly
one of a0, ..., ap_1 is a multiple of 1). Similarly, if c is any integer then
p_1
p—l
2+
2(ak — c)"'1 = p—l
2a? 1 — <P —1 1 )cZafi—
Ic=0
k=0
E —1
+p(—-c)1"1
k=0
(mod p)
and so exactly one of a0 — c, ..., ap_1 — c is a multiple of p. This is equivalent to the fact that am, ...,ap_1 is a complete residue system modulo
p.
E
30. Find all integers n > 2 for which n | 2” + 3” +
+ (n — 1)".
Proof. Let n be such a number and let p be a prime divisor of n. Write
n = kp and observe that
1” + 2" +
+ (n — 1)" E k(1" + 2” +
+ (p — 1)”)
(mod p),
since
(px+1)”+...+(pw+p—1)"E 1‘”+...+(p— 1)”
(modp)
for all 1:. We deduce that
k(1n + 2n +
+ (p — 1)") E 1
(mod p).
In particular p does not divide k, Le. 102 does not divide n. Since p
was an arbitrary prime, this means that n is squarefree. On the other
586
Chapter 8. Solutions to practice problems
hand, the sum 1” + 2" +
+ (p — 1)" is not divisible by p thanks to the
previous congruence. Corollary 5.77 implies therefore that p — 1 | n and
so 1'” + + (p — 1)" E —1 (mod p). Thus k E —1 (mod p). In other
words, n must be squarefree, p — 1 | n and p | g + 1 for all p | n. The
solution of problem 27 shows that the first conditions are already enough
to ensure that n = 6, 42 or 1806. It is not difficult to check that each of
these numbers is a solution of the problem: by the above computations
this comes down to checking that p — 1 | n and p | g + 1 for each p I n,
which is straightforward. Thus the solutions of the problem are 6,42
and 1806.
El
31. (Alon, Dubiner) Let p be a prime and let a1, ...,a31,,,b1,...,b3p be integers
such that
3p
3p
2a,- E Eb, E 0
i=1
i=1
(mod p).
Prove that there is a subset I C {1,2, ..., 3p} with p elements such that
2a,- : 2b,- 50 (mod p).
ieI
ieI
Proof. Consider the following system of congruences
317—1
2 emf—1 E 0
i=1
(mod p),
311-1
2 biz-5‘1 E 0 (mod p),
i=1
3p—1
2 avg—1 E 0 (mod p).
i=1
Since 3(p — 1) < 3p — 1 and m1 = x2 =
= w3p_1 = 0 is a solution, by
corollary 5.88 the system has a nontrivial solution (xi)1§i33p—1- Let
1: {il1 S 2' S 310- 1,931- 760 (mod 10)},
8.4.
Cong'ruences involving prime numbers
587
then Fermat’s little theorem combined with the equations of the system
yields
2a,; E 0
(mod p),
ieI
2b,; E 0 (mod p).
ieI
Moreover, we have p | |I|, thus |I| = p or III = 2p. In the first case
it suflices to choose the set I, in the second case we can choose its
complement (this is where the hypothesis that the sum of the ai’s and
the sum of the bj’s are multiples of p is used).
[I
32. Prove that for any n > 1 the number (3)4 + (’1’)4 +
of any prime p E (n, én].
+ (Z)4 is a multiple
Proof. Let
A = (n + 1)(n + 2)...(p — 1),
with the convention that A = 1 ifp = n + 1. For all j 6 {0,1, ...,n} we
have
A(n) = (p— 1) .
j
-n(n'— 1)...(n—j+1)
J!
=(n—j+1)-....(p—
1_fl,@—»e—2Tnm@—n
Since (17 —j)(p —j + 1)...(p — 1) is congruent to (—1)j -j! modulo p, we
4
deduce that
144.2(3)
22m)
(map),
i=0
i=0
where
f(X) = (n—X+1)4-...-(p—X—1)4.
Note that
deg(f) =4(p— l—n) <p— 1
thanks to the hypothesis of the problem. Also
f(n+1)=...=f(p—1)=O,
588
Chapter 8. Solutions to practice problems
thus (using corollary 5.77)
n
P—1
Z: W) a Z M) E 0 (mod p)
j=0
j=0
and we conclude that A4 - 39:0 (7;)4 is a multiple of p. Since A is not a.
multiple of p, the result follows.
III
33. Let f be a monic polynomial of degree n 2 1, With integer coefficients.
Suppose that b1, ..., bn are pairwise distinct integers and that for infinitely
many primes p the simultaneous congruences
f(a:+ b1) E f(:t+b2) E
E f(1l:+bn)_=. 0
(mod p)
have a common solution. Prove that the equations
f(a:+b1) =
= f(w+bn) = 0
have a common integral solution.
Proof. Since b1,...,bn are pairwise distinct, they are pairwise distinct
modulo p for all sufficiently large primes p (more precisely for all primes
p not dividing the nonzero integer [II-#- (bi — bj)). We only consider such
primes p from now on. By assumption for infinitely many such primes
p we can find an integer mp such that f (93,, + bi) E 0 (mod p) for all
1 S i S n. Using Lagrange’s theorem, we deduce that
11
1‘00 5 H(X - 17p - bi) (mod 1?),
i=1
since the difference between the two sides is a polynomial of degree at
most n — 1 that has at least 77. distinct roots modulo p (namely the
numbers $1,, + bi with 1 S 12 S n). Writing
f(X) = X“ + an_1X""‘1 +
+ a0,
8.4.
Congr’uences involving prime numbers
589
we deduce that
n
an_1 E —na:p — Z bi
(mod p).
i=1
Letting
n
A = ”an—1 _ Zb‘i)
i=1
we obtain nxp E A (mod p). Since nxp E A (mod p) and f(mp + bi) E 0
(mod p), it follows that for all 1 S i S n
ndf (g + b;) E 0
(mod p).
The left-hand side is independent of p and since the congruence holds
for infinitely many primes we deduce that f (f + bi) = 0 for 1 S i S n.
By the rational root theorem the rational number % + b1- must be an
integer, thus a: := g is an integer and f(:1: + bi) = 0 for 1 S 2' g n. The
I]
result follows.
34. (Romania TST 2016) Given a prime p, prove that
B]
2w
is not divisible by q for all but finitely many primes q.
Proof. Since each prime q 7E p is of the form q = pn + 7' for some
1 S 'r' S p — 1, it will be enough to prove that for each such 7' there are
only finitely many n such that pn + 7' | 11"1 + 21"1 +
+ imp—1. Let us
fix r E {1,2,...,p — 1} and assume that m + r | 11"1 +
+ 1211—1 for
infinitely many n.
The first key observation is that for each k 2 1 there is a polynomial
fk with rational coefiicients, of degree k + 1 and leading coefficient 761—1,
such that
1" + 2’“ +
+ n"9 = fk(n)
590
Chapter 8. Solutions to practice problems
for all n 2 1. This is easily established by induction on k, using the
following relation to pass from k — 1 to k
(n+1)k+1—1 = (k1+ 1) (1"+.. .n+ k)+(k; 1)(1k”1+...+nk_1)+...+n.
This relation follows immediately by adding up the relations (for 1 S
a)
(j+1)k+1—jk+1= (k:1)jk+(k; 2 )jk'1+...+1
deduced from the binomial formula.
Let f = fp_1, so that
Choose the smallest integer M Z 1 such that Mf has integer coeflicients.
Then p | M, since the leading coeflicient of f is 1—1,. We know that
pn+r | Mf (n) for infinitely many n. But pn+r also divides pp(Mf (n) —
Mf (——)), thus pn + r divides ppMf (— ) for infinitely many n. This
yields Mf (—E) — 0. Using example 3.64, we obtain the existence of a
polynomial g pwith integer coefficients such that
Mf(n) = (P71 + T)g(n)
for all n. Since f (n) is an integer for all n, p | M and gcd(p,pn+r) = 1,
we deduce that p | g(n) for all n. However deg g = deg f — 1 = p — 1,
thus Lagrange’s theorem yields 9 E 0 (mod p). But then
grow <pX+ > 97""
has integer coeflicients, contradicting the minimality of M. The result
follows.
El
8.4.
Cong'ruences involving prime numbers
591
35. (China 2016) Let p be an odd prime and a1, a2, ..., up be integers. Prove
that the following two conditions are equivalent:
a) There is a polynomial P of degree S %1 such that P(i) E (11- (mod p)
for all 1 S i S p;
—1
b)Forany1$dSp2—
p
:(‘IHd - (102 E 0 (mOd P),
i=1
Where indices are taken modulo p.
Proof. The fact that a) implies b) is fairly easy. Indeed, if ai E P(i)
(mod p) and degP S %1, then considering Q(X) = P(X + d) — P(X)
we have deg Q g %3, thus deg(Q2) < p — 1 and so (by corollary 5.77)
19
262(2)2 E 0
(mod p),
i=1
which is exactly the content of part b).
Let us turn now to the interesting implication. Note that since p is odd
and 1 + d,2 + d, ...,p + d is a complete residue system modulo p, the
congruence in part b) is equivalent to
P
P
E a? E Z a¢a¢+d
i=1
i 1
for all 1 S d S pg—l. Consider a polynomial P of degree _<_ p— 1 such that
P(i) E az- (mod p) for 1 S i S p (P is actually unique by Lagrange’s
theorem). It is not difficult to construct such a polynomial: choose
integers b1: such that b,- Hj¢i(i — j) E 1 (mod p) and set
P(X) = i=1
iii-b.- #z‘
H<X —j).
592
Chapter 8. Solutions to practice problems
Consider now the polynomial
p
Q(X) = ZP(i)P(X + 1').
i=1
The hypothesis of the problem becomes Q(d) E Q(0) (mod p) for 1 g
d S 521. For such d we also have (using that 1 — d,2 — d, ...,p — dis a
complete residue system mod p)
P
P
Q(-d) = Z P(z')P(z' — d) a ZPU +d)P(j) = CM) 2 62(0) (mod p),
i=1
j=1
thus the congruence Q(X) — Q(O) E 0 (mod p) has at least 1) solutions.
Since degQ S p — 1, Lagrange’s theorem yields Q E Q(0) (mod p), i.e.
all coefficients of the polynomial Q — (2(0) are multiples of p.
Finally, write
P(X) a cor" + fiX"1 +
(mod p),
with a 75 0 andr Sp—l. Assume that r > %1 and let k = 2r—(p—1).
Note that k > 0 and k S r. Since
Q(X) = :P(i)[a(X + z‘)’ + ,6(X + z)"—1 + ...],
1.=1
the coeflicient of Xk in Q(X) — Q(0) is
p
r
r—1
ZP(i)(a(k)z""’°+fl( k )ir‘k—1+...)
13:1
and this is 0 mod p by the previous discussion. We deduce that
fir—k—l +
(1(2) ;P(’i)iT—k + 16C" 2 1) :Pa
E0
(mod p).
8.4.
Cong'ruences involving prime numbers
593
Note that since deg(P - X’“"‘j) = 2r —— k — j = p — 1 — j, we have (by
corollary 5.77)
iP(i)iT_k E —a
(mod p),
i=1
iP(i)z"’_k_1 E 0
(mod p),
i=1
Thus the previous congruence becomes
a2 (1:) E 0 (mod p).
This is certainly impossible, since a is not a multiple of p and p > 7' Z
k.
E]
36. (USAMO 1999) Let p be an odd prime and let a, b, c,d be integers not
divisible by 1) such that
m
—
P
+
rb
—P
+
rc
—
P
+
rd
—
=2
P
for all integers 'r not divisible by p (where {at} is the fractional part of m).
Prove that at least two of the numbers a + b, a+ C, (1+ d, b+ c, b+ d, c+ d
are divisible by p.
Proof. This is a very difficult problem! Let 1'(:c) E {0, 1, ..., p — 1} be the
remainder of a: mod p, so that the hypothesis of the problem becomes
r(an) + 'r(bn) + r(cn) + r(dn) = 2p
for any n relatively prime to p. Call such a 4-tup1e (a, b, c, d) good.
Clearly if (a, b, c, d) is good, then so is (ka, kb, kc, kd) for any k which is
not a multiple of 19. Note also that if (a, b, c, d) is good, then a+b+c+d E
0 (mod 10), since 'r(a) + r(b) + 7(0) + r(d) = 2p E 0 (mod p).
Let
Q(a:)
_ 2'r(:1:) — 'r(2:1:)
—p—,
594
Chapter 8. Solutions to practice problems
in other words Q(a:) = 0 if 1 S r(.7:) S (p — 1)/2 and Q(x) = 1 if
(p — 1) /2 < r(:c) < p. It follows from the first paragraph that
Q(ka,) + Q(kb) + 62060) + Q(kd) = 2
for all 1 S k < p and all good 4-tuples (a, b, c, at).
Next, choose1 a polynomial P(X) with integer coefficients, of degree
at most p — 2, such that P(zc) E Q(:r) (mod p) for all a: not divisible
by p, and define R(X) = P(X + 1) — P(X). Then R(x) E 0 (mod p)
for a: = 1,...,P%3,%1,...,p— 2 and R(%) is not divisible by p. We
deduce from Lagrange’s theorem that the coefficient of X9’3 in R is not
divisible by p and hence the coefficient of X1"2 in P is not divisible by
p. Next, letting
S(X) = P(Xa) + P(Xb) + P(Xc) + P(Xd),
the congruence 8(32) E 2 (mod p) has at least 1) — 1 solutions (by the
second paragraph and the choice of P) and since deg S S p—2, we deduce
from Lagrange’s theorem that S(X) E 2 (mod p), thus the coefficient of
X1“2 in S is divisible by p. Combining the previous observations yields
cup—2 + b"_2 + c"_2 + tip—2 E 0
(mod p),
which can be also written (by Fermat’s little theorem)
a—1 + b‘1 + c-1 + d‘1 E 0
(mod p),
where we write 93—1 for the inverse of a: modulo p. Since a + b+ c+ d E 0
(mod p), it follows that
a—1 + b‘1 + c‘1 E (a + b + c)‘1
(mod p)
and multiplying by abc(a+b+c) we easily obtain (a+b)(b+c)(c+a) E 0
(mod p). By symmetry, we may assume that a + b E 0 (mod p). Since
a+b+c+d E 0 (mod p), we also have c+d E 0 (mod p) and the result
follows.
El
1The existence of such a polynomial follows easily from Lagrange’s interpolation theorem;
see the solution of the previous problem for the simple argument.
8.4.
Cong'r‘uences involving prime numbers
595
37. Let n be a positive integer such that p = 4n + 1 is a prime. Prove that
n" E 1 (mod p).
Proof. We have 477. E —1 (mod p), thus 4" - n” E (—1)” (mod p). It
suffices therefore to show that 4" E (—1)” (mod p). But
_
2_
4" = 2’3+1 a (—1)”—
s =(—1)2"2+"= (—1)" (mod p),
as needed.
El
38. Let p be an odd prime.
Prove that the number of integers n E
{1, 2, ., p— 2} such that n and n + 1 are both quadratic residues mod p
ism—4&4,
Proof. Let N be the desired number and observe that
12—21
N= 2 310+ (2) (1+(”—“))’
n=14
p
since the term indexed by n in the sum is 1 if n and n + 1 are both
quadratic residues mod p, and 0 otherwise. Expanding the product and
rearranging terms yields
N=—+- iguo <—
—>+—z<——>71.
41112
11°2 n+1
1p—2 n(n+l)
411:1
4 n=1
P
P
On the other hand, we clearly have
p—2
_
_
12—2
2 (fl) = -(—1)= +1)? 2 (—”+1) =
n=1
p
p
n=1
p
while proposition 5.111 gives
1§(n(n+1)) ff (n(n+1)) _ _1
n=1
1)
n=1
p
The result follows by combining these relations.
III
596
Chapter 8. Solutions to practice problems
Remark 8.16. One can also establish this result directly, by carefully
analyzing the solutions of the congruence y2 — x2 E 1 (mod p).
39. (Gazeta Matematica) Prove that for any n 2 1 the number 3" + 2 does
not have prime divisors of the form 2419 + 13.
Proof. Suppose that p E 13 (mod 24) is a prime divisor of 3" + 2 for
some n 2 1. Since p E 1 (mod 4) and p E 1 (mod 3), we deduce from
the quadratic reciprocity law that
(gree(:3) = (i) <2) =
However since p E 5 (mod 8), we also compute that
P
P
P
This is a contradiction since 3" E —2 (mod p), but the left-hand side is
a quadratic residue modulo 1) while the right-hand side is not.
El
40. Prove that there are infinitely many primes p E —1 (mod 5).
Proof. Let 'n, > 1 and consider a prime divisor p of N = 507.!)2 — 1
such that p is not congruent to 1. mod 5. Such a prime exists since
otherwise N would be congruent to 1 mod 5, which is certainly not the
case. Since p | N, we have 5 E (571.!)2 (mod p), thus 5 is a quadratic
residue mod p. The quadratic reciprocity law then implies that p is a
quadratic residue mod 5, and since p is not congruent to 1 mod 5, we
must have p E —1 (mod 5). Since p > n, varying n we obtain infinitely
many primes p E —1 (mod 5).
El
41. Let p = a2 + b2 be an odd prime, with a, b positive integers and a odd.
Prove that a is a quadratic residue mod p.
8.4.
Congmences involving prime numbers
597
Proof. It suffices to prove that any prime factor q of a is a quadratic
residue mod p. Note that q aé p and that p E b2 (mod q), thus (g) = 1.
Using the quadratic reciprocity law, we deduce that
(gP ) = (—1)??? = 1,
the last equality being a consequence of the fact that p E 1 (mod 4)
(since p is a sum of two squares). The result follows.
III
42. Let n be a positive integer and let a be a divisor of 36n4 — 8n2 + 1, such
that 5 does not divide a. Prove that the remainder of a when divided
by 20 is 1 or 9.
Proof. It suffices to prove the same statement for each prime factor of
a, thus we may assume that a = p is a prime.
First, since p I (6n2 — 1)2 + (2n)2 and p does not divide simultaneously
6n2 — 1 and 2n, we deduce that p E 1 (mod 4). It remains to prove that
p E 1, 4 (mod 5). Since 1) aé 5, by the quadratic reciprocity law this is
equivalent to showing that (g) = 1, i.e. that 5 is a quadratic residue
mod p. But p | (6n2 + 1)2 — 5 - (2n)2 and p does not divide 2n (otherwise
1) would also divide (in2 + 1, impossible), which makes it clear that 5 is
a quadratic residue mod p. The result follows.
El
43. Are there positive integers 113,31, z such that 8x3; = a: + y + Z2?
Proof. Assume that such integers exist, then they also satisfy
(8a.- — 1)(8y — 1) = 822 + 1.
p is a prime divisor of 8:0—1 or 8y—1, then p | 822+1, thus (42)2 E —2
(mod p) and so —2 is a quadratic residue mod 19. We deduce that p E 1, 3
(mod 8). Since 3-3 E 1 (mod 8), the product of a finite number of primes
of the form 8k + 1 or 8k + 3 is congruent to 1 or 3 modulo 8. We deduce
that 811: — 1 E 1, 3 (mod 8), which is absurd. Thus the equation has no
solutions.
El
598
Chapter 8. Solutions to practice problems
44. (Komal A 618) Prove that there are no integers x, y such that
x3—x+9=5y2.
Proof. Assume that 3:, y are such integers. Note that the left-hand side
is odd and a multiple of 3, thus y must be odd and a multiple of 3, say
y = 3t. Then x3—m+9 E 5y2 E 5 (mod 8), thus a33—a:+4 E 0 (mod 8),
which implies that a: is even and then that 4 | 1:, say a: = 42. Note that
2 must be odd, as a: E 4 (mod 8). The equation can be rewritten
42(16z2 — 1) = 9(5t2 — 1).
Note that 5t2 — 1 is not a multiple of 3 (for any t), thus the highest
power of 3 dividing the right-hand side is 9. Also, one of the numbers 2
and 1622 — 1 must be a multiple of 9 and the other must be relatively
prime to 3. p aé 3 is a prime factor of z or 16z2 — 1, then p | 52?2 — 1,
thus 5 is a quadratic residue mod p. The quadratic reciprocity law (note
that p aé 2 as z and 1622 — 1 are odd) yields p E :|:1 (mod 5). Thus all
prime factors different from 3 of z and 1622 — 1 are :|:1 mod 5. Since 2
is either relatively prime to 3 or of the form 9a with it relatively prime
to 3, we deduce that z E :|:1 (mod 5). It follows that 1622 — 1 E 0
(mod 5), which is impossible since 9(5t2 — 1) is not a multiple of 5. Thus
the equation has no solutions.
El
45. Let p be an odd prime divisor of n4 — n3 + 2n2 + n + 1, for some n > 1.
Prove that p E 1,4 (mod 15).
Proof. Let
f(n) = 4(n4 — n3 + 2n2 +n + 1).
One can directly check the equalities
N?) = (2n2 - n + 1)2 + 3(n + 1)2 = (2722 — n + 3)2 — 5(n — 1)2.
Note that 2n2 — n + 1 cannot be a multiple of 3 and Zn2 — n + 3 cannot
be a multiple of 5. Thus p 75 3, 5. We have
(2n2 — n + 1)2 E —3(n + 1)2
(mod p)
8.4.
Congruences involving prime numbers
599
and p does not divide 3 or n + 1 (if p | n + 1, the previous congruence
yields p | (2 + 1 + 1)2, impossible), we obtain (—373) = 1, which by the
quadratic reciprocity law can be rewritten (g) = 1. Thus p E 1 (mod 3).
Similarly, the congruence
(2n2 — n + 3)2 E 5(n — 1)2
(mod p)
combined with the quadratic reciprocity law yields (1%) = 1, thus p E 1, 4
(mod 5). Combining these we conclude that p E 1, 4 (mod 15).
El
46. Prove that infinitely many primes don’t divide any of the numbers
2"2+1 — 3" with n 2 1.
Proof. Suppose that p > 3 is a prime that divides 2”2"'1 — 3" for some n.
Thus 2‘"2+1 E 3“ (mod p). Note that n and n2 + 1 have difierent parity.
We deduce that (fi) = 1 or (g) = 1. The first case happens if and only
if p E :|:1 (mod 8), while the second case happens (using the quadratic
reciprocity law) if and only if p E :l:1 (mod 12). We conclude that p
must be congruent to one of the numbers 1,7,11,13,17,23 modulo 24.
By Dirichlet’s theorem we can find infinitely many primes congruent to 5
modulo 24, and the previous argument shows that none of them divides
a number of the form 2'"2+1 — 3”.
E!
47. a) (Gauss) Prove that an odd prime p can be written a2 + 2b2 for some
integers a, b if and only if p E 1, 3 (mod 8).
b) (Euler, Lagrange) Prove that a prime p aé 3 can be written a,2 + 31)2
if and only if p E 1 (mod 3).
Proof. a) Suppose first that p = a2 + 2b2. Then a2 E —2b2 (mod p).
Since b is not a multiple of p, we deduce that (—72) = 1, which is equiv-
alent to p E 1,3 (mOd 8).
Conversely, assume that p E 1, 3 (mod 8), so that by the above discussion —2 is a quadratic residue mod p. Let u be an integer such that
600
Chapter 8. Solutions to practice problems
u2 E —- (mod p). Using Thue’s lemma (see theorem 5.59), we can find
integers a,b such that |a|,|b| < fl, a,b are not both 0 and a E ub
(mod p). Then a2 E uzb2 E —2b2 (mod p), thus p | a2 + 2b2. Since
a2 + 2b2 < 3p, we deduce that p = a2 + 2b2 or 2p = a2 + 2b2. In the
first case we are done, so assume that 2p = a2 + 2112, so that a = 2c and
p = b2 + 2c2. This finishes the proof.
b) The proof is very similar to that of a) and we leave the details to the
reader. The key point is that —3 is a quadratic residue mod p if and
only if p E 1 (mod 3) (this follows directly from the quadratic reciprocity
law). This immediately settles one implication. For the more difficult
implication, one uses Thue’s lemma as above to deduce the existence of
integers a, b such that Ia], |b| < (/11 a,b are not both 0 and p I a2 + 3b2.
If p = a2 + 3b2 or 3p = a2 + 3b2, one immediately obtains the desired
conclusion. If 2p = a2 + 3b2 one obtains a contradiction by taking the
relation mod 3.
El
Remark 8.17. Proceeding in a similar (but slightly more technical) way,
one can prove the following result of Lagrange and Gauss: if p 74 5 is a
prime, then p can be written a2 + 5b2 for some integers a, b if and only if
p E 1, 9 (mod 20), and 2p can be written a2 + 5b2 if and only if p E 3, 7
(mod 20). In general, given an integer n > 1 it is a very delicate problem
to describe all primes that can be represented 932 + ray2 for some integers
cc, y.
48. (Moldova TST 2005) Let f, g : N ——> N be functions with the properties:
i) g is surjective;
ii) 2f (rt)2 = 'n2 + g('n,)2 for all positive integers n.
iii) |f(n) — nl S 2004fi for all n E N.
Prove that f has infinitely many fixed points.
Proof. Let pn be the sequence of prime numbers of the form 8k + 3 (the
fact that there are infinitely many such numbers follows from Dirichlet’s
theorem, or from example 5.131). Then (10%.) = —1 for all n. Letting at”
8.4.
Congruences involving prime numbers
601
be an integer such that g(:z:n) = pm we obtain 2f («3,02 = 93% + 12%, thus
2f(a:n 2 E 1,321 (mod p”). Since (52;) = —1, We deduce that pnlxn and
pn | f (can). Thus there exist sequences of positive integers an, bn such that
can = anpn and f(1:n) = up” for all n. Using ii) we obtain 2b% = a3, + 1
and iii) yields
2004>
Tfii>
(_fa;n) _1‘ _ b_n_1’
mu
m;
'
Thus
lim —' a" + 1 = \/§
71—)00
an
and so ”lingo an = 1. Therefore, starting from a certain n onwards, we
have an = 1 = bn, that is f (pa) = pn. The result follows.
III
49. (Romania TST 2004) Let p be an odd prime and let
5(2)
i=1
a) Prove that f is divisible by X — 1 but not by (X - 1)2 if and only if
p E 3 (mod 4);
b) Prove that if p E 5 (mod 8) then f is divisible by (X — 1)2 but not
by (X — 1)3.
f_11 (—)— 0 and
-
Proof. a) Note that f(1)=
p—l
f’(1)=Z(i—l)(%)=2i(%)=:X:(p-i)< p—i)
p
i—l
=(-1)LIZ(p-i)(-)=-(-1)P3_f(l)
602
Chapter 8. Solutions to practice problems
Hence forp E 1 (mod 4) we have f’(1) = 0 and f is divisible by (X—1)2.
If p E 3 (mod 4), then
12—]
.
p—l
f(1)—;2(p) _;2—
2—1
2
_1 (mod2),
2—1
thus f is divisible by X — 1 but not by (X — 1)2.
b) Using part a) we obtain
—1
f”(1) = EM — 32' + 2) (133) = I: 22 (3)
2:1
2:1
p
and we need to show that this is nonzero. We will prove that f” (1) —
(mod 8). Since 2'2(%)—
= 2' (mod 2) and (22' — 1)2=1 (mod 8) for all4
2,
we have
u
f”(1)= 2342(j'f)+§23(2z—1)2(2z 1)
i=1
5452+E(2i;1)=4+2(22p1) (mod8),
i=1
2:1
2:1
:1
since 213
_1 2' = L1 E 1 (mod 2). It suffices therefore to prove the
equality
L1
i<2i—1)=0.
i=1
p
For this, simply note that since p E 1 (mod 4) we have
—‘—2' ))= Z(-)Z(1)
2(1) §(——
since
{1:11 (11;)—
— 0. This finishes the proof.
[I
8.4.
Congruences involving prime numbers
603
50. For an odd prime p, let f (p) be the number of solutions of the congruence
y2 E x3 — cc (mod p).
a.) Prove that f(p) = p for p E 3 (mod 4).
b) Prove that if p E 1 (mod 4) then
is 2:1
f(p)E(-1) 4 (L) (modp).
4
c) For which primes p do we have f(p) = 1,?
Proof. We have
f(p)=p§(1+<x3p_ ))= “263:”
m=0
z=1
a) If p E 3 (mod 4), then for all a: we have
(—“””‘°’;<‘”)=<%>-(”‘3;x>=-<””t”‘>’
thus
so >— <><———>o
and f(P) =
b) Writing p — 1—— 4l, we have (using the binomial formula and the
congruence (1%):
_ a 2 (mod 12))
12—1
273—
2 (p H)
12—1 21
— 2 Z (:l)xp—1+2l—2k(_l)k
21 :
:(x3 —£II)—
m=1
m=1 k=0
=§(_ 1)k(:l)zxp—1+2(l— 1:)
k=0
(mod p).
604
Chapter 8. Solutions to practice problems
Note that
p-1
Exp—1+20—k) E p_1
2 $204“)
1:1
(mod 17)
(”=1
and (by corollary 5.77) the last sum is congruent to 0 mod p unless I = k
(as this is the only case when 2(l — k) is a multiple of p — 1 = 4l, for
0 5 k 3 2l), in which case the sum is congruent to —1 mod p. We
conclude that
10—1
x 3 —a:
2l
2( p )E(-1)’+1(l) (mod 10),
31:1
as desired.
L1
c) Since (—1)p:—3 (p3_1) is obviously not a multiple of p, we conclude that
4
no p E 1 (mod 4) is a solution of the problem. Combining this with part
a) shows that the solutions are the primes of the form 4k + 3.
III
51. Is there a polynomial f of degree 5 with integer coefficients such that f
has no rational root and the congruence f (:0) E 0 (mod p) has solutions
for any prime p?
Proof. The answer is positive, we will show that f(X) = (X2 +3) (X3+2)
is a solution of the problem. Clearly f has degree 5 and no rational root.
p = 2, then f(O) E 0 (mod p), so assume thatp > 2. p E 1 (mod 3),
then a simple calculation using the quadratic reciprocity law shows that
(_?3) = 1 and so there is a: such that x2 + 3 E 0 (mod 10)- Thus the
congruence f (as) E 0 (mod p) is solvable in this case. Suppose now that
p E 2 (mod 3), then the map cc I—> 3:3 (mod p) is bijective (see theorem
5.29), so the congruence $3 + 2 E 0 (mod p) is solvable. Thus f is a
solution of the problem.
El
Remark 8.18. For more details on this problem, the reader can consult
the article "Polynomials (x3 —n) (51:2 +3) solvable modulo any integer'I by
A. M. Hyde, P. D. Lee and B. K. Spearman, published in the American
Mathematical Monthly, vol. 121, no. 4, p. 355-358.
8.4.
Congrnences involving prime numbers
605
52. Let p be an odd prime and let a, be an integer not divisible by 19. Let
N (a) be the number of solutions of the congruence y2 E x3+am (mod p)
and let
1
3(a) = z ( k3 + ak ) .
p_
Ic=0
p
1) Prove that N(a) = p + 3(0).
2) Prove that if p E 3 (mod 4) then 3(a) = 0 for all a, hence N(a) = p.
We assume from now on that p E 1 (mod 4).
3) Prove that if b is not a multiple of p, then
2
S(ab ) =
b
5 3(a).
4) Prove that
12—1
2 3W = 21000 — 1)
a=0
and that if A = S(—1) and B = 3(a) for any quadratic non-residue a,
then
A2 + 32 = 4p.
5) Prove that A E —(p + 1) (mod 8).
6) Deduce the following theorem of Jacobsthal: let p E 1 (mod 4) be
a prime and write p = a2 + b2 with a, b integers, a odd and a E —%1
(mod 4). Then the congruence y2 E m3 — a: (mod 1)) has p+ 2a solutions.
Proof. 1) This is clear, since for each a: the congruence y2 E 9:3 + as:
(mod p) has 1 + (3—3:?) solutions.
2) Since
(p-k)3+a(p— k) E —k3 —ak = —(k3 +ak)
(mod p)
606
Chapter 8. Solutions to practice problems
and p E 3 (mod 4), we obtain for all k
(p—k)3+a.(p—k)
p
_(_—_1)
k3+ak
p
__
p
k3+ak
p
'
Adding these relations for k = 0,1,...,P;—1 gives 5(a) = 0 and N(a) =
3) Since the remainders of 0, b, 2b, ..., (p — 1)b when divided by p are a
permutation of O, 1, ..., p — 1, we obtain
(M) =95 (m3 + am)
) if
f (M
SW) = 19:0
1"
1)
k=0
19
k=0
=(3>,§,('°3Z“k)= (20)“)
4) We have
Ewe j; 2:610?) - (é) ~ (”J")
_:Z=O(k_l):((k2+a;(l2+a)).
a=0
For fixed k, l, the mner sum Za-O (W) equals —1 when k2 and
l2 are not congruent modulo p and p— 1 otherwise, by proposition 5.111.
It follows that
WW
a=0
Next, we have
2
($35 (fl)-
OSkJSp—l, 1:251? (mod p) p
k,l=0 p
8.4.
Cong'ruences involving prime numbers
607
Finally, note that if k2 E l2 (mod p) and k,l are not multiples of p, then
(1;!) = 1, since k E :l:l (mod p) and (_?1) = 1. It follows that
22
(fl) =2(p—1)
OSkJSp—l, #512 (mod p) p
and so
13—1
2 3(a)2 = 2p(p — 1).
(1:0
The second part follows, since S(a) = A whenever (g) = 1 and S(a) = B
Whenever (1%) = —1, thus
p—l
Z 3(a)2 = 5(0)2 + (p — 1)(A2 + B?) = (p — 1)(A2 + 32).
0:0
5) This is fairly tricky. Note that
A=§(k3£kl=§(k—;i)-(S)°($)Next, consider the expression
E=§(l+(%))'(1+(S))-(1+(’%1))’
and note that for k aé 0, 1, p— 2 the corresponding term in the sum is the
product of three even numbers, thus a multiple of 8. When k = 0, 1, p— 1
we use the fact that (%1) = 1 to obtain
EE4+4(1+ (1%)) E4
(mod 8).
608
Chapter 8. Solutions to practice problems
On the other hand, brutally expanding we obtain (using proposition
5.111)
p—l
je{—1,0,1}k=0
=p+
.
k
Z z(_fl)+
E=p+
1’
Z
p—l
.
.
k
k
2(M)+A
i<je{—1,0,1}k=0
1"
2 0+
2
(-1)+A=p—3+A.
je{—1,0,1}
i<jE{—1,0,1}
Thus p — 3 + A E 4 (mod p), which yields A E —(p + 1) (mod 8).
6) It is immediate to check that A and B are even numbers, hence
(32+ ($2
is the unique way to write p as the sum of two squares, up to sign. The
previous part determines uniquely A and the result follows easily.
[:1
53. (Mathematical Reflections) Find all primes p with the following prop-
erty: whenever a, b, c are integers and p I azb2 + b2c2 + c2a2 + 1, we also
have p | a2b2c2(a2 + b2 + 62 + 0.211202).
Proof. This is a very difficult problem! The answer is 2,3, 5, 13 and 17.
Define X1 (p) as the set of solutions in {0, 1, ...p — 1}3 of the congruence
(12b2 + b2c2 + 020,2 + 1 E 0 (mod p), and similarly let X2 (13) be the set of
solutions of the congruence a2b2c2(a2 + b2 + 02 + (121,262) E 0 (mod p).
We want to find all primes p for which X1 (p) C X2 (p).
First, we prove that 2, 3, 5,13 and 17 are solutions of the problem. Sup-
pose that (a, b,c) e X1(p) \ X2(p) for some prime p. Letting a: = a2,
y = b2, 2 = 02, it follows that x,y,z are quadratic residues modulo p,
my + yz + za: + 1 E 0 (mod p) and wyz(x + y + z + xyz) is not divisible
by p. Since
e(xy+yz+zx+1)+(x+y+z+myz)=(w+e)(y+e)(z+s)
for a = :|:1, we deduce that x, y, z are not equal to 0 or :|:1 modulo p. This
already excludes the cases p = 2, p = 3 and p = 5. Moreover, we cannot
8.4.
Congruences involving prime numbers
609
have a:+y E 0 (mod p) (and similar congruences obtained by permuting
the variables as, y, 2), as otherwise we would also have $y+1 E 0 (mod p)
and then m+y+z+xyz E 0 (mod p), a contradiction. Similarly, we cannot have (cg/+1 E 0 (mod p) (and similarly with permutations of :13, y, z).
Finally, :2, y, z must be pairwise distinct if p 6 {13,17}, for one tediously
checks that for these primes the congruence m2 +2zx+ 1 E 0 (mod p) has
no solutions with m, z quadratic residues modulo p different from 0, :|:1.
Using these observations and the fact that the quadratic residues modulo
13 (respectively 17) are 0, :|:1, :|:3, :|:4 (respectively 0, :|:1, :|:2, :l:4, :|:8),
one easily (but tediously!) checks that there are no triples (:13, y, z) with
all the previous properties. It follows that 2, 3, 5, 13 and 17 are solutions
of the problem.
Next, we prove that if p > 3 is of the form 4k+3, then X1 (p) is nonempty
and disjoint from X2 (p), hence p is not a solution of the problem. Pick
an integer c such that c2 is not congruent to 0 or 1 mod p (such c exists,
since p > 3). Note that if a E {0,1,...,%1}, then p does not divide
a2 + 02 (as p E 3 (mod 4) and p does not divide 0), thus we can define
a map f by imposing f : {0,1, ..., ’3—1}—>{0,1,...,p — 1},
f(a)(a.2 + c2) E —(a2c2 + 1)
(mod p).
We claim that this map is injective. Indeed, if f (a) = f (a1), then an
easy computation gives (a2 — (1%)(04 — 1) E 0 (mod p), hence a E a1
(mod p) (because c2 :I: 1 are not divisible by p). Since f is injective and
since there are %1 quadratic residues mod p, it follows that there are
a,b E {0, 1, ...,p — 1} such that f(a) E b2 (mod p), which is equivalent
to (a, b, c) E X1(p). Hence X1(p) 75 (0.
Next, suppose that (a, b, c) E X1(p) fl X2(p). Since p E 3 (mod 4),
p does not divide abc, hence (12(b2c2 + 1) + b2 + c2 E 0 (mod p) and
a2(b2 + c2) + b2c2 + 1 E 0 (mod p). This yields (a4 — 1)(b2 + c2) E 0
(mod p), then a,2 E 1 (mod p) and finally (1 + b2)(1 + c2) E 0 (mod p),
a contradiction with p E 3 (mod 4).
Finally, suppose that p E 1 (mod 4) and p > 17. We will construct an
element of X1 (p) which is not in X2(p), finishing the solution. Since
610
Chapter 8. Solutions to practice problems
p E 1 (mod 4), there exists a: e Z such that x2 + 1 E 0 (mod p). We
will need the following
Lemma 8.19. The congruence a2 + ab + b2 E a: (mod p) has at least
p — 1 solutions.
Proof. Write the congruence as (2a + b)2 + 3b2 E 43: (mod p). So it is
enough to prove that the congruence u2 + 3v2 E t (mod p) has at least
p — 1 solutions when p does not divide t. But the number of solutions is
p + 20:, (#) and the result follows from proposition 5.111.
El
Now let S be the set of solutions of the previous congruence. For each
(a, b) 6 S we have an element (a, b, c) of X1 (p), where c = —a—b. Indeed,
a2b2+b2c2+cza2+1E (ab+bc+ca)2+1E(a2+ab+b2)2+1
Ex2+1E0
(modp),
hence (a, b, c) 6 X1 (p) Now we bound the number of these elements
that lie in X2(p). Suppose that (a, b, c) e X2(p). If a E 0 (mod p), then
b2 E m (mod p) and (a, b) takes at most two values mod p. Similarly the
cases b E 0 (mod p) and c E 0 (mod p) yield each at most 2 values for
(a, b) mod p, hence we have at most 6 elements of this form in X2 (p).
The other possibility is that a2 + b2 + c2 + azbzc2 E 0 (mod p). Since
a2+b2+0252(a2+b2+ab)52$ (modp)
and
a202 E (a(a + b))2 E (:1: — b2)2
(mod P),
we obtain 2:1: + b2 (a: — b2)2 E 0 (mod p). This congruence has at most
6 solutions by Lagrange’s theorem, and each solution b corresponds to
at most two pairs (a, b). Hence X2(p) contains at most 12 elements
this type. Thus in total X2(p) contains at most 18 of these elements
X1 (p). Since p > 17 and p E 1 (mod 4), we have at least one element
X1 (p) which is not in X2(p).
of
of
of
El
8.4.
Congruences involving prime numbers
611
54. Let n be a positive integer and let p 2 2n + 1 be a prime. Prove that
2n _
n =(—)4“ L;n (mod 2»).
Proof. We have
(277,) = (2n)! _2-4-...'(2n).1-3-...-(2n-1)
n
n!2
n!
n!
= 2n .1-3-...-(2n—1)
n!
Since n < p we have gcd(n!, p) = 1 and so the desired congruence is
equivalent (after multiplication by n! and division by 2") with
1-3~...-(2n—1)E(—2)”op—;—1(p%1 — 0.41% — 71+ 1) (mod p).
This congruence follows by multiplying the congruences
—1
(—2) (I’T—j)
E2j+1
for 0 g j S n — 1.
El
55. (Mathematical Reflections 0 96) Prove that if q 2 p are primes, then
m ' ( p ) (2»)
P+q
—
q
— 1.
Proof. If p = q, this comes down to (if) E 2 (mod p2) and has already
been proved (see example 5.157). So suppose that q > p. By Vandermonde’s identity
(T)=(Z) (3)1401) (i)+-~+(€) (Z)
and each term in the sum except for the first and last one is a multiple
of pq.
Cl
612
Chapter 8. Solutions to practice problems
56. (Hewgill) Let n = no +2n1 + +2dnd be the binary representation of an
integer n > 1 and let S be the subset of {0,1,...,n} consisting of those
k such that (2) is odd. Prove that
Z 2’6 = Palominfld,
IceS
where Fk = 22k + 1 is the kth Fermat number.
Proof. By Lucas’ theorem, the elements of .S’ are precisely those
k = k0 + 2k1 +
+ 2%,, e {0, 1, ...,n}
with 0 g kz- 3 n1- for all 0 S i S d. We deduce that
no
n1
E 2k = Z z
z 2ko.22k1.....22‘ka = E 2k0
”.1
n0
Z 22% .
1665
kd=0
ko=0
kd=0
160:0 k1=0
”:1
It suffices to observe that since no, ..., nd 6 {0, 1}, we have
no
M
d
ko=0
kd=0
d
2 2k = (2+ 1)"°,..., Z 22 k4 = (22 + 1)"d.
57. (Calkin) Let a be a positive integer and let
i=icf
19:0
for n 2 1. Let p be a prime, n an integer greater than 1 and let
n=no+pn1 +...+pdnd
be its base p representation. Prove that
d
xn E H mm.
i=0
(mod p).
E]
8.4.
Congruences involving prime numbers
Proof. Clearly
613
a
n
sons 2 (k)
(modp),
1663!:
where Sn is the set of those k 6 {0,1, ..., n} for which p does not divide
(71:). By Lucas’ theorem the set Sn consists of the numbers
k : k0 +pk1 +
+pdkd
with 0 S k,- 3 7n for all 0 S i S d, and moreover for each k E S we have
d
(Z)EH(7I::)
(modp).
We obtain therefore
mi": "2H(”1“) =H(i( ))=m (mom
ko=0 k1 =0
i=0
kd=0 i—O
i=0
Isa-=0
as needed.
I]
58. Let p be a prime and let [6 be an odd integer such that p — 1 does not
divide k + l. Prove that
17—1 1
Z ,—k E 0
(mod p2).
i=1 3
Proof. It sufiices to prove that
11—11
22—
73' 50
(mod p2).
j=1'7
But
—1
—1
22%: 296+ —j_)k)= flirt—1.52
j=
=1]
k
2:1
k
614
Chapter 8. Solutions to practice problems
and since k is odd, the binomial formula gives
1' + (p— j)'°= km" 1 (mod 102)
It suffices therefore to prove that
19-1
1
;j@—— j)’“ =0
(modp)
or equivalently that
P—1
1
i=1
This follows from proposition 5.149.
E]
59. (’I‘uymaada 2012) Let p = 4k + 3 be a prime and write
02+1
12+1
(p—1)2+1”n
for some relatively prime numbers m, n. Prove that p | 2m — 77..
Proof. Since 12 E 3 (mod 4), the numbers 02 + 1,12 + 1, ..., (p — 1)2 + 1
are not multiples of p by corollary 5.28. Next, we argue as in the proof
of Wilson’s theorem, by creating pairs of the form (13,11) with 93,11 6
{2, 3, ..., p — 2} uniquely determined by my E 1 (mod p). Note that for
such a pair (cc,y),
1
1
_
=
1
1
x2+1+y2+1 952+1+1+1 :1 (mOdp)
Since the congruence x2 E 1 (mod p) has no solutions in {2, ..., p — 2}
we deduce that
1
1
—
..
——
22+1+ +(p—2)2+1
p—3
—
2 (md p)’
8.4.
615
Congruences involving prime numbers
hence
07E?+FL+T+.H+WEP%3+1+2%=I%I
(modp)
The result follows.
III
60. (IMO Shortlist 2012) Find all integers m 2 2 such that n I (mf2n) for
any integer n 6 [%, %].
Proof. We will prove that the solutions of the problem are exactly the
prime numbers. If m is a prime number, then for any n E [%, 123] the
number
n
n— 1
(m_2n)(m—2n) _n(m—2n— 1)
is a multiple of n and since gcd(n, m — 2n) = 1 we obtain n | ( m—2n)'
"
Conversely, let m be a solution of the problem. If m is even, choosing
n = % yields % | 1 and so m = 2. Assume that m is odd and let us
suppose that m is composite. Then the smallest prime factor 1) of m is
less than or equal to %. Let n = ”—272, so n 6 [%, %] and by assumption
n I (Z). We obtain pl (n — 1)(n — 2)...(n —p+ 1), impossible since pl 72..
III
Thus m must be a prime number.
61. (Putnam 1991) Prove that for all odd primes p we have
i (Z) (pl-k) E 2" + 1
(mod p2).
k=0
Proof. For 1 S k Sp— 1 we have
+2... (p+ k >51 (map)
(pk+19)=(p +1 )(pk!)
616
Chapter 8. Solutions to practice problems
and (2) E 0 (mod 1’); hence (1,2) (pile) E (2) (mod p2). Thus the congruence is equivalent to
11—1
1 + (2p) + Z (Z) E 2p+ 1
p
(mod p2)
Ic=1
and then (using the binomial formula) to (2:) E 2 (mod p2). This has
already been established in example 5.157.
[I
62. (ELMO Shortlist 2011) Prove that if p is a prime greater than 3 then
L1
22: (Z) 3'c E 2" — 1
(mod p2).
k=0
Proof. We have for 1 S k g %1
(Z) 5 £61)“ a 2(—1)’°2£k(—1)2k-1 E 2(—1)k(2’;) (mod p2).
The congruence is thus equivalent to
22
1+2i<2€c)(—3)’°+1s2P—1 (modp2)
[6:1
or
L1
22
p)-3kE2p
md p)2.
5(2“
>
(o
Let a = 2V5 E C, then —3 = a2 and the binomial formula yields
2]; (212)03’“ = (1 + a)? + (1 — 001'.
The result follows now from the equality (1 +.a)p + (1 — a)? = 21’, which
itself follows from 1 + a = 26%, 1 — a = 23"?" and (303(133) = %
|:|
8.4.
Cong’mences involving prime numbers
617
63. (IberoAmerican Olympiad 2005) Let p > 3 be a prime. Prove that
13—1 1
Z 5 E 0 (mod p3).
i=1
Proof. Let 5' denote the left-hand side. Then
12—1
28' =
1
13—1 .
1
(T‘ + —.) =
7,?
g
.
z? + (p - 2)?
(13—1,)?
2;
.—.—-
1,?(p-1)?
Using the binomial formula we obtain
2'” + (P - z')" E 102(—13)”‘1 = 1,221.4 (mod 103),
thus it suflices to show that
P—1
1
.—.
1.; 1.(p — 7.)?
E0
(
mod p .
)
Since (p — i)p E p —i E —z‘ (mod p), we are further reduced to showing
that
P—1 1
i—z E 0
(mod 1)),
i=1
which has already been established in proposition 5.149.
64. (AMM) Let 0,, =
; (2:?)
n+1
be the nth Catalan number. Prove that
01+02+...+CnE 1
(mod 3)
if and only if n + 1 has at least one digit equal to 2 in base 3.
Proof. One easily checks the equality
2k+2
2k
(k+1) _4(k) ‘_20’“’
III
618
Chapter 8. Solutions to practice problems
which shows that
Ck
216 + 2
2k
(k+1)— (k)
(mod3).
It follows that
2 2
2
2 2 (mod3).
01+02+...+0na(:i1)—(1)=1+(::1)
Thus we need to prove that 3 | (27”? if and only if 71+ 1 has at least one
digit equal to 2 in base 3. This follows directly from example 5.146.
III
65. Prove that for any prime p > 5 we have
P‘1 1
1+pZ—
2
P—1
1
E 1—1222—2
k=1 k
(modps).
k=1 k
Proof. Letting
p_1 1
11?] = E g,
16:1
the congruence is easily seen to be equivalent to
2901 + p(x% + 172) E 0 (mod p4).
Since x1 E 0 (mod p2), this further reduces to 2.181 + pxg E 0 (mod p4).
Note that
2x1=1E<IIc+p—lk)=pzk—2(l—%)
Note2 that if z E 0 (mod p) then
1—(1—z)(1+z+z2)=z3E0
2This is motivated by the identity fi = 1 + z + 22 +
(modp3),
8.4.
Congruences involving prime numbers
thus
619
1
i E 1+z+z2
(modp3).
Combining this with :33 E 0 (mod p2) (see example 58) and 5134 E 0
(mod p), we obtain
p—1
2
k 1 i
k2
k2
296 1 E -pz
1 + 2k + E= -px2—p2m 3 -p3w4 E -pm2 (mod p4) i
III
as desired.
66. (USA TST 2002) Let p > 5 be a prime number. For any integer 1:, define
P—1
1
fp(-”3) = Z _'
16:1 (pa: + k)2
Prove that fp(a:) E fp(y) (mod p3) for all positive integers x, y.
Proof. Observe that
_1__ _ i . _1_
(m + k)? ‘ k2 (1 +12%»?
The identity
fl = 1+2z+3z2+...
suggests the congruence
1
whenever z E 0 (mod p). Once we guess that this is true, it is very easy
to prove it: an explicit computation shows that
1 — (1 — z)2(1 + 22 + 3z2) = 4z3 — 324 E 0 (mod p3).
620
Chapter 8. Solutions to practice problems
We deduce that
f(a:)EZk1—2-
2_Zk2(1_
a:
2:132
(1—2—2—+31;62 ) (modp3).
Since
p—11—1
Z—
k3 E0 (mod p2)
and
23—194 _
=0
(mod p),
we conclude that
P—1
1
to) a 2: p a my) (mod p3)
16:1
for all :r, y, as desired.
8.5
El
p-adic valuations and the distribution of primes
(Russia 2000) Prove that there is a partition of N with 100 sets such
that if a, b, c E N satisfy a + 99b = c, then at least two of the numbers
a, b, c belong to the same set.
Proof. Let the ith class consist of those n for which 122 (n) E 2' (mod 100)
for 1 S 2' g 100. If a + 99b = c, then necessarily 122(a),v2(b),'02(c) are
not pairwise distinct (if v2(a) 7E v2(b), the strong triangle inequality
gives 122(0) = min(v2(a),v2(99b)) = min(v2(a),vg(b))), and the result
follows.
III
(Iran 2012) Prove that for any positive integer t there is an integer n > 1
relatively prime to t such that none of the numbers n+t, n2 + t, n3 + t,
is a perfect power.
Proof. Let p be a prime divisor of t + 1 and let k = vp(1 + t). We choose
72 such that n E 1 (mod 12"“), then nj + t E 1 + t (mod pk“) for all
8.5. p-adic valuations and the distribution of primes
621
j 2 1, thus vp(nj + t) = k. Assume that nj + t is a perfect power, then
by the previous relation it must be of the form (11" for some a > 1 and
N | k. Take now n = 51:"! with a: E 1 (mod pk“). If nj + t = a” then
N =t+bN, where b=xkfi!. Thus a 2 b+1 and then
t2(b+1)N—bN>Nb>a:.
Choosing :1: > t and n as above yields therefore a solution of the problem.
El
3. Prove that if n, k are positive integers, then no matter how we choose
signs :I:
1
1
:|:— :l: — :l:
k
k+1
1
:I: —
k+n
is not an integer.
Proof. Let
7 = K313313220)
and fix j e {k,.. .,k + n} such that 122(9): 7. We claim that there is
no other 3" E {k,.. .,k + n} such that 122(3’) = 7'. Indeed, otherwise we
may assume that j’ > 3', then writing j = 2’ - a, j’ = 2" - b with odd
integers a, b, we have 1:: S 2'a < 2'b S k +n. But then 2’ (a + 1) belongs
to {k, ..., k + n} and v2(2'(a + 1)) Z 7‘ + 1, a contradiction.
Thus there is a unique j 6 {k, ..., k + n} with 222(j) = 7 being maximal.
It is now easy to conclude: we can write
1
i—k :l: L
in.:l:
—
= 5y i1j
k+1
k+n
with 513,31 integers such that 772(y) < 7'. Since v2(j)—
— 7', it is clear that
Q j =fl cannot be an integer: the numerator is nonzero (as v2(y) <
222 (xj)) and has smaller 2—adic valuation than the denominator!
El
4. (Romania TST 2007) Let n 2 3 and let a1, ...,an be positive integers
such that gcd(a1,...,a.n) = 1 and lcm(a1,...,an) | a1 +
that a1a2...a.n divides (a1 + a2 +
+ an)"_2.
+ an. Prove
Chapter 8. Solutions to practice problems
622
Proof. It suffices to prove that for any prime p we have
vp(a1...an) S (n — 2)'vp(a,1 +
+ an).
Let as, = 1),, (a5) and assume without loss of generality that $1 2
2 run.
Since gcd(a1, ...,an) = 1, we must have 11:1, = 0. Also, by hypothesis
vp(a1 +
+an) _
> 11151531“-.
If mn_1 75 0, then a1, ...,an_1 are multiples ofp and p | lcm(a1, ...,an) |
(11 +
+ an, a contradiction with the fact that p does not divide an.
Thus xn_1 = 0. It is then clear that
vp(a1...a,,,) = $1 +
+ (3,, = $1 +
S vp(a1 +
+ xn_2 S (n — 2) Egan
+an),
as desired.
D
(Erdos-Turan) Let p be an odd prime and let S be a set of n positive
integers. Prove that one can choose a subset T of .S' with at least [g]
elements such that for all distinct elements a, b E T we have
11,,(0. + b) = min('up(a), 'vp(b)).
Proof. Let (11 <
< an be the elements of 8'. Set k,- = vp(ai) and
let a,- = pk‘bi with b,- > 0 not divisible by p. Let I (respectively J)
be the set of those 2' 6 {1,2, ...,n} for which the remainder of b,- when
divided by p is smaller (respectively larger) than 1%. Clearly, if 2', j E I
or 2', j E J are distinct then b,- + bj is not a multiple of p. One of the
sets I, J has at least lg] elements. Without loss of generality, assume
that this set is I. Let T = {oil 2' E I}. Ifz' # j G T and if k, 7E 19,-, then
'vp(a,- + aj) = min(vp(a,,-),vp(aj)), so assume that k,- = kj. Then
vp(a,; + a,-) = k; + ’Up(bi + bj) = kg = min(k.;, kj),
as desired.
El
8.5. p-adic valuations and the distribution of primes
623
6. (Ostrowski) Find all functions f : Q —> [0, 00) such that
i) f(x) = 0 if and only ifa: = 0;
ii) f(961/) = f(w) - f(y) and f(x + y) S maX(f(-'v), fly» for all m, 2/Proof. First of all f(1) = f(1)f(1) and f(l) > 0 (by i)), thus f(1)= 1.
Similarly, we obtain f(—1)2 = 1 and f(—1) = 1. In particular f (—23) =
f(w) for all :3. Since f(n) g max(f(n — 1),f(1)) = max(f(n — 1), 1) for
all n 2 2, an immediate induction yields f (n) S 1 for n 2 1, and since
f(—a:) = f(x), we obtain f(x) 3 1 for :1: e Z.
Suppose first that f(n) = 1 for all nonzero integers n. Then for any
a: E Q* we can find n E Z* such that ms 6 Z*, thus 1 = f(nx) =
f(n) f(w) = f(:12) and f(x) = 1 for all nonzero cc. This function is indeed
a solution of the problem.
Suppose now that there is n E Z* such that f(n) aé 1, Le. f(n) < 1.
Take the smallest such positive integer n.
Then n > 1, and if n is
composite, say it = ab, then f(a)f(b) < 1 forces f(a) < 1 or f(b) < 1,
contradicting the minimality of n. Thus n = p is a prime. We claim
that f(n) = f(p)”P(") for all n. Since both f and f(p)”P are totally
multiplicative, it suffices to check this for primes n. If n = 1) this is
clear, so assume that n is a prime different from p. Then we can find
integers a, b such that 1 = an + bp, thus
1 = f(1) = f(an + bp) S maX(f(a)f(N),f(b)f(P))Since f (b) f (p) S f (p) < 1, it follows that f (a) f (n) 2 1 and since
f(a),f(n) S 1, we must have f(a) = f(n) = 1. Thus f(n) = 1 for all
primes n 7A p and the claim is proved. We deduce that for any a: = %
we have
m #2:; jam-w
Conversely, if a 6 (0,1) and p is a prime, setting (for nonzero integers
mm)
f (E) = vp(m>—vp(n>
n
624
Chapter 8. Solutions to practice problems
yields a solution of the problem, using the basic properties of the opmap.
[I
Find all integers n > 1 for which
n” | (n — 1W“ + (n + on“.
Proof. If n is a solution of the problem, then 72. | (n— 1)""+1 + (n+ 1)"n—1.
If n is even, then
(n — 1)"‘"+1 + (n + 1)
nn—l
E (—1)""+1 + 1 E 2
(mod 77.),
thus n = 2 and one easily checks that this is not a solution. So all
solutions must be odd. Conversely, we will prove that odd numbers are
solutions of the problem, by proving that when n is odd we have
n“ | (n — 1)"‘n+1 + 1 and n” I (12+ 1)”"_1 — 1.
Let p be a prime divisor of n. Then p is odd and by the lifting the
exponent lemma
vp((n- 1)”"+1 +1) = vp(n)+vp(n"+1) = (n+2)vp(N) > TWA”) = W“)
and
_1
vp((n + 1)”"
— 1) = vp(n) + 'vp(n”_1) = 111,01").
The result follows.
III
(Mathlinks Contest) Let a, b be distinct positive rational numbers such
that a” — b” E Z for infinitely many positive integers n.
a, b E Z.
Show that
Proof. By taking a common denominator of a, b, we are reduced to proving the following statement: if a,b,c are positive integers with a aé b,
and if c” | a" — b” for infinitely many n, then c | a and c | b. By working
with each prime factor of c separately, we easily reduce to the case when
c is a prime. Thus we need to prove the following statement: if a, b are
8.5. p-adic valuations and the distribution of primes
625
distinct positive integers and p" divides a." — b" for infinitely many n,
then p divides a and b. To prove this, assume that p does not divide a,
so it does not divide b either. But then
”Ida” — b") S ”p(a(p_l)n — b(p_l)n) S ”p(a2(p_1) — 5207—1)) + 1’p("")
3 c1 + C2 logn
for two constants c1, 62 depending only on a, b, p. As the last quantity is
smaller than n for large enough 71., the result follows.
III
. (Saint Petersburg) Find all positive integers m, n such that mnlnm — 1.
Proof. Let p be the smallest prime factor of m. Then p divides 729—1 — 1
(note that p does not divide n since p | n’" — 1) and also nm — 1, thus p
divides n3°d(m’1"1) — 1 = n — 1. Next, suppose that p > 2, then lifting
the exponent lemma yields
n’vp(m) 3 ”12mm — 1) = ”pm — 1) + ”170”),
from which n — 1 S vp(n — 1), that is n — 1 2 p ‘1 2 371—1, impossible.
So p = 2 and n is odd. Then using the lifting the exponent lemma again
yields
nvg(m) S v2(nm — 1) = 12207.2 — 1) — 1 + v2(m),
thus (n —- 1)v2(m) g v2(n2 — 1) — 1. It is not diflicult to see that this
implies n2 — 2 2 2"—1 and so that n = 3 and v2(m) = 1. Next, m3
divides 3m — 1. Suppose m > 2 and let q be the smallest prime factor of
m/2. Then q is odd and q divides 93°d(q—1’m/2) — 1 = 8, a contradiction.
Thusn=3andm=2.
III
10. (Balkan 1993) Let p be a prime and let m 2 2 be an integer. Prove that
if the equation
zP+yP _ (x+y)"‘
2
2
has a positive integer solution (a), y) aé (1, 1), then m = p.
626
Chapter 8. Solutions to practice problems
Proof. Suppose first that p = 2 and m 2 3. Then
(:1;+y)2 > 232+y2 _ (x+y)m > (x+y)3
2
2
_
2
—
2
’
which gives :I:+y < 4. Since (2:,y) 75 (1,1), we must have a: = 1,3; = 2 or
a: = 2, y = 1 and in both cases it is easy to check that the given relation
cannot be satisfied.
Assume now that p > 2. The function a; I—> 11:? being convex on [0, oo),
Jensen’s inequality yields
P
P
P
$_+y_2
(My),
2
2
which combined with the given relation yields m 2 p > 2.
Letting
a: = du, y = do, with gcd(u, v) = 1, the given relation can be written as
dm‘p(u + v)m = 2m‘1(up + up).
If u + v has an odd prime factor q, then lifting the exponent lemma and
the previous equality give
q(u + v) = vq(up + up) = vq(p) + vq(u + v) S 1 + vq(u + 'v),
a contradiction with m > 2. Thus it + v is a power of 2 and so
v2(u" + up) = v2('u. + 12),
since 1) is odd. But then
mv2(u+v) S v2(u+'v) +m — 1,
yieldingu+v=2,thenu='v=1,x=yandfinallym=p.
El
11. (China TST 2004) Let a be a positive integer. Prove that the equation
n! = ab — a6 has a finite number of solutions (n, b, c) in positive integers.
8.5. p-adic valuations and the distribution of primes
627
Proof. Let (n, b, c) be a solution. Note that a > 1 and let p be an odd
prime not dividing a. Using lifting the exponent lemma and Fermat’s
little theorem we obtain
ups" — a6) = «lamb-c — 1) s vamp-1W — 1) = vp(a”‘1 — 1) +vp<b— c).
We conclude that
vp(ap‘1 — 1) + vp(b — c) 2 'vp(ab — a”) = vp(n!) > g — 1.
Therefore vp(b — c) 2 g — k, for some constant k independent of n.
Letting e = 12"“ > 0, we conclude that b — c 2 epn/P and so
n" > n! = ab — a6 > ab'c Z a‘pn/p.
Taking logarithms, we deduce that n is bounded in terms of a. Since
III
c, b — c < 71!, the result follows.
12. (China TST 2016) Let c, d be integers greater than 1. Define a sequence
(an)n21 by a1 = c and an+1 = a: +c for n 2 1. Prove that for any n 2 2
there is a prime number p dividing an and not dividing alaz...an_1.
Proof. Suppose that for some n > 1 there is no such prime p. Take any
prime factor p of on. By assumption there is some j < n such that p | aj.
Take the smallest such j. We claim that j | n. Indeed, aj+1 = ag+c E (11
(mod p) and an immediate induction shows that aj+u E on (mod p) for
all u 2 1, Le the sequence (an)n21 is periodic with period j modulo p.
Writing the Euclidean division n = qj + r and assuming that r > 0, we
obtain a, E aqj+r = on E 0 (mod p), thus p | or. This contradicts the
minimality of j, thus 3' | n.
Next, we claim that vp(an) = vp(aj). Let r = vp(a,j). Then
obj-+1 = a}; + c E c = (11
(mod 1)”)
and again an immediate induction shows that (an)n21 becomes periodic
with period j modulo 1)”. In particular, since 3' | n, we have an E a,-
(mod 10‘”). Since vp(aj) = r < dr, this gives vp(an) = r, as claimed.
628
Chapter 8. Solutions to practice problems
The above paragraphs show that for each prime p I an we can find jp < n
such that 'up(an) = vp(ajp). This implies that an divides alaz...an_1, in
particular an s a1a2...an_1. But an immediate induction shows that
an > a1...an_1 for n 2 2. Indeed, this is clear for n = 2 and if it
holds for n, then the inductive hypothesis combined with the recurrence
relation yield (using that d > 1)
an“ = of, + c > of, > ag—l -a1...an_1 2 a1a2...an.
This contradiction shows that our assumption was wrong, so there is at
least one prime dividing an and not dividing a1a2...an_1.
I]
13. (Kvant M 1687) Find the largest possible number of elements of the set
{2” — ll 72. E Z} that are terms of a geometric progression.
Proof. We will prove that a geometric progression cannot contain more
than 2 elements of the set S = {2" — 1| n E Z} (which will show that
the answer of the problem is 2). Suppose the contrary and set (for some
pairwise distinct integers a, b, c)
2“ — 1 = alqa, 2" — 1 = alqfi, 2c — 1 = alq",
where a > [3 > 'y 2 0. Take positive integers m and n, n > m, such that
n(fl — 'y) = m(a — 7). Then one easily checks that the previous equalities
yield
(2" — 1)" = (2“ — 1)m(2° — 1)n-m.
Using the identity 23(2_‘” — 1) = 1 — 2"” and taking absolute values we
get an equality of the form
(23 _ 1)'n = (2A __ 1)m(2C _ 1)n—m,
where A, B, C are pairwise distinct positive integers. This immediately
implies that max(A, C) > B. On the other hand, the previous equality
implies that any prime factor of 2A — 1 divides 2B — 1 and similarly any
prime factor of 2C — 1 divides 2B — 1. We may assume that A > B.
8.5. p-adic valuations and the distribution of primes
629
Any prime factor of 2A — 1 divides 2B — 1 and so it divides 2d — 1, where
d = gcd(A, B) < A. Since 21— 1 | 2A — 1, it follows that 2d— 1 and 2A— 1
have the same prime divisors. This contradicts the result established in
example 6.31.
III
14. (Iran TST 2009) Let a be a positive integer. Prove that there are infinitely many primes dividing at least one of the numbers
221 + (1,222 + (1,223 + a,
Proof. We argue by contradiction, assuming that there are only finitely
many such primes, say 191, ..., pd. Fix an arbitrary positive integer k and
let N be an integer (depending on k) such that for all n 2 N we have
22" + a > (p1...pd)k.
In particular, for any n 2 N there is in E {1, ..., d} such that
”Pin (22" + a) > k)
since all prime factors of 22" + a are among p1, ..., pd. Among the d + 1
numbers iN,iN+1, ...,iN+d (which are all between 1 and d) there must
be two equal numbers, say in = im with N S n < m g N + d. Then
pf | 22" + a and pi?" = pfm I 22'" + a. Note that if an integer s divides
22'). + a and 22m + a, then
—a 5 22m = 22n'2'n—n E (—a)2m_n
(mod 3)
in other words 3 divides awn—1‘ + a. We deduce that pf" | a2m_n + a, thus
(recallthat N gn<mSN+d)
2kgp§nga2
m—n
d
+a.<a2 +0..
Since k was arbitrary and a and d are fixed, this is certainly impossible.
The result follows.
[I
630
Chapter 8. Solutions to practice problems
15. (China TST 2016) A point in the coordinate plane is called rational if
its coordinates are rational numbers. Given a positive integer n, can we
color all rational points using n colors such that
a) each point receives one color;
b) any line segment whose endpoints are rational points contains rational
points of each of the n colors?
Proof. Give the color 0 (or any number between 0 and n— 1) to the origin
0 = (0,0). Extend 02 to Q* by setting 112(x/y) = v2(a:) — v2(y) for any
nonzero integers 13,31. This is well-defined and satisfies the same basic
properties as '02 on Z (this follows immediately from the definition). If
P 75 0 is a rational point with coordinates 3:, 3;, give P the color whose
number is the remainder of min(v2(m), 02(y)) when divided by n.
Consider now a segment I whose endpoints are P1 = ($1,311) and P2 =
(x2, yz). Fix 72 E {0, 1, ..., n — 1} and let us prove the existence of a point
on I whose color is 2'. We may assume that v2(a:1 — :32) S v2(y1 — yg),
which in particular implies that 9:1 79 .732. Pick k large enough, to ensure
that 122(m1—x2)—k < 020172) and, ifyl 75 pg, that 02(y1—y2)—k < v2(y2).
Let
1
1
Qk=§EP1+(]-_¥)P2=(
a: —a:
—
12k
2+$2,y12ky2+y2)'
Note that Q; belongs to I and is not equal to 0 for large enough k. Call
uh, vk the coordinates of Qk, so
uk—
1131 —m2
2k;
+932,
_ 111 —y2
'Uk —
2k
+y2.
Thanks to the choice of k we have
a:
122014;) = ’Uz(
—:L'
12k 2) = 122({131 — x2) — k.
If y1 = yg then v2('uk) = 112(y2), while if yl 7A yg, then a similar computation shows that 122(vk) = 122 (yl — yg) — k. In all cases, taking into
8.5. p-adic valuations and the distribution of primes
631
account the inequality '02 (11:1 — .732) S v2(y1 — m) we see that for k large
enough we have
min('02('u,k), v2('uk)) = 122(uk) = 02(151 — m2) — k.
It suflices therefore to choose k large enough and such that
v2(a:1 — x2) — k E i
(mod n),
and then Qk will receive color i.
E]
16. (China TST 2010) Let k > 1 be an integer and let n = 2"“. Prove that
for any positive integers a1 < (12 < ... < an, the number
H
(ai + a,-)
1_<_i<j$n
has at least k + 1 different prime divisors.
Proof. We will prove a stronger result, with n = 2" + 1 instead of 2"“.
Suppose that n = 2" + 1 and that N = H1gi<jgn(ai + aj) has at most
k prime divisors. Note that N is clearly even, so let 2, q1, ...,qr be the
different prime factors of N, with r S k — 1.
By problem 5 we can choose at least 2’“1 + 1 integers b1, ...,b2k_1+1
among the ai’s such that vq1(b1- + bj) = min(vq1(b.i),vq1(bj)) for i aé
j.
Note that all prime factors of H1$i<j32k_1+1(b¢ + bj) are among
2aq1) "'aq'r-
Using problem 5 again with the numbers b1, ...,bzk—l + 1, we can find
at least 2’“2 + 1 of them, say 01,...,c2k_2+1 such that ’q (Ci + Cj) =
min(vq2(q),vq2(cj)) for i aé j. Of course, we also have vql(ci + Cj) =
min(vq1(c,-), 'Uq1(Cj)) for i aé j. Continuing this way we obtain at least 3
numbers 901, $2,183 among the ai’s such that
vqk ($1- + $3) = min(vqk(wz~), vqk (5%))
for all i 75 j and 1 S k S r. We will prove that this cannot happen.
Chapter 8. Solutions to practice problems
632
Let 2:1 + x2 = 2Aq‘1’1...q$" and note that $1,:1;2 are multiples of q?1...qfi‘r.
If 122(321) 74 v2(a:2), then A = 02(x1 + m2) = min(vg(a:1),v2(:c2)) and so
561,502 are also multiples of 2", hence x1,x2 are multiples of 1:1 + {1:2,
impossible. Hence v2(a:1) = 122(932) and by symmetry we have 1220131) =
'02 (x2) = v2 (933). Call this common value B and write x,- = 23y,- with y,odd. Then
=2A—
—.3 gal
211 +112
"qr
'
Since 311, 342 are odd, we have A — B Z 1. Assuming that A — B = 1, we
deduce that 2:131, 2:132 are both multiples of 3:1 + x2, hence 23:1 2 x1 + 9:2
and 20:2 2 x1 + x2, forcing x1 = $2, a contradiction. Thus A — B 2 2
and so 4 l 341 + yg. Similarly, 4 | 3/2 + 113 and 4 | 3/3 + yl. This is however
impossible, since y1,y2, 343 are odd.
El
17. (Komal) Which binomial coefficients are powers of a prime?
Proof. If (2) =1)t,then pt_
< n by theorem 6.44. Thus (7‘) < n. Assume
that2$k$n— 2, then
17.
(k)="
(n— 1)(n— 2). .(—n
k!
k+1)> n(k+1)k...
k!
_ k+1
‘ n 2 > n’
a contradiction. Thus k = 1 or k = n — 1 and the equation reduces to
n = pt .
III
18. Prove that (2:) | lcm(1, 2, . . . , 277.) for all positive integers n.
Proof. Let p be any prime and let k = up ((25)). Then pk 3 2n by
theorem 6.44, hence pk | lcm(1, 2, . . . , 2n) since
'vp(lcm(1, 2,
2n)) = [iogp(2n)J
by example 6.7. The result follows.
III
8.5. p-adic valuations and the distribution of primes
633
19. Prove that for all positive integers n and all integers a we have
1
$01” — 1)(a." — a)...(an — an_1)6 Z.
Proof. We may assume that n > 1. It suffices to prove that for every
prime p we have
vp(n!) S vp(a” — 1) + vp(a" — a) +
+ vp(a” —— (In—1).
Theorem 6.49 gives vp(n!) S [z—jj , thus it suffices to prove that
21v as;:—;J
k=0
If p | a, then vp(a" — ak) 2 19, thus the left-hand side is at least a? 2
n — 1 > 13%]. If p does not divide a, Fermat’s little theorem shows
thatpdivides a“? 1) ——1 for 1 <k<|_;TIJ, thus
k
—1
———1_
7:10pm" —a)=2vpk(a —1)>:
III
k=0
20. Prove that if k < n then
71— 1
n( k )llcm(n,n— 1,...,n — k).
Proof. It suflices to prove that for any prime p we have
vp<n<n—1) (n— k))<vp(k!)+ _n,ggx< W)
Let N = maXn—kgjgn vp(j) and consider the numbers n,n — 1, ..., n — k.
For each 3' S N there are at most 1 + [fij multiples of p7 among them.
Indeed, if k = qpl +r with 0 S r < p7 , then there is exactly one multiple
634
Chapter 8. Solutions to practice problems
ofpi among n—sp7,n—sp7—1,...,n—(s+1)p7+1 for eachO S s S q-l,
and at most one multiple of p7 among n — qpi , ..., n — k. Thus
k
vp(n(n — 1)...(n — k)) g: (1 + lfil)
= I“:1 [a g N + upon),
as desired.
El
21. (Mathematical Reflections S 206) Find all integers n > 1 having a prime
factor p such that vp(n!) | n — 1.
Proof. Write n = kp and observe that by Legendre’s formula
n
vp(n!) = k + lFJ +
2 k.
Hence (recall that sp(n) is the sum of digits of n in base p)
_E> n—1
p_k
k
n—1
‘vp(n!)_
n—sp(n)_
vp(n!)
—p
_1
’
the last equality being a consequence of theorem 6.49. Since %1—5
is an
071'
integer belonging to [p — 1, p), it can only be p — 1 and moreover we must
have 8,, (n) = 1, that is n is a power of a prime. Conversely, if n = pk for
some prime k and some k 2 1, then vp(n!) = 2%? is a divisor of n — 1.
Thus the solutions are all powers of primes.
El
22. (Romania TST 2015) Let k be an integer greater than 1. When n runs
through the integers greater than or equal to k, What is the largest
number of divisors of (2) that belong to {n — k + 1, n — k + 2, ..., n}?
Proof. Since
n
_ n(n—1)...(n—k+1) _ n
— k + 1),
(k) ‘ —kT— - H01 - 1)--.(n
8.5. p-adic valuations and the distribution of primes
635
we see that (2) can be divisible by n— 1, n— 2, ..., n— 19+ 1, by choosing n
a multiple of k!. If we can prove that (2') is never divisible by all numbers
n,n — 1, ...,n — k + 1, then the answer of the problem is k — 1.
Fix a prime p | k and let
u = max(vp(n),vp(n — 1), ...,vp(n — k + 1)).
Recall that
714(2)) :23
= ltJ - lfil - 1%,
and each xj is either 0 or 1. Note that since 1) | k, we have
VJ k l” '“J
331: — ——— ——— =0.
P
P
P
P
Also if j > u, then by the definition of u none of the numbers n, n— 1, ...,
n — k + 1 is divisible by 1”. Since [fij is the number of multiples of p7
that are at most m, we conclude that [fij = [VT—k]
for j > u. Hence
Therefore wj = 0
(0);
Thus there must be at least one of the numbers n,n — 1, ...,n — k + 1
which does not divide ('2).
III
23. (Mathematical Reflections 0 285) Define a sequence (01107121 by a1 = 1
and an+1 = 2”(2“" — 1) for n 2 1. Prove that n! | an for all n 2 1.
Proof. We will prove by induction on n the following stronger statement:
for all primes p S n+1 we have up (an) 2 n—p+1. Note that this implies
the desired result, since for any prime p S n theorem 6.49 gives
n—1
n —p
v n! S—=——+1$n—p+1§v an,
A) p_1 p_
p( )
636
Chapter 8. Solutions to practice problems
and this implies that n! | on.
It remains to prove the claim. This is clear for n = 1, so assume that it
holds for n and let us prove it for n + 1. Let p S n + 2 be a prime and
let us prove that vp(an+1) 2 n —— p + 2. This is clear for p = n + 2, so
assume that p S n + 1.The result is also clear for p = 2, so assume that
p > 2.
Thanks to the inductive hypothesis and the argument at the end of the
first paragraph, we know that n! divides an, in particular p—l I an. Using
lifting the exponent lemma (theorem 6.22) and Fermat’s little theorem,
we obtain
vp<an+n = 22.42“" — 1) = mop-1)??? — 1) 2 vp(2P-1— 1) + w (131)
21+vp(an)21+n—p+1=n—p+2,
the last inequality being the inductive hypothesis. This proves the inductive step and finishes the proof.
El
24. (China 2015) For which integers k are there infinitely many positive
integers n such that n + A: does not divide (2:)?
Proof. Since the Catalan numbers are integers (see example 2.54), k = 1
is not a solution of the problem. We will prove that any integer k aé 1 is
a solution, by constructing for such k infinitely many integers n 2 1 for
which n + k does not divide (22‘). Suppose first that k 2 2 and let p be
a prime factor of k. Choose any j such that p7 > k and let n = p7 — Is.
There are at most j — 1 carries when adding n to n, since 2n has at most
j digits in base p, the last one being 0 (since p | k). Therefore p7 = n+ k
cannot divide (2:) by Kummer’s theorem. Next, suppose that k S 0 and
choose any odd prime p > 2|k|. Letting n = p — k, we see that n + k
does not divide (2:) since there are no carries when n is added to n in
base p. The result follows.
[I
Remark 8.20. This result, as well as many other interesting ones appears in the article 'Divisors of the Middle Binomial Coefficient" by
8.5. p-adic valuations and the distribution of primes
637
Carl Pomerance, published in the American Mathematical Monthly, vol.
122, No. 7 (2015), pp 636-644. The author of the paper also proves the
following two interesting results (the proofs are however more technical
than that of the problem above): for each It 2 1 almost all integers n > 0
(in the sense of asymptotic density) satisfy n + k | (2:), while for each
It > 0 the set of n > k with n— k | (2:) is infinite, but with upper density
3 %.
25. (Romania TST 2007) Find all positive integers x, y such that
$2007 _ y2007 = (I?! _ yl.
Proof. We will prove that the equation has only the trivial solutions
(2:, z), with x is a positive integer. Suppose that a: > y satisfy
x2007 _ y2007 = x! _ yl.
Clearly y > 1, thus y has a prime divisor p. Considering the equation
modulo p we obtain p | cc, therefore (a very weak version of) theorem
6.39 gives
1:!
2007 S vp(x2007 — 1112007) = 1),, (y! (E — 1)) = vp(y!) < y.
Next, choose any prime q < 2007 such that gcd(2007, q — 1) = 1. Then
q | w! — yl, since 3; > 2007. We deduce that q | $2007 — 3/2007 and
since q | 534—1 — gag—1 we obtain q | a: — y. Varying q, we easily obtain
a: > y + 2007, which gives
I
m! — y! = y! 6 — 1) > 2007! - x(a: — 1)...(:z: — 2006) > $2007,
a contradiction. The result follows.
26. a) Prove that for all n 2 2 we have
’02 ((32) — (—1)” (21:21)) = 32(7),) + 2 + 311201,),
El
638
Chapter 8. Solutions to practice problems
where 32(n) is the sum of the digits in the base 2 expansion of n.
b) (AMM E 2640) Find the exponent of 2 in the prime factorization of
the number
2n+1
2n
( 2n )-(2n—1)Proof. a) Note that
(42 _M. L! 2
@727»)! ((210!)
and for all k
(2k)! _ 2-4-...~2k-1-3-...-(2k—1)
k! _
k!
=2’°-1.3-...-(2k—1).
We conclude that
4n
n 2n
_
2n
Fn(4n)
(2n) _(—1) (n) _ (n) (2n—1)!!’
where (2n — 1)!! = 1 ~ 3 ~
- (2n — 1) and
Fn(X) = (X—1)-(X—3)o...-(X—2n+1) -—(—1) -(—3) -
. (1—2n).
A brutal expansion shows that
Fn(X) = —n2X + %n(1 — 4n + 3n2)X2 + . . .,
thus
8
Fn(4n) = —4n3 + §n3(1 — 4n + 3n2) + . . ..
The first term has v2(4n3) = 2 + 3v2(n), the next term has 112 2 3 +
3v2(n), and all other terms are multiples of (4n)3. The strong triangle
inequality gives therefore
02(Fn(4n)) = 2 + 302(71)Combining this relation with 122 ((2:3)) = 32 (n) yields the desired result.
b) The answer is 3n and this follows directly from part a).
El
8.5. p-adic valuations and the distribution of primes
639
27. (China TST 2016) Define a function f : N —> Q* as follows: write a
positive integer n = 2km with k 2 0 and m odd, and set f(n) = m1_k.
Prove that for all n 2 1 the number f (1) f(2) f(n) is an integer divisible
by any odd positive integer not exceeding n.
Proof. For each prime p we extend up to Q’k by setting
”pm/y) = ”10(1’) _ ”12(31)
for all nonzero integers m, y. Fix an odd prime p S n and let Sj be the
set of those k 6 {1,2, ...,n} for which 222(k) 2 j, i.e the set of multiples
of 2j among 1, 2, ...,n. Note that if k = 2"m with m odd, then
vp(f(k)) = vp(ml"’) = (1 - 7")vn) = (1 - T)vp(k) = (1 - v2(k))’vp(k),
the last equality using that p is odd. Thus
it
vp(f(1)f(2)---f(n)) = 2(1 - 112(k))”p09) = 2(1 — j) Z 14207*)
= 2(1 —j)( z ”100“)- 2 ”13(10)jZO
Let
kESj
kESj+1
tel ,
n
933' = Z W) = 2 «mm = 114n
kGSj
[=1
Then the previous equality yields
vp(f(1)f(2)---f(n)) = 2(1 -J')($j - mm)
.720
=xo—x1 —(11:2—123)—2($3-$4)—3($4—$5)—... =x0—x1 —:B2—
Using Legendre’s formula and the previous observations (as well as the
easily checked identity [fl = “lb—ill for each real number 1:), we end up
with
vp(f(1)f(2)...f(n)) = Z
(lfil _ 1'21
Z lVZ’TJ)
321
640
Chapter 8. Solutions to practice problems
It suflices to prove that the last quantity is not less than N := [logp (n)J
(which is the maximal value vp(a) can take when a varies among odd
positive integers not exceeding n). Letting
ys=l%J-,§l%t
it suffices to prove that y, 2 0 for all s, and that y.9 2 1 for 1_ sgN
n
LxJ
Fix any 3 2 1 and let a: = lFJ'
Using again the equality|_El
l—[.:_
=13]
for all cc 6 R we obtain
Since [27J<
_ T:
“for all j, it is clear that y3_
> 0. Moreover, if s < N then
x21andso
2m z—=
1'21
j>12j
the inequality being strict because there is at least one j for which 23'
does not divide x. Thus for s g N we have y,I > 0 and since ys is an
integer, we finally obtain 3/8 2 1. We have just proved that
vp(f(1)---f(n)) Z v2201)
for each odd prime p and each positive odd integer a not exceeding n.
The result follows.
Cl
28. (IMO Shortlist 2014) If as is a real number, we denote by ”x” the distance
between a: and the nearest integer. Prove that if a, b are positive integers,
then we can find a prime p > 2 and a positive integer k such that
a
F
+115-|l+
a__+bH
=1.
8.5. p-adic valuations and the distribution of primes
641
Proof. Let us start by observing that
||$|l =
[Ha—w
,
since [SB + H is the nearest integer to it. Thus [at + H = :1: :l: “as“ for all
m. We deduce that for all a, b, p, k we have
a+b
__
a
_1 _ __
lp" +2l
b
_1 _ _
lpk+2j
a+b
_1 = :l: _
lpk+2l
pk
‘ :I:
a
p’“
:l:
’b
pk '
Suppose that we manage to prove that the left-hand side is 2 1 for some
prime p > 2 and some k 2 1. Each term in the right-hand side has
absolute value < %, thus the only possibility for the previous equality to
happen is that the left-hand side is 1 and all signs are + in the right-hand
side, i.e. that the conclusion of the problem is satisfied.
Thus we only need to prove the existence of p > 2 and k 2 1 such that
the number
f(p,k)=lap:b+%J‘l1%+%J_l1%+%J
is positive. Using the easily checked identity [:6 + %J = [2:12] — [m],
Legendre’s formula gives
2fw>=zl2‘“pi"’J-zl“;bj
1:21
1:21
1:21
Elt—“nfiJ-gli—nlil
= ”12((20 + 25)!) - vp((a + b)!) - vp((2a)!) — vp((25)!) + ”12(0!) + 1Mb!)
_
(20. + 2b)!a!b!
— ”P ((2a)!(2b)!(a + b)!)'
Since for all n 2 1
642
Chapter 8. Solutions to practice problems
we can rewrite
__
(2a+2b)!a!b! _
" (2a)!(2b)!(a + b)! — 1 . 3 -
1-3-... - (2a+2b— 1)
- (2a — 1) - 1 - 3 -
- (2b — 1)
_ (2a + 1)(2a + 3)...(2a + 2b — 1)
_
1-3-...-(2b—1)
'
This shows that A > 1 and that A is a rational number with odd numerator and denominator. Thus there must be an odd prime p such that
vp(A) > 0. For such p we obtain 2,21 f(p,k) > 0, thus f(p,k) 2 1 for
at least one It 2 1, finishing the proof.
El
29. (Erdos-Palfy-Szegedy theorem) Let a,b be positive integers such that
the remainder of a when divided by any prime p does not exceed the
remainder of b when divided by p. Prove that a = b.
Proof. Taking primes larger than a and b, it is clear that a S b. Assume
that a < b from now on.
Note that if q is a prime factor of b(b— 1)...(b—a+ 1), then the remainder
of b when divided by q is between 0 and a—l, thus q S a by assumption of
the problem (otherwise the remainder of a when divided by q is a > a— 1).
Thus all prime factors of b(b — 1)...(b — a + 1) are between 1 and a. Let
P be the set of primes between 1 and a. For each p E P and k 2 1 let
«twatl-la—m—“J-
Then a:(k,p) is 0 or 1 for all k,p, and the assumption of the problem
implies that :1:(1,p) = 0. Indeed, consider the Euclidean divisions a =
qp + r and b = q'p + r’, then r’ 2 r by assumption, so
r’
r
x(1,p)=q’-q-)q'-q+ p J=0Letting 13,, be the largest k for which :I:(k,p) = 1, these observations
combined with Legendre’s formula yield
1),, ((2)) = a:(1,p)+:1:(2,p)+
3 lap — 1,
8.5. p-adic valuations and the distribution of primes
643
thus (2) divides “pep k‘l and so
b(b — 1)...(b— a+ 1)
a!
HpGPpkp
HpePP.
Next, let us observe that since 23(kp, p) > 0, we have
b
b—a
0
W ‘ W > ’
which means that one of the numbers b— a+ 1, b—a+2, ..., b is a multiple
of MP. Since this happens for all p e P, we deduce that
b(b — 1)...(b — a + 1)
2 (b — a + 1)“-|P|.
HpEPpk'p
Indeed, once the divisions are being made, there are still at least a — |P|
factors available at the numerator, and each of them is at least b — a + 1.
On the other hand, clearly
I
a.
< (ta—IF].
HpeP 17
We conclude that b — a + 1 S a and so 2a > b. However, note that
if a, b is a solution of the problem with a < b, then so is b — a and b
(as the remainder of b — a when divided by any p will be the difference
between the remainder of b and that of a, under the stated assumptions).
Applying the above reasoning, we also obtain 2(b — a) > b. But then
adding the two relations yields the absurd inequality 2b > 2b. Thus
a = b.
E!
Remark 8.21. This result is the topic of the article "a (mod P) S b
(mod p) for all primes p implies a = b'I of P. Erdéis, P. P. Palfy and M.
Szegedy, published in the American Mathematical Monthly, Vol. 94, No.
2 (1987), pp. 169—170.
30. Prove that there exist two consecutive squares such that there are at
least 2000 primes between them.
644
Chapter 8. Solutions to practice problems
Proof. Let k = 2000. Assuming that between any two consecutive
squares there are at most k primes, it follows that the total number
of primes between 1 and n is at most k - (1 + b/fij). Thus we obtain
1r(n) S k - (1+ [JED S 2k\/1—'t
for all 72.. On the other hand theorem 6.63 gives
1n2 n
> __
7r(n)_
2 lnn
hence we obtain
< _
\/— —
1nk1n2
which is impossible for 11. big enough.
17”
I]
31. A finite sequence of consecutive positive integers contains at least one
prime number. Prove that the sequence contains a number that is relatively prime to all other terms of the sequence.
Proof. Let as, cc+1, ..., y be the terms of the sequence. Let p be the largest
prime appearing in the sequence. Then 2p > y, for otherwise Bertrand’s
postulate shows the existence of a prime q between p and 2p, and such
a prime would be in the sequence and greater than p, contradicting the
maximality of p. Since 2p > y, it is clear that p is relatively prime to any
term of the sequence which is different from p. The result follows.
El
Remark 8.22. This statement may look innocent, but it actually immediately implies Bertrand’s postulate (by applying it to the sequence
2, 3, ..., 2n, where n > 1 is a given integer), so it is actually equivalent to
Bertrand’s postulate!
32. Prove that 2pn+1 Z pn + pn+2 for infinitely many 11., where pn is the nth
prime.
Proof. Assume that this is not the case, say 2pn+1 < pn + pn+2 for all
n 2 N and some N > 1. Since —2pn+1 + pa + pn+2 is even, we actually
8.5. p-adic valuations and the distribution of primes
645
have 12,, +pn+2 Z 2pn+1 + 2 for n 2 N. Let xn = pn+1 — pn, then
the previous inequality can be written can“ 2 12,, + 2 for n 2 N, thus
xn 2 am +2(n—N) > 2(n—N) for n 2 N. But then
n—l
:(pkH—pk)Z2(1+2+...+(n—1——N))>(n—1—N)2
k=N
for n > N, hence 1),, > (n — 1 — N)2 for n > N. This contradicts the
result established in example 6.64.
III
33. (AMM) Find all integers m, n > 1 such that
1!
.(2n— 1)! =m!
Pmof. Clearly (n, m) = (1, 1), (2, 3) are solutions. The equalities
3!-5!=6!,
3!°5!-7!=720-7!=8~9~10-7!=10!
show that (n, m) = (3, 6) and (n, m) = (4, 10) are also solutions. We will
prove that there are no other solutions. Note that if 3! . 5! - 7! ~ 9! = m
then m! > 11! and so 11 | m! = 3! - 5! - 7! - 9!, which is impossible. One
proves similarly that n = 6,7,8 are not solutions. Suppose now that
n 2 9. p is a prime factor of m!, then 1) divides 1! - 3! -
- (2n — 1)! and
so p 3 2n — 1. Thus any prime not exceeding m also does not exceed
2n — 1. By Bertrand’s postulate there is a prime p e (%,m) and so
m < 2(2n — 1). On the other hand, we have
m > v2(m!)—
— Zv2((2i — 1)!)_
> ;(i — 1):
no»; 1>_
We conclude that n(n — 1) < 4(2n — 1), which contradicts the fact that
_n > 8. Thus the only solutions of the problem are
(n, m) = (1,1), (2,3),(3,6), (4, 10).
El
646
Chapter 8. Solutions to practice problems
34. (EMMO 2016) Let a1 < a2 <
be an infinite increasing sequence of
positive integers such that the sequence (21?) is bounded. Prove that for
infinitely many 72 the number an divides lcm(a1, ..., an_1).
Proof. Assume by contradiction that an does not divide lcm(a1, ..., an_1)
for n 2 N, for some N 2 2. Thus for each n 2 N we can find a prime
pn dividing an such that
«we > up.(1cm<a1, Gin—1)) = pgam
Let as" = p1?" (“'0 be the largest power of pa dividing an. Choose k 2 1
such that an 3 km for all n 2 1, thus 32,, 3 km for all 17,. On the
other hand, the inequality above immediately implies that an 96 mm for
different n,m 2 N. Indeed, if as” = sum for some N S n < m then
pn = pm and up" (an) = ppm (am), contradicting the inequality
”pm (am) > up", (an) = vpn (an).
Thus for n 2 N the set {1, 2, ..., kn} contains at least n — N + 1 pairwise
distinct prime powers, namely xN, ..., an. On the other hand, it is clear
that the number of prime powers in {1, 2, ..., kn} is bounded by
Wen) + Wm + 9' kn +
s 7r(kn) + log2(kn) . Wm g c%
for some constant c depending on k (this uses theorem 6.62). We deduce
that for n 2 N we have
n—N+1£c n
logn
which is obviously absurd.
,
III
Remark 8.23. As the proof shows, it is enough to ensure that the ai’s are
pairwise distinct and that an has order of growth smaller than nlog n.
35. Does the equation x! = y!(y + 1)! have infinitely many solutions in positive integers?
8.5. p-adic valuations and the distribution of primes
647
Proof. The answer is negative. If x > 8, choose a prime q E (g, 3:], which
is possible by Bertrand’s postulate. Then vq (a3!) = 1 = 2vq(y!)+vq (y+ 1).
It follows that 'vq (y!) = 0 and vq(y+ 1) = 1, which can only happen when
y = q — 1. In particular there is a unique such q, namely y + 1. Letting
n = [g] we obtain
Pnz=
H
p=q=y+lgm<2n+2.
n<p$2n—1
Theorem 6.69 immediately implies that this is impossible for n large
enough. Thus :1: must be bounded and the equation has only finitely
many solutions.
El
Remark 8.24. Using the previous argument as well as explicit estimates,
it is not difficult (though tedious) to prove that the only solutions in
positive integers are given by (ray) = (2, 1) and (10, 6).
36. (Richert’s theorem) Prove that any integer larger than 6 is a sum of
distinct primes.
Proof. We will prove by induction on n 2 5 the following statement:
each of the numbers 7, 8, ..., 19 + pa + + 17,, is a sum of distinct primes
among p1, ...,pn (here, as usual, 1),, denotes the nth prime). For n = 5
we need to show that each of the numbers 7, 8, ..., 19 is a sum of distinct
primes among 2,3,5,7,11. This is clear for 7, 8 = 3 + 5, 9 = 2 + 7,
10 = 3+7,11,12 = 5+7,13 = 2+11, 14 = 3+11, 16 = 5+11,
18 = 7 + 11 and a little bit less for 15, 17, 19, which can be written as
3+5+7, 2+3+5+7, 3+5+11 respectively.
Assume now that the statement holds for n and let us prove it for n + 1.
Write
50,, = 19+p6+...+p.,,.
Consider a number N E [7, xn+1]. If N E [7, an], we are done by the
inductive hypothesis, so assume that 53,, < N S xn+1. We deduce that
3n _Pn+1 < N —Pn+1 S mn-
648
Chapter 8. Solutions to practice problems
If we manage to prove that 23,, - pn+1 2 6, the inductive hypothesis will
show that N — pn+1 is a sum of distinct primes among p1, ..., pn and so
N is a sum of distinct primes among 101, ..., pn+1, as needed.
It remains to prove that can — pn+1 2 6, which we do by induction.
Indeed, for n = 5 this is reduced to the equality 19 — 13 = 6, while if
— pn+1 2 6, then thanks to Bertrand’s postulate
93n+1 - Pn+2 > 93n+1 — 210n+1 = xn — Pn+1 2 6-
D
Remark 8.25. Schnirelman proved in 1930 that there exists k such that
any n > 1 is a sum of at most k primes. Riesel and Vaughan proved
that every even positive integer is the sum of at most 18 primes, so every
integer n > 1 is the sum of at most 19 primes.
37. (China TST 2015) Prove that there are infinitely many integers n such
that n2 + 1 is squarefree.
Proof. We fix a large integer N and count the numbers n in {1, 2, ..., N}
for which n2+1 is not squarefree. If n is such a number, then since 4 does
not divide n2 + 1, there must be an odd prime 1) such that p2 I n2 + 1.
Then p2 S N2+1, sop g N. Let us fix an odd prime p S N and
see how many integers n 6 {1,2, ...,N} satisfy 1)2 | n2 + 1. If n,m are
two such integers, then p does not divide mn and p2 | (m — n) (m + n).
Since p cannot divide simultaneously m — n and m + n, we deduce that
102 | m — n or p2 | m + n. Thus any two such integers m,n are either
congruent modulo 1)2 or their sum is a multiple of 102. It is not diflicult
to deduce that there are at most 2 (1 + 32) such integers n. Therefore
the number of n E {1, 2, ..., N} for which n2 + 1 is squarefree is greater
than or equal to
N— Z 2(l+g)>N—2W(N)—2N Z
2<pSN
On the other hand
2<pSN
8.5. p-adz'c valuations and the distribution of primes
649
Thus the number of n E {1, 2, ...,N} for which n2 + 1 is squarefree is
greater than
N
8
Since 7r(N) < % for N large enough, the result follows.
III
38. (USAMO 2014) Prove that there is a constant c > O with the following
property: if a, b,n are positive integers such that gcd(a + t, b + j) > 1
for all t,j 6 {0,1,. . .n}, then
min{a, b} > c” - 71%.
Proof. We will prove a stronger statement, with cnng replaced with
cnnn for some constant c > 0. Note that it is enough to establish such
an inequality for n large enough, as then we can always replace c by a
smaller constant so that the new inequality holds for all n. Thus n will
always be assumed to be sufliciently large.
The idea is fairly simple: consider an (n + 1) x (n + 1) table and put
an arbitrarily chosen prime factor 1) of gcd(a + 2', b + j) in cell (i, j) for
0 S i, j S n. We will prove that at least half of the primes in this table
exceed 0.001112 when n is large enough. This will be the technical part
of the proof, so take this for granted for a moment and let us see how
to conclude. It follows that there is an index 2' E {0, 1, ...,n} such that
for at least half of the numbers j E {0, 1, ...,n} the prime in cell (i, j)
exceeds 0.001712. All these primes divide a +z' and they are pairwise
distinct, since if one of these primes divides both b + 3'1 and b + j2 with
0 S j1 < .12 S n, then 0.00171,2 < p 3 3‘2 — jl S n and this is impossible
for n large enoughIt follows that a +z' is divisible by at least % primes,
each greater than 0.00117,2 and so
a, + n > (0.001n2)%,
which immediately yields the desired result by symmetry in a and b.
Now, let us prove that at least half of the primes in the table exceed
0.001122. Let M = [0.001n2j and let S be the set of primes not exceeding
650
Chapter 8. Solutions to practice problems
M. Let us see how many cells can be occupied by a prime p E S. If p
occupies cells (11,11) and (2'2, 3'2), then it divides i2 — i1 and j2 — j1 since
it divides a + 751, a+ i2, b+j1, b+j2. There are at most 1 + "—21; pairwise
congruent mod p numbers between 0 and n, hence the number of cells
occupied by p does not exceed (1 + Ext-1)? It is thus enough to prove
that for n large enough we have
2
p65
1 2
p
Expand the left-hand side and rewrite the inequality as
(n+1)22$+2(n+1)2%+ISI < (ll-gm.
pES
PES
Now, by problem 4.77 the first term in the sum does not exceed
0.49(n + 1)2. The last term does not exceed 0.00171,2 by the definition of
S. Finally, the second term is bounded by
M
(n+1)Z% < (n+1)logM < 2(n+1)logn
k=1
and this is less than (0.5 — 0.49 — 0.001)n2 for n large enough.
39. (Mertens) Prove that for all n > 1
—6<Z-hi’3—1nn<4.
psn
Proof. We will use the prime factorization of n!, which yields
log n! = Z vp(n!) log p.
psn
By theorem 6.39 we have
n
n
——1<'v n! g—.
p
p() p_1
El
8.5. p-adic valuations and the distribution of primes
651
Combining the inequality vp(n!) > 5n —— 1 With the obvious inequality
nlogn > log n!, we obtain
nlogn > logn! = Z vp(n!) logp > n 2 l_og_p — log H p.
pSn
199»
p
pgn
Employing Erdos’ inequality (theorem 6.57) yields
2 log — logn < 4,
1611
as desired.
Next, similar arguments (using the inequality vp(n!) <1,—_1) yield
log n! <Z_1_0gp
n
p<n
108—231)
+ 210(1)
p<np
In order to bound from above the second sum appearing in the righthand side, one uses the inequality log p < M (a consequence of the
inequality e” > % for a: 2 O), Which gives
1031»
_\/2_P_1
Zpe—1)<z—p(p—)-‘/§zvzz—(k_1)
pSn
p<np
19-2
Finally, we leave to the reader as an amusing exercise to prove the inequality
1)<
2———
192Wk
Combining all this yields the desired inequality.
40. (Mertens) Prove that the sequence ((170722 defined by
an=Zl—lnlnn
psn
is bounded, Where the sum is over all primes not exceeding n.
III
652
Chapter 8. Solutions to practice problems
Proof. The fact that the sequence is bounded from below is an immediate
consequence of Euler’s theorem 4.74. In order to prove that the sequence
is bounded from above we define (for 2 g k S n) we = bk,“ if k is a prime
and uh = 0 otherwise. Letting 31 = 0 and Sk = u2+...+uk for 2 g k g n,
we have
”—1
1
SkmSk—l
§p=k:2l—nk =2— :22
Sk
(_
Ink
___)
1
ln(k+1)
Sn
+ —.
By the previous problem
Sk=Zl——np<ln [6+4
psk p
for 2 S k S n. Therefore
1
4
”-1
Ink
lnn+4
Z—<—+z(1——)+—.
pSnp ln2 k=2
ln(k+1)
Inn
On the other hand for each 4 S k S n — 1 we have (the last inequality
can be proved using the function f (x) = ln In :13)
_ Ink _1n(1+t)<
1
< 1
1n(k+1)—ln(k+1) kln(k+1) klnk < lnlnk—lnln(k—1).
The result follows now easily by adding the previous inequalities (note
that the resulting sum is telescopic).
8.6
El
Congruences for composite moduli
. (Poland 2003) A polynomial f with integer coeflicients has the property
that gcd(f (a), f (b)) = 1 for some integers a 74 b. Prove that there is an
infinite set of integers S such that gcd(f (m), f (n)) = 1 whenever m,n
are distinct elements of S.
8.6.
Congmences for composite moduli
653
Proof. It suffices to prove that if a1, ..., ak are integers such that
gcd(f(a¢),f(aj)) = 1
for 1 S i 96 j S k then there is an integer ak+1 different from a1, ...,ak
and such that gcd(f(ai),f(aj)) = 1 for 1 S 2' aé j S k + 1. Pick ak+1
such that ak+1 E ai (mod f(ai+1)) for 1 S i _<_ k — 1 and ak+1 E ak
(mod f (0.1)), which is possible by the Chinese remainder theorem. Then
f(ak+1) E f(ai) (mOd f(ai+1)) f0r 1 S i < k and f(ak+1) E f(ak)
(mod f(01»- Thus gcd(f(ak+1),f(ai+1)) = gcd(f(ai):f(ai+1)) = 1 for
1 S i < k and similarly gcd(f(ak+1), f(a1)) = 1, as desired.
El
Remark 8.26. In particular, consider two relatively prime integers a, b.
Then the problem implies that in the arithmetic progression (an+ b)n20
there is an infinite set of pairwise relatively prime numbers. This is of
course a direct consequence of Dirichlet’s theorem on primes in arithmetic progressions, but as the problem shows one can also prove it by
purely elementary means (and with an argument which generalizes to
higher degrees, for which no analogue of Dirichlet’s theorem is known).
2. Prove that for all positive integers k and n there exists a set S of n
consecutive positive integers such that each :1: E S has at least k distinct
prime divisors that do not divide any other element of S.
Proof. Consider a matrix (pig-)19-Sn with n rows and k columns and
K ’<k
whose entries are pairwise distinaajprimes greater than n. Let R1, ..., Rn
be the products of the entries in rows 1,2, ...,n of the matrix. Then
R1, ...,Rn are pairwise relatively prime, so by the Chinese remainder
theorem there is a positive integer at such that a: E -z' (mod R5) for
1 S i S n. Then a: +2' has at least k distinct prime divisors (namely the
entries of the kth row of the matrix) and none of these divides :1: + j for
j aé i: ifp is an entry ofthe matrix andp I :I:+2' andp | :1:+j then
p I j — i, contradicting the fact that p > n. Thus a: + 1, ..., a: + n satisfy
all required properties.
El
654
Chapter 8. Solutions to practice problems
3. A lattice point is called visible if its coordinates are relatively prime
integers. Prove that for any positive integer k there is a lattice point
whose distance from each visible lattice point is greater than k.
Proof. It suflices to prove that for each k we can find a square of side
length It with sides parallel to the coordinate axes and consisting of
invisible points. In other words, we want to find distinct integers x,y
such that gcd(a: + 1,3,; +j) > 1 for 1 S i,j S k. Consider a k X k
matrix whose entries (pgfigdsk are pairwise distinct primes, and let
R1, ...,Rk (respectively 01,...,Ck) be the products of the numbers in
rows (respectively columns) 1,2,...,k of the matrix. Then R1,...,R;c
(respectively 01, ..., Ck) are pairwise relatively prime, so by the Chinese
remainder theorem there are integers a: aé y such that a: E —2' (mod Ri)
forl S i S kandyE —j (mod Cj)for1 gj g k.Thenfora111 S i,j g
k the prime pij divides both 3: +73 and y +j, hence gcd(a: + i, y +j) > 1
and we are done.
[I
a) Prove that for all n 2 1 there is a positive integer a such that
(1, 2a, ...,na are all perfect powers.
b) (Balkan 2000) Prove that for all n 2 1 there is a set A of n positive
integers such that for all 1 S k S n and all £1,132, ...,:ck E A the number
W51 is a. perfect power.
Proof. a) Choose pairwise distinct primes p1, ..., pn. We will prove that
there is a > 1 such that ia is a pith power for 1 S 'i S n. Letting
q1, ..., qk be all primes not exceeding n, we can write each 1 S 'i S 'n, as
2' = flung?“ with aij 2 0. We look for a of the form a = qfl...q:’°. If
1 S 2' S n, then to = qffl+zl...q,‘:"°+z’° is a pith power if ajj + 113,- E 0
(mod pi) for 1 g j g k. By the Chinese remainder theorem we can
choose for each 1 S j S k a positive integer acj such that my E —a¢j
(mod pi) for 1 S 2' S k: and the problem is solved.
Let us remark that there is also a very simple inductive proof: we prove
the result by induction on n, taking a = 4 for n = 1. Suppose that
we can find a such that [co = 33%" for 1 s k g n, where whyk are
8.6.
Congmences for composite moduli
655
integers greater than 1. Let m be a common multiple of y1, ...,yn and
choose b = (n + 1)mam+1. For 1 S k S n the number kb is a ykth
power since y], | m and since ha is an ykth power. On the other hand
(17. + 1)b = ((n + 1)a)m'"1 is also a perfect power, so we are done.
b) By part a) there is a positive integer a such that a,2a,...,n - nla
are all perfect powers. Consider the set A = {n!a,2n!a,...,nn!a}. If
$1,...,xk e A and 1 S k S n, then Lkfli is of the form “farm with
1 S m S nk. Thus file—+311 is indeed a perfect power by the choice of
a.
III
5. Let a, b, c be pairwise distinct positive integers. Prove that there is an
integer n such that a + n, b + n, c + n are pairwise relatively prime.
Proof. It is not difficult to see that there is k such that at least two of the
numbers a+k, b+k, c+k are odd. Replacing a, b, c with a+k, b+k, c+k
and making a permutation of these numbers, we may assume that a and
b are odd. Let p1, ..., pm be the odd prime divisors of (a — b) (b — c)(c — a)
(we allow m = 0). For all 1 S 2' S m the numbers a, b,c give at most
two different remainders when divided by p,- (since p,- divides a — b or
b — c or c — a), thus (since p,- > 2) there is an integer n,- such that
a + m, b+ 71,-, C+ n,- are not multiples of pi. Using the Chinese remainder
theorem, we can find an even integer n such that n E n,- (mod p,-) for
1 S i S m. Then 71. + a,n + b,n + c are pairwise relatively prime: by
construction the only possible common prime factor of any two of the
numbers n + a, n + b, 'n. + c is 2 (note that any such prime factor would
divide (a — b) (b — c) (c — a)), which is excluded since 71. + a and n + b are
odd. The result follows.
E!
6. (AMM) Prove that there are arbitrarily long sequences of consecutive
integers, none of which can be written as the sum of two perfect squares.
Proof. Letting n be a positive integer, we will construct a positive integer
a: such that none of the numbers :1: + 1, ..., :1: + n is a sum of two squares.
For this, we choose pairwise distinct primes p1, ..., pn that are congruent
656
Chapter 8. Solutions to practice problems
to 3 modulo 4 (this is possible thanks to example 4.56), and then use
the Chinese remainder theorem to find a: such that
13+ 1 Ep1
(mod p¥), m+2 Epz
(mod pg), ..., x+n Epn
(mod pi).
By theorem 5.60 none of the numbers a: + 1, ...,:I: + n is a sum of two
squares.
III
Let f be a nonconstant polynomial with integer coefficients and let n
and k be positive integers. Prove that there is a positive integer a such
that each of the numbers f(a),f(a + 1), . . . , f(a + n — 1) has at least k
distinct prime divisors.
Proof. Choose pairwise distinct prime numbers (pig-)1Sz-fl-Sk such that
f (xij) E 0 (mod pij) for some positive integers xij, which is possible
using Schur’s theorem 4.67. Thanks to the Chinese remainder theorem,
we can find a 2 1 such that a+i—1 E xij (mod p”) for all i,j. But then
each of the numbers f(a), f(a+1), . . . , f(a+n— 1) has at least k distinct
prime divisors, since pij divides f (a. + t — 1) for all 1 S i,j S k.
El
(IMC 2013) Let p and q be relatively prime positive integers. Prove that
Proof. Write
E1(_1)[%J+L§J _
0
k=0
1
_
k
iq is even
if pq odd
k
N“) = lfil + ltl
for 0 S k S pq— 1. Suppose first that pq is even. If k 6 {0,1, ...,pq — 1},
then writing k = ozp + r with 0 S r < p we obtain
l—JlJH
8.6.
Congmences for composite moduli
657
and a similar formula with p replaced by q. Since p + q must be odd in
this case, it follows that
fCPq-l-k) =q+p—2-f(k) E 1+f(k) (mod 2),
which immediately yields
pq—l
pq—l
pq—l
Z (_1)f(k) = Z(_1)f(pq—1—k) = _ Z (_1)f(k)
k=0
k=0
=0
and then Zfii31(—1)f(k) = 0.
Suppose now that pq is odd.
Writing the Euclidean division of k E
{0,1,...,pq — 1} by p and q in the form k = akp+ 1"], and k = bkq + R1,,
we obtain (since p and q are odd)
f0“)=ak+bkEk—7‘k+k-RkErk+Rk
(mod2).
Next, for each (7‘, R) e {O,1,...,p — 1} x {0,1,...,q — 1} the Chinese
remainder theorem yields the existence of a unique k E {0, 1, ..., pq — 1}
such that (m, Rk) = (a, b). We conclude that
pq—l
p—1 q—1
p—l
11—1
:3 (AW) = a=0
2 b=0
3—1)” = a=0
Z(—1)“-Z(-1)"
= 1.
b=O
k=0
The result follows.
El
9. (IMO 1999 Shortlist) Find all positive integers n for which there is an
integer m such that 2" — 1 I m2 + 9.
Proof. Clearly n = 1 is a solution of the problem, so assume from now
on that n 2 2. If 2” — 1 | m2 + 9 for some integer m, then 2“ — 1 has no
prime divisor p > 3 such that p E 3 (mod 4), by corollary 5.28. On the
other hand, if d > 1 is an odd integer, then 2d — 1 E —1 (mod 4) and
3 does not divide 2d — 1, thus 2“ — 1 has a prime factor p E 3 (mod 4)
different from 3. We deduce that 71. cannot have any odd divisor d > 1 (as
658
Chapter 8. Solutions to practice problems
otherwise 21— 1 | 2" — 1 | m2+9, contradicting the previous observations)
and so 71 is a power of 2.
Conversely if n is a power of 2, then n is a solution of the problem.
Indeed, write n = 2k and observe that
2‘" — 1 = 3 . (22 + 1)(24 + 1)...(22’°'1 + 1).
Choosing m = 30,, it is enough to find a such that
(22 + 1)(24 + 1)...(22’°'1 + 1) divides a2 + 1.
Since the Fermat numbers 221 + 1 are pairwise relatively prime (by example 3.12), by the Chinese remainder theorem there is an integer a
such that a E 22'—1 (mod 221 + 1) for 1 S 2' S k — 1. Then a2 + 1 E 0
(mod 22‘+1) for 1 g z‘ 5 k—l and so (22+1)(24+1)...(22’°‘1 +1) divides
a2 + 1. The solutions of the problem are therefore all powers of 2.
III
10. (Bulgaria 2003) A finite set C’ of positive integers is called good if for
any k e Z there exist a aé b E C such that gcd(a + k, b + k) > 1. Prove
that if the sum of the elements of a good set 0 equals 2003, then there
exists c e C such that the set C — {c} is good.
Proof. Say a primep is good for a set C C Z if for any i E {0, 1, ...,p— 1}
the congruence a: E 2' (mod p) is satisfied by at least two elements of C.
It is clear that if there is a prime p good for C, then C' is good. The
crucial remark is that the converse holds. Indeed, assume that C is
good but no prime p is good for 0. Let S be the set of all primes not
exceeding max(C). Then for all p 6 S’ we can find ip E {0,1,...,p — 1}
such that a; E 2", (mod p) for at most one element a: of C. Using the
Chinese remainder theorem, we can find an integer k such that k E —z',,
(mod p) for all p e S. Since 0 is good, there are a 75 b e C such that
gcd(a + k, b + k) > 1. Letting p be a prime divisor of gcd(a + k, b + k),
we have p E S, since p | b — a and la — bl < max(C'). But then a E
—k E ip (mod p) and b E tp (mod p), contradicting the choice of ip.
This establishes the claim.
8.6.
Congmences for composite moduli
659
It is now rather easy to solve the problem. Let p be a prime good
for C, so we can find a,; 76 bi e C such that a,- E b,- E 2' (mod p) for
0 S i < p. Note that {0.0, ...,ap_1,bo, ...,bp_1} is a good set and so is any
set containing it (as p is good for any such set). Thus it suffices to prove
that C 75 {(10,...,ap_1,bo,...,bp_1}.
If C = {am...,ap_1,b0,...,bp_1},
then the hypothesis yields
13—1
201,; + b,) = 2003.
i=0
On the other hand
p—l
p—l
20L,- +bi) E 2211 E 0 (mod p),
i=0
i=0
thus p divides 2003 and then p = 2003. Since (15, bi > 1, this makes the
equality 213;} (ai + bi) = 2003 impossible and finishes the proof.
III
11. Is there a sequence of 101 consecutive odd integers such that each term
of the sequence has a prime factor not exceeding 103?
Proof. Such a sequence exists. Let d be the product of all odd primes
not exceeding 47. Let a: be an odd positive multiple of d and consider
the sequence of 101 consecutive odd integers
:1: — 100,9: — 98,51: — 96, ...,:r,a: + 2, ...,x + 100.
If 1 g j S 50 is not a power of 2, then the terms a::l:2j of this sequence are
not relatively prime to (1 (since j has an odd prime factor, which divides
d). There are still 12 terms of the sequence we have to take care of,
namely x—2j and a:+2j for 1 S j S 6. Call these terms w—a1,..., m—alz
and let p1 = 53, ..., p12 = 103 be all primes in (47,103]. Choosing a: such
that x E a”; (mod 1);) for 1 S 2' S 12, which is possible by the Chinese
remainder theorem, yields a sequence which has the desired property. El
660
Chapter 8. Solutions to practice problems
12. (USA TST 2010) The sequence (an)n21 satisfies a1 = 1 and
an = “in/2] + “in/3] + - - - + “Ln/n1 + 1
for all n 2 2. Prove that an E n (mod 22010) for infinitely many n.
Proof. For n 2 3 we have
an—an—1=
in Lkl
M (as—02:1)Lil
Ln H an_—1=1+
k=2 0&—
Since [fij — [HT—IJ is 0 unless k | n, in which case it equals 1, we deduce
that
an - (In—1 = 1 + 2 (ad - (Id—1),
2Sd<n
dln
which also holds for n = 2. Defining x1 = 1 and run = on — an_1 for
n > 1, the previous relation becomes (for n _>_ 2)
:12", = d.
d|n
d<n
Next we prove by strong induction on n that
2maxpl,‘ vp(n)—1 l 31:11.-
This is immediate for n = 1 and n = 2, so assume that n > 2 and that
the previous divisibility holds for 1, 2, ...,n — 1. Take any prime p | n
and let 1:: = vp(n). We have (assuming n 76p, as otherwise everything is
clear)
xn=Zxd+Zxd=2xg +2“.
all;
pkld
d<n
pkld
d<n
By the inductive hypothesis 2"—1 divides 2xn/p and also $4 for all d < n
such that pk | d. Thus 2"—1 | Jon and the inductive step is proved.
8.6.
Congmences for composite moduli
661
It it now easy to conclude. Let N = 22010— 1 and choose pairwise distinct
primes p1, ..., pN. By the Chinese remainder theorem there are infinitely
many integers z > 1 such that z E —i (mod p20”) for all 1 S 2' S N.
The previous paragraph shows'that 22010 | £2.” for 1 S i S N, thus
az+i E az+¢_1 (mod 22010) for 1 S i S N. Since one of the numbers
z,z + 1, ...,z + N is congruent to az modulo 22°10, it follows that for
each such z we can find n E {z,z+ 1, ...,2+ 22°10 — 1} such that an E n
(mod 22010), which finishes the proof.
El
13. (China TST 2014) A function f : N —+ N satisfies for all m, n 2 1
gcd(f(m),f(n)) S gcd(m,'n,)2014 and n S f(n) S n + 2014.
Prove that there is a positive integer N such that f (n) = n for n 2 N.
Proof. Letting k = 2014, we will prove that we can take N = kk. First,
let us observe that f is injective on (kk,oo), for if f(a) = f(b) with
a > b > kl“, then a g f(a) = f(b) S b+ k, hence
a s f(a) = gcd(f(a), f(b)) s gcd(a, b)" s (a — b)k = M.
a contradiction.
This observation combined with the inequality n S
f (n) _<_ n + 1:: yields the following result: if a; > kl“ and f (a: + i) = z +z'
for all 1 S 2' S k, then f(n) = n for all n 6 (kk,x]. It is thus sufficient
to prove the existence of infinitely many a: such that f (ac + 2') = a: +z' for
all 1 g z' S k.
Let n > 1 be an integer such that f (n) aé 77.. By example 7.8 we know
that all prime divisors p of f (n) divide n and so they divide f (n) — n.
Since n + 1 S f (n) S n + Is, it follows that any such prime p cannot
exceed k. Calling a number n > 1 nice if it has at least one prime factor
greater than k, it follows that f (n) = n whenever f (n) is nice. Thus,
in order to finish the proof it suffices to prove that for infinitely many :1:
each of the numbers x+ 1, ..., z+k is nice. This is however an immediate
consequence of the Chinese remainder theorem: simply choose different
primes q1, ..., qk each greater than k, and choose a: such that :1: +2' E 0
(mod qi) for 1 S i S k.
El
662
Chapter 8. Solutions to practice problems
14. (Iran 2007) Let n be a positive integer such that gcd(n, 2(21386 — 1)) = 1.
Let a1, a2, . . . ,a(p(n) be a reduced residue system modulo n. Prove that
1386
1386
1386
nlal
+ a2
+ ' ' ' + awn)
Proof. Since n is odd, 2a1, 20,2, . . . , 26W”) is also a reduced residue system modulo n, hence
a1386 +a1386+n +a1386=
_ (2a1)1386+(2a2)1386+” +(2a¢(n))1386 (mod n)
The result follows, since n is relatively prime to 21386 — 1.
El
15. Let n > 1 be an integer and let r1,r2, ...,r,p(,,) be a reduced residue
system modulo n. For which integers a is r1 + a, r2 + a, ..., 71W») + a a
reduced residue system modulo n?
Proof. Note that r1 +a, ..., Tron) +a are pairwise distinct modulo 77., since
r1, ..., rMn) are so. So the question is when they are all relatively prime
to 72.. Let N = lnp be the product of the different prime factors of
17.. If N | a, then clearly gcd(a: + a, n) = 1 whenever gcd(w,n) = 1, so
any such a is a solution of the problem. Conversely, let a be a solution
and assume that N does not divide a, so there is a prime factor p of n
which does not divide a. Write n = prk with k relatively prime to p
and choose, using the Chinese remainder theorem, 1: such that :1: E —a
(mod p) and a: E 1 (mod 19) Then clearly gcd(mm) = 1, so there is
'i such that a: E r,- (mod n). It follows that a: + a E r,- + a (mod n)
and so gcd(a: + a, n) = gcd(ri + a, n) = 1. This is clearly absurd, since
p l gcd(x + a, n) Thus the answer of the problem is: all multiples of
Hp|n p
I]
16. Prove that any positive integer n has a multiple whose sum of digits is n.
Proof. Write n = 2“ - 5b - m, with gcd(m, 10) = 1 and a,b 2 0, and
consider the number
A = 10a+b(10‘”("") + 102‘P(‘”‘) + + 10'1“”).
8.6.
Congmences for composite moduli
663
Clearly the sum of digits of A is n. It remains to check that A is a
multiple of n. It suffices to prove that m divides 10‘P(m) + 102990”) +
+
10n‘P(m), which follows from Euler’s theorem.
[I
17. For which integers n > 1 is there a polynomial f with integer coeflicients
such that f(k) E 0 (mod n) or f(k) E 1 (mod n) for any integer k, and
both these congruences have solutions?
Proof. If n is a power of a prime, then Euler’s theorem shows that X‘P(”)
is a solution of the problem. If n is not a prime power, we can write
n = ab with a,b > 1 and gcd(a, b) = 1. Fix some 1*,s with f(r) E 0
(mod n) and f (s) E 1 (mod n). The Chinese remainder theorem gives
a t with t E 7" (mod (1) and t E 3 (mod b).
But then we see that
f(t) E f(r) E 0 (mod a) and f(t) E f (s) E 1 (mod b). But then f(t)
is neither 0 nor 1 modulo n, a contradiction. Thus the solutions of the
problem are exactly the powers of prime numbers.
El
18. (Saint Petersburg 1998) Is there a nonconstant polynomial f with
integer coefficients and an integer a > 1 such that the numbers
f (a), f (a2), f(a3),
are pairwise relatively prime?
Proof. The answer is negative. Assume that f(a), f(a2), f(as), are
pairwise relatively prime. Then gcd(a, f(0)) divides both f(a) and
f (a2), so gcd(a, f(0)) = 1. Choose a positive integer 7; such that
I f (ai)| > 2, which is possible since f is nonconstant. Note that
gcd(a. f(a“)) = gcd(a,f(0)) = 1. thus, letting j = z‘ + mm)”, Euler’s
theorem yields aj E a.i (mod f (a’)) and f(aj ) E f(a‘) E 0 (mod f (ai)).
Thus gcd(f (a‘), f(aj)) 7E 1, a contradiction.
III
19. a) (IMO 1971) Prove that the sequence (2” — 3),,21 contains an infinite
subsequence in which every two distinct terms are relatively prime.
b) (Romania TST 1997) Let a. > 1 be a positive integer. Prove the same
result as in a) for the sequence (0.”+1 + a" — 1),,21.
664
Chapter 8. Solutions to practice problems
Proof. a) We prove by induction on k 2 2 the existence of an increasing
sequence m <
< nk such that gcd(2”" — 3, 2’” — 3) = 1 for all 75 aé j 6
{1,2, ..., k}. For k = 2 take m = 1 and 71.2 = 2. Assuming that m <
<
nk are constructed, we will construct nk+1 > nk such that 2nk+1 — 3 is
relatively prime to N := [[99:1(27‘1' —3). Simply take nk+1 = (nk+1)<p(N)
and observe that nk+1 > nk and by Euler’s theorem 2nk+1 — 3 E —2
(mod N). Since N is odd, it follows that 2nk+1 — 3 is relatively prime to
N, as desired.
b) Let as", = a”+1 + a" — 1. As in part a), we prove by induction on
k 2 1 the existence of a sequence m <
< nk such that xn1,...,mnk
are pairwise relatively prime. There is nothing to be done for k = 1, so
assume the existence of m <
< 72],. Let N = xnl...xnk and note that
gcd(N, a) = 1. Choose nk+1 = (rt,c + 1)<p(N), then by Euler’s theorem
sunk+1 E a (mod N) and so gcd(a3n,c+1,N) = 1, proving the inductive
step.
D
20. (China TST 2005) Integers a0, a1, ..., an and 930,931, ...,xn satisfy
(1o + al +
+ (1a = 0
for all 1 g k: S r, Where r is a positive integer. Prove that m divides
aow6”+a1m’1”+...+anaz$ for allr+1 3mg 2r+1.
Proof. Taker+1 S m S 2r+1 and letpbeaprime factor ofmand
u = vp(m). It suffices to prove that p" | 2?;0 ajxg-T‘. We claim that
$3” E 3:1F (mod p") for 0 S j S 77.. If this holds, we obtain
”
m
20,3183" E Eng-$1."
(mod p“)
and the last sum vanishes by assumption, since % E {1,2, ...,r}. To
prove the claim, we discuss two cases. If p | 561', then p“ | xjg, since
% 2 gnu—1 2 u. p does not divide xj then 90(1)“) | m — % and so by
8.6.
Congruences for composite moduli
665
Euler’s theorem :33” E 11:]; (mod p“). This proves the claim and finishes
[I
the solution of the problem.
21. (Hong Kong 2010) Let n be an integer greater than 1 and let 1 3 (11 <
< ak S n be the totatives of n. Prove that for any integer a relatively
prime to n we have
—_a
4501) _
n
k
.
1 E Z —1— [flj
z=1
aai
(mod n)
n
Proof. Consider the Euclidean division cat- = qm + 7'; of aai by n. Since
a is relatively prime to n and (a1, ...,ak) is a reduced residue system
modulo n, so is (aa1,...,aak), thus 7-1, ...,rk are just a permutation of
a1, ..., ak. In particular 1—11-11 0.; = [Ii-“=1 13-.
Next, take the product of the relations aai = qin + n and obtain
(1""(")¢11...a;c = (qln + r1)...(qkn + rk).
Expanding the product in the right-hand side and reducing modulo 7?.2
yields
a‘p(”)a1...ak E r1...r,c + r2...rkq1n +
+ r1...'rk_1qkn
(mod n2).
Since H§=1 a1: = [[211 n, we obtain the equivalent congruence
Wt) _. 1
a—Efl+...+q—k
n
7'1
(modn).
’I‘k
We conclude using the fact that 3f E 3%, (mod n) and that q,; = [a—“ij.
El
22. (Komal) Let {1:1, :32, ..., xn be integers such that gcd(a:1, ..., as“) = 1. Prove
that if s,- 2 191+ .192 +
+ 11);, then
gcd(sl, 32, ..., 3.”) | 1cm(1, 2, ....,n)
666
Chapter 8. Solutions to practice problems
Proof. By example 6.7 it suffices to prove that pd g n for any prime p
and any d 2 1 such that pd | gcd(sl, ..., .9"). Write
(X — 2:1)...(X — 1%) = X" + an_1X"’_1 +
+ on
for some integers ao,...,an. Then a3? + tummy—1 +
+ a0 = 0 for
1 g i S n. Multiplying this relation by (of (for 1' an arbitrary nonnegative
integer) and adding the resulting relations, we obtain
sn+r ‘l' an—13n+r—1 +
+ “031- = 0
for all r 2 0. Since pd divides 31, ...,sn an immediate induction using
the previous relation shows that pd divides 3,. for all r 2 1. Setting
7' = d - <p(pd) we obtain
x‘lwu’d) +
+ $390024) E 0 (mod pd).
By Euler’s theorem, each term x76?” is either a multiple of pd or congruent to 1 modulo pd. Since gcd(a:1, ...,a:n) = 1, there is at least one
nonzero term. We immediately conclude that pd S n, as desired.
El
23. (Brazil 2005) Let a and c be positive integers. Prove that for any integer
b there is a positive integer so such that
a$+x Eb (mod c).
Proof. The solution is very similar to that of example 7.55. We will
prove by strong induction on c the following statement: for all integers
b and all a 2 1 there are infinitely many a: 2 1 such that a” + a: E b
(mod c). The case 0 = 1 is clear, so assume that the result holds up
to c — 1 and let us prove it for c. Fix a 2 1 and an integer b. Since
90(0) < c, by the inductive hypothesis there are infinitely many a: 2 1
such that 90(0) I am + a: — b. We can thus choose (once and for all) such
cc, with a: 2 maximc vp(c) and a: 2 b. Then arguing as in example 7.55 we
obtain az+k¢(c) _=_ a” (mod c) for all k _>_ 1. Write of” +90 — b = d<p(c) for
8.6.
Cong'ruences for composite moduli
667
some d 2 1 and set yk = a: + (kc — d)<p(c) for k > d (k > d/c would be
enough). Then
ayk+ykEaz+ykEax+$—d¢(C)Eb (“10(10):
thus all (yk)k>d are solutions of the congruence ay + y E b (mod c),
proving the inductive step.
El
24. (Ibero American 2012) Prove that for any integer n > 1 there exist n
consecutive positive integers such that none of them is divisible by the
sum of its digits.
Proof. Write s(:c) for the sum of the digits of x. Choose pairwise distinct
prime numbers p1,p2,...,pn such that 191- > max(3,i) for i S n. Let
P = plpg . . . 10,, and consider
0¢(P)10(P-10)90(P) _ 1
B=1
10¢(P) _ 1
+ 10.
Then B is a multiple of P by Euler’s theorem, and 5(3) = P — 9. Since
gcd(P — 9,1») = 1 for 1 S i g n, the Chinese remainder theorem yields
the existence of a positive integer t such that t(P—9) +s(z') E 0 (mod p,-)
for 1 g i g n. Define C = BB. . . B (with t copies of B) and note that
for so large enough we have
3(10w0 + i) = 3(0) + s(z‘) E 0 (mod 10;)
for i S n. Then 1030 + 1, ...,109’0 + n are consecutive numbers and
none of them is a multiple of the sum of its digits. Indeed, if 3(10‘”C + i)
divides 10"”0 + 2', then p,- divides 10"‘0 +2' and since pi | 0 (because
pi | B) we deduce that p; | 2', a contradiction.
III
25. (Russia 2006) Let a: and y be purely periodic decimal fractions such that
:1: + y and my are purely periodic decimal fractions with period length T.
Prove that the lengths of the periods of a: and y are not greater than T.
668
Chapter 8. Solutions to practice problems
Proof. Write a: = % and y = 5 with c, d > 0 and gcd(a, b) = gcd(c, d) =
1. Write
x+y=g+c=ad+bc=g
b
d
bd
f
and xy = fi = if in lowest form.
By assumption f | 10T — 1 and h | IOT — 1. Since f(a.d + bc) = ebd, we
obtain b | fad and so b | fd | d(10T — 1). Next, since ach = bdg, we have
b I ach and so b I ch | c(10T — 1).
It follows that b | gcd(c(10T — 1), d(10T — 1)) = IOT — 1 and similarly we
obtain d | 10T — 1. The result follows.
Here is an alternative argument: by the hypotheses, the polynomial
P(X) = (10T - 1)(X - $)(X - 11)
has integer coeflicients and roots :1: and 3;. By the rational root theorem,
it follows that the denominators of a: and y divide the leading coefficient
10T — 1 of P(X). Thus their periods divide T.
El
26. (Iran 2013) Let p be an odd prime and let d be a positive divisor of p— 1.
Let S be the set of integers a; E {1, 2, ...,p — 1} for which the order of a:
modulo p is d. Find the remainder of HwES a: when divided by 1).
Proof. For each a: e S there is a unique y 6 {1,2, ...,p — 1} such that
my E 1 (mod p). If k is a positive integer, then the congruence :13" E 1
(mod p) is equivalent to (:z:y)’c E 3;" (mod p) or yk E 1 (mod p), thus
the orders of a: and y modulo p are the same and y e S. Moreover, by
construction any E 1 (mod p). If a: = y then x2 E 1 (mod p) and so
(1 = 1 or d = 2. Thus for d > 2 the set S has a partition into pairs (3:, y)
as above and so Hzesx E 1 (mod p). If d = 1 then S = {1} and the
answer is again 1. Ifd = 2 then S = {1,p— 1} and the answer is —1. El
27. Let a, b, n be positive integers with a. 75 b. Prove that
n_ n
2n|<p(a”+b”) and n|<p(aa_::).
8.6.
Congmences for composite moduli
669
Proof. Note that we may assume that gcd(a, b) = 1, by replacing a and b
with film and W2». We may also assume that a > b, by symmetry.
We prove first the divisibility 2n | <p(a'” + b”). Let c be a positive integer
such that be E 1 (mod on + b”) (c exists since gcd(b, an + b”) = 1) and
note that gcd(ac,a” + b") = 1. If k 2 1 the congruence (ac)k E 1
(mod on + b") is equivalent to (abc)" E bk (mod on + b”) and then to
a,“ E bk (mod on + b"). Let d be the order of ac modulo on + b”. Since
(12” E b2” (mod on + b"), the previous discussion yields d I 212. and
a" + b” I ad — bd, in particular d I 271. and d > n. We deduce that d = 2n.
Since (1 I ¢p(a” + b"), the result follows.
We prove next the divisibility n | go (%) . Let
(Ln—b"
N: a
b =a”‘1+a"‘2b+...+b"_1.
Since gcd(ab, N) = 1, there is a positive integer c such that be E 1
(mod N), and we have gcd(ac, N) = 1. Arguing as above, one proves
that the order of ac modulo N equals n and concludes that n I <p(N). El
28. Find all primes p and q such that p2 + 1I2003‘1 + 1 and q2 + 1I2003P + 1.
Proof. We may assume that p S q. If p = 2 then 5 I 2003‘? + 1, which
forces q = 2 and gives the solution (2, 2). Assume next that p > 2. If
7' is a prime factor of p2 + 1, then r I 200324 — 1, hence 0rd,.(2003) I 2q.
Assuming that gcd(q, ord,(2003)) = 1, we infer that
rI20032—1=23-3-7-11-13-167.
Since 7" E 1 (mod 4) (combine corollary 5.28 with r I p2 + 1), it follows
that 'r = 2 or r = 13. We cannot have 7" = 13 since 1‘ I 2003‘] + 1 and
20039 + 1 E 2 (mod 13). We conclude that r = 2 or q | ordr(2003) I
1' — 1, i.e. any odd prime factor 1' of p2 + 1 is congruent to 1 modulo
q. Combined with 02(p2 + 1) = 1, this gives p2 + 1 E 2 (mod q), i.e.
q | (p — 1)(p + 1). This is however impossible since q 2 p and p is odd.
Thus the only solution of the problem is (2, 2).
El
670
Chapter 8. Solutions to practice problems
29. (MOSP 2001) Let p be a prime number and let m, n be integers greater
than 1 such that n|mp(”_1) — 1. Prove that gcd(m ‘1 — 1,n) > 1.
Proof. Assume that gcd(m"‘1 — 1,12) = 1. Let a = vp(n — 1), let q be
any prime factor of n and finally let d be the order of m mod q. Since
q does not divide m"_1 — 1, d cannot divide n — 1. On the other hand,
q divides mp(”_1) — 1, thus d divides p(n — 1). It follows that vp(d) > a
and since d | q — 1, we obtain 'Up(q — 1) 2 a+ 1. Since this happens for all
primes q dividing n, it follows that n E 1 (mod pa“), which contradicts
the equality vp(n — 1) = a. The result follows.
El
30. 3.) (Pepin’s test) Let n be a positive integer and let k = 22" + 1. Prove
that k is a prime if and only if “3% + 1.
b) (Euler-Lagrange) Let p E —1 (mod 4) be a prime. Prove that 2p + 1
is a prime if and only if 2p + 1|2p — 1.
Proof. a) Suppose that k is a prime and let us prove that k
3L3; + 1.
By Euler’s criterion (theorem 5.99) this is equivalent to (%) = —1 and,
by the quadratic reciprocity law (theorem 5.124), to G1)? . (g) = —1.
This follows directly from k E 1 (mod 4) and k E 2 (mod 3).
Suppose next that kl3% + 1 and let p be a prime factor of k. Since
p I k | 3’“1 — 1, the order d of 3 modulo p divides k — 1 = 22", so d is a
power of 2. If d < k — 1, then d | k—gl and p | 3% — 1, contradicting the
fact thatp | k: | 3% +1. Thusd=k—1 andsinced—1,weobtain
k S p. Since p | k, we conclude that p = k, as needed.
b) The argument is very similar. If q = 2p + 1 is a prime, we need to
—1
prove that q I 232— — 1, Le. that G) = 1, which follows from the fact
that q E —1 (mod 8) and theorem 5.125. Conversely, if q | 2? — 1, then
the order of 2 mod q must be p (since it is not 1 and it divides p), and
the same happens for any prime factor l of q. Thus p | l — 1 for each
prime factor l of q, which immediately yields the result.
[I
8.6.
Congruences for composite moduli
671
Remark 8.27. Pepin’s test was used for instance to prove that each of
the numbers F13, F14, F20, F22, F24 is composite, where E, = 22" + 1.
31. Let p > 2 be an odd prime and let a be a primitive root modulo p. Prove
m
that a. 2 E —1 (mod p).
Proof. By Fermat’s little theorem we have (LP—1 E 1 (mod p), hence
L'_1
£1
L1
(a 2 — 1)(a 2 + 1) E 0 (mod p). We cannot have a 2 E 1 (mod p),
—1
since the order of a mod p is p — 1 > %1. Hence a% + 1 E 0 (mod p),
as desired.
I]
32. Suppose that n > 1 is an integer for which there are primitive roots mod-
ulo n. Prove that the set {1, 2, ..., n} contains exactly <p(<p(n)) primitive
roots modulo n.
Proof. Pick a primitive root 9 modulo 71.. If a is another primitive root
modulo n, then we can find an integer k 6 {0,1, ..., <p(n) — 1} such that
a E gk (mod 77.).
Since the order of g modulo n is <p(n), proposition 7.66 shows that the
order of 9" modulo n is <p(n) if and only if gcd(k, <p(n)) = 1. We deduce
that the primitive roots modulo n in the set {1,2, ...,n} are precisely the
remainders modulo n of the numbers g“1,...,ga’=, where 0.1, ..., 0.], are the
totatives of <p(n). Their number is k: = <p(go(n)).
III
33. Let p be an odd prime. Prove that p is a Fermat prime (i.e. of the form
2" + 1 with n 2 1) if and only if every quadratic non-residue mod p is a
primitive root mod p.
Proof. There are %1 quadratic non-residues mod p and <p(p — 1) primitive roots mod p (use the previous exercise or Theorem 7.104 for the
last assertion). Thus if any quadratic non-residue mod p is a primitive
root mod p we must have <p(p — 1) 2 1%1. Writing p — 1 = 2km with
k 2 1 and m odd, the previous inequality becomes <p(m) 2 m and forces
m = 1. Thus p is a Fermat prime.
672
Chapter 8. Solutions to practice problems
Conversely, assume that p is a Fermat prime, then 90(1) — 1) = %1 since
p — 1 is a power of 2. Since any primitive root mod p is a quadratic nonresidue mod p and since there are as many quadratic non-residues mod
p as primitive roots mod p, it follows that every quadratic non-residue
mod p is a primitive root mod p. The result follows.
III
34. Let Mn) be the least positive integer k: such that wk E 1 (mod n) for all
a: relatively prime to n. Prove that
a) If k is a positive integer such that 13’“ E 1 (mod n) for all in relatively
prime to n, then k is a multiple of Mn).
b) a) = lcm(Mm), Mn)) for m, n relatively prime.
0) We have Mn) = <p(n) when n = 2, 4 or a power of an odd prime, and
M2") = 2"—2 for n 2 3.
d) For each n, the set of numbers 0rd,,(x) (over all a: relatively prime to
n) is precisely the set of positive divisors of Mn).
Proof. a) Write k = a) + r with 0 S r < Mn). Assume that r > 0.
Then for all a: relatively prime to n we have
1 E .73" = (x’\(”))q - at" E 56’"
(mod n).
This contradicts the minimality of Mn).
b) Let M = lcm(Mm), Mn)). Suppose that a: is relatively prime to mn,
so it is relatively prime to both m and n. Now by definition of M we
have xM E 1 (mod n) and xM E 1 (mod m), thus wM E 1 (mod mn),
since gcd(m, n) = 1. Since a: was arbitrary, this yields (thanks to a))
a) | M.
To prove that M | a), it suffices, thanks to a) and to symmetry in
m and n, to prove that 9:a) E 1 (mod n) for all :1: relatively prime
to n.
Take such 11:.
Note that :1: is not necessarily prime to m, but
since gcd(m,n) = 1 we can find 3] such that y E a; (mod n) and y E 1
(mod m) (Chinese remainder theorem). Now y is relatively prime to mn,
so m”) E 1 (mod n). But clearly m") E :r’\(m"), hence the result.
8.6.
Congmences for composite moduli
673
0) Note that in all cases Mn) | <p(n), thanks to a) and Euler’s theorem.
Suppose that n is 2,4 or a power of an odd prime. Then we can find
a primitive root 9 modulo n. Since 9"") E 1 (mod n) and since 9 has
order <p(n) modulo n, it follows that <p(n) | Mn). Combined with the
first paragraph, this yields <p(n) = Mn) for such n.
Now consider 2” for n 2 3. By the first paragraph M2”) divides <p(2") =
2"_1, hence it is a power of 2, say 2’“. Thus we need to find the smallest
k for which :62,“ E 1 (mod 2”) for all odd numbers a). We saw several
times that k = n — 2.
d) Let :3 be an integer relatively prime to n and let d = 0rd,, (m). Since
33’4”) E 1 (mod n), we deduce that d | Mn). Conversely, let d be a
positive divisor of Mn). We need to prove that we can find a: relatively
prime to n such that ordn(a:) = (I.
Let n = p11“... E8. By b) and c) we have Mn) = lcm(<p(p’1°1),...,<p(ps’)).
Let d, = gcd(d, <p(pf‘)). Since every prime power factor of d must divide
at least one of the mpg“), we have d = lcm(d1,...,ds). Let a,- be a
ki
primitive root modulo pf‘. Then as, = are," Nd“ has order d,- modulo pf.
Using the Chinese remainder theorem, we can find an integer n: such
that w E 2:,- (mod 12,") for all 2'. Then a: is clearly relatively prime to n,
and its order modulo pi‘ is di. Hence its order modulo n is a multiple of
d = lcm(d1, . . . ,ds). Conversely, d,- divides d for all i and hence .73“ E 1
(mod pf) for all 1'. Thus cod E 1 (mod n) and hence the order of a:
modulo n divides d. Thus the order must be d.
1:]
35. Let p > 2 be a prime and let a be a primitive root mod p. Prove that
—a is a primitive root mod p if and only if p E 1 (mod 4).
Proof. Note that if x is a primitive root modulo p then mpg—1 E —1
(mod p), since (53%)? E 1 (mod p) by Fermat’s little theorem and mpg—1
is not congruent to 1 modulo 1) since ordp(a:) = p — 1. Suppose that
—a is a primitive root modulo p, then by the preliminary discussion
we have a? E (—a)%1 E —1 (mod p), thus (—1)L§_1 E 1 (mod p)
674
Chapter 8. Solutions to practice problems
and since p > 2 we deduce that p E 1 (mod 4). Conversely, suppose
that p E 1 (mod 4) and let d be the order of —a modulo p. Then
(—a)d E 1 (mod p), thus azd E 1 (mod p) and since a is a primitive
root modulo p we deduce that p — 1 | 2d. If —a is not a primitive root
modulo p, then necessarily d = L1 and so (—a)%1 E 1 (mod p). But
(—a)p_
2 E—( 1)P2_1aL —
:-1 (— 1)2:
— -1 (mod p), a contradiction. Thus
—a is a primitive root mod p and the problem 1s solved.
I]
36. (Unesco Competition 1995) Let m,n be integers greater than 1. Prove
that the remainders of the numbers 1”, 2”, ..., m” modulo m are pairwise
distinct if and only if m is square-free and n is relatively prime to 90(m).
Proof. Suppose that the remainders of 1n,2",...,m"' are pairwise dis-
tinct. If there is a prime p such that p2 | m, then m” and (m/p)“ are
both 0 modulo m, a contradiction. Thus m is squarefree, say m = p1...pk
for some pairwise distinct primes p1, ...,pk. We need to prove that n is
relatively prime to p, — 1 for all 12, since go(m)= (p1 — 1).. .(pk — 1). Suppose that d,- = gcd(p,° — 1 ,n) 1> 1 for some i, and pick a primitive root
9 modulo pi. Then :1): g pd
satisfies a3” E 1 (mod p,) and z is not
congruent to 1 modulo 1),. Thanks to the Chinese remainder theorem we
can find y such that y E 1 (mod pj) for all j aé i and y E a; (mod p,).
But then y” E 1 (mod m) and y is not congruent to 1 modulo m, a
contradiction. This proves one direction.
Next, assume that m = p1...p;c is squarefree and gcd(n,<p(m)) =
Suppose that for some 1 S 12 < j g m we have i" E j” (mod m). Then
in E j” (mod pr) for all r and since pr — 1 and n are relatively prime,
we deduce that i E j (mod pr). But then 2' E j (mod m), which is
impossible. This proves the opposite direction and finishes the solution.
El
37. (adapted from Tuymaada 2011) Prove that among 2500 consecutive positive integers there is an integer n such that the length of the period of
the decimal expansion of % is greater than 2011.
8.6.
Congmences for composite moduli
675
Proof. We want to ensure that the order of 10 modulo n is greater than
2011. It suffices to prove that there is d 6 {1,2, ..., 2500} such that the
order of 10 modulo d is greater than 2011. Indeed, if such d exists, then
among any 2500 consecutive integers one can find a multiple of d, and
the result follows.
We start by finding a prime p for which 10 is a primitive root modulo 1).
Trial and error gives the smallest answer p = 7. Let us see whether 10 is
a primitive root modulo 49. The order of 10 modulo 49 is a multiple of 6
and a divisor of <p(49) = 42. So if 10 is not a primitive root modulo 49,
then its order is 6 and so 49 | 106 — 1 = 33 - 7 - 11 - 13 - 37. The last result
is absurd, hence 10 is a primitive root modulo 49, thus also a primitive
root modulo 7” for all n, by theorem 7.108. Now, it is enough to ensure
that we can find a power of 7 with 90(7’“) > 2011 and 7" S 2500. It is
not diflicult to see that 74 works, hence the result.
El
38. Is there a positive integer which is divisible by the product P of its digits
and such that P is a power of 7 greater than 102016?
Proof. Fix a positive integer k. We will prove that there is a number m
divisible by the product P of its digits and such that P: 7’“. We saw in
the previous exercise that 10 1s a primitive root modulo 7’“. Consider the
number a—
— 66.. .6: 6 10k9‘1,then 1— 90,—
- 7—6-10’“ 1s relatively prime
to 7 and so there are infinitely many n such that010" E 1— 9a (mod 7").
For such 77. which'1s greater than k, the number1—_1
—+a has the product
of its digits equal to 7k and'IS a multiple of 7" by construction.
III
39. Let m,n be positive integers. Prove that there is a positive integer k
such that 2’“ E 1999 (mod 3’") and 2’“ E 2009 (mod 5").
Proof. Using theorem 7.108, it follows easily that 2 is a primitive root
modulo 3’” and modulo 5", thus we can find positive integers k1, k2 such
that 2’“1 E 1999 (mod 3m) and 2"2 E 2009 (mod 5”). Considering these
simply as congruences modulo 3 and 5, it follows that k1 and k2 are even.
The Chinese remainder theorem yields the existence of a positive integer
676
Chapter 8. Solutions to practice problems
a such that a E E21 (mod 3m“1) and a E E21 (mod 2 - 5""1). Letting
k = 2a. and using Euler’s theorem, we obtain 2" E 1999 (mod 3’”) and
2’“ E 2009 (mod 5”), as desired.
III
40. (Iran 2012) Let p be an odd prime. Prove that there is a positive integer
a: such that a: and 4a: are both primitive roots modulo p.
Proof. Fix a primitive root 9 modulo p and write 2 E gk (mod p) for
some positive integer k. If we can find a positive inte
Download