Topics in Number Theory
Topics in Number Theory
An Olympiad-Oriented Approach
BY
Second Edition
Dedicated to
Masum Billal
Amir Parvardi
August, 2021
Preface from first edition
I would like to have a few words before diving into the discussion. First of all, from my
personal experience, I have found that there is a common practice to learn by learning
a lot of theories and then investigating how those theories are used to solve problems.
As our primary audience would be students who are looking to get into mathematical
Olympiads, I highly discourage this. Please do not take number theory for a collection
of theories just because the word theory is literally juxtaposed with it. That being said,
one could argue our book itself is a collection of a lot of theorems as well. Sadly, that
is partially true for multiple reasons though it was not our intention at all.
When I first thought about writing this book, my intention was to make students
realize that they do not need to know a lot of theorems in order to be able to solve
problems. But as we kept writing, we had to increase the pace since we had to cover
a lot (and that was discarding a lot of content which we thought would ask for even
discussion or we just felt lazy about it), we had to increase the pace.
Initially, my plan was to make this book a series of 5 volumes, this being the first
one. In those volumes, I wanted to discuss a lot of topics such as special numbers
like egyptian fraction or even interesting numbers like abundant number or deficient
number and their properties, etc., or crucial topics such as Diophantine equations. You
will notice that we have left a lot of important topics like those out of this book. The
reason is, I quickly realized I could hardly finish writing this first volume, and if I
wanted to complete the whole series, we would probably have to keep writing my whole
life. So, I had to discard a lot of content and make the book concise. This resulted in
squeezing in a lot of content in a few hundred pages.
Finally, I would like to thank Amir for joining me in this project. At one point, I
stopped writing the book. If he had not agreed to be a co-author, this book would have
probably not been completed at all, more so because he agreed to follow the style I
wanted to write in even when we had objections from a reputed publisher like Springer.
Masum Billal
In the past three years, we have always been worried about this book. It’s been a
long and tedious job to manage everything and edit all we had written a very long time
ago. After I studied more number theory concepts of higher level, there were times that
I found errors/typos in my previous drafts for the book. And that sometimes happened
two or more times in a short period, and so, it was getting annoying. Anyhow, we
managed to finish it at this time of the summer. It is now 5:36 AM, Tuesday, July 17,
2018, that I’m writing this. You can imagine how crazy this process has made me!
Many of our friends helped us on the way to finish this book, as mentioned in the
acknowledgment, and we are so proud to have such friends. I wouldn’t be able to
finish my part in this book if I didn’t have the support of my wonderful, beautiful, and
lovely wife Nadia Ghobadipasha. She gave me hope to choose mathematics and always
believed in me. She was the only one in the hardest days of my life. Professor Peyman
Nasehpour, whom I knew from the very first semester of my undergraduate studies
in electrical engineering at the University of Tehran, helped me a lot in the process
of enhancing my mathematical abilities to change my field to mathematics (number
theory) for my master’s. He is an inspiration and a great colleague to me when it
comes to teamwork. I’m looking forward to working with him more often. The idea
behind the lattices in the cover is a geometric proof of the law of quadratic reciprocity.
Our friends found other interpretations such as the Pick’s theorem (which is not the
case here) or the sum of positive integers up to n, which you will realize is also not
always true (for all primes p, q). Section (§9) is dedicated to this proof and investigates
why it is true using counting the lattice (grid) points. When we picked this idea for
the cover, we chose quadratic reciprocity because its proof is geometrically visual and
indeed very beautiful. Our hope was to make the reader curious because the design
looks familiar. I remember I found the idea of the proof in one of Kenneth H. Rosen’s
books on discrete mathematics, but I’m not sure which one, as it was a long time ago
when I wrote it. I used the TikZ package for LATEXto write the codes and generate the
graphs. There are so many wonderful things to learn in this book. I hope you enjoy it!
Amir Parvardi,
Vancouver, BC, Canada,
July 2018.
Acknowledgment
Here is a list of all the kind people who helped us review, edit, and improve this book.
The list is ordered alphabetically based on the last name.
1. Thanks to Ali Amiri, a kind friend who helped us with the cover design.
2. Thanks to AnréC from TeX.StackExchange who wrote the code for figure (1.4)
in base conversion.
3. We are thankful to Arta Khanalizadeh for designing the cover of the book.
4. Thanks to Kave Eskandari for reading the whole book and commenting on the
general points. He caught a good mistake in chapter I.
5. Cheers to our mathematical friend Leonard Mihai C. Giugiuc from Romania that
gave us positive and constructive feedback on the book. He also wrote us a
wonderful review on the website.
6. Thanks to Valentio Iverson for proof-reading chapters III and V, and pointing
out the typo in figure (3.1).
7. Thanks to Aditya Khurmi for reading the book and giving us positive feedback.
9. Professor Peyman Nasehpour sent us the beautiful problem (264) and an amazing
solution using Prime Number Theorem. He also gave us pretty useful comments
on chapter I. He also introduced in section (§2.2) the amicable numbers to us with
a brief historical note on it.
12. We would like to thank Nur Muhammad Shafiullah Mahi for his efforts to make
this book better.
13. We are honored to thank Professor Greg Martin, a faculty member at the Math-
ematics Department of the University of British Columbia. He happens to be
Amir Hossein’s Master’s supervisor. He kindly reviewed a printed draft of the
book and emailed us over 10 major points to correct in the book. We do appre-
ciate his advice on improving the whole context of the book.
14. We are thankful to Sohrab Mohtat for his comments on chapter I. Thanks to him,
we avoided a fatal mistake at the beginning of the book. He also wrote a very
useful and detailed review for our book on the website.
15. We are thankful to Aditya Guha Roy who reviewed the whole book and caught a
few LaTeX typos, generalized lemma (32), fixing problems in chapter VII. Aditya
wrote an amazing, educative review on our website.
16. Navneel Singhal carefully reviewed and proof-read the whole first part of the book
(chapters I to V) and gave us very constructive comments. We are thankful to
him.
17. Thanks to Amin Soofiani, who is a Master’s student of mathematics at the Uni-
versity of British Columbia, we noticed there was a mistake in theorem (152). He
did a perfect, precise, and detailed review on chapter IV.
18. We are thankful to Sepehr Yadegarzadeh for informing us about the correct um-
1
laut for Möbius among other grammatical and vocabulary points.
1
umlaut: a mark (˝), used over a vowel, as in German or Hungarian, to indicate a different vowel
quality, usually fronting or rounding.
CONTENTS
I Fundamentals 13
I Divisibility 15
§1 Definitions and Propositions . . . . . . . . . . . . . . . . . . . . . . 15
§2 GCD and LCM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
§3 Numeral Systems . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
§4 Floor and Ceiling . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
§5 Some Useful Facts . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
§6 Solved Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
§7 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
II Modular Arithmetic 75
§1 Basic Modular Arithmetic . . . . . . . . . . . . . . . . . . . . . . . 75
§2 Modular Exponentiation . . . . . . . . . . . . . . . . . . . . . . . . 80
§3 Residue Systems . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84
§4 Bézout’s Lemma . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
§5 Chinese Remainder Theorem . . . . . . . . . . . . . . . . . . . . . . 93
§6 Wilson’s Theorem . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
§7 Euler and Fermat’s Theorem . . . . . . . . . . . . . . . . . . . . . . 100
§8 Quadratic Residues . . . . . . . . . . . . . . . . . . . . . . . . . . . 104
§9 Wolstenholme’s Theorem . . . . . . . . . . . . . . . . . . . . . . . . 116
§10 Lucas’ Theorem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125
§11 Lagrange’s Theorem . . . . . . . . . . . . . . . . . . . . . . . . . . 128
§12 Order, Primitive Roots . . . . . . . . . . . . . . . . . . . . . . . . . 133
§13 Carmichael Function, Primitive λ-roots . . . . . . . . . . . . . . . . 149
§14 Pseudoprimes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153
§15 Using Congruence in Diophantine Equations . . . . . . . . . . . . . 156
§16 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162
Glossary 419
Notations
(nk) n choose k, the binomial coefficient of the k + 1-th term in the expansion of
(1 + x) .
n
⌊x⌋ and ⌈x⌉ The largest integer not greater than x and the smallest integer integer not
less than x respectively.
gcd(a, b) (for brevity, (a, b)) and lcm(a, b) (for brevity, [a, b]) are greatest common di-
visor and least common multiple of a and b respectively.
a
(p) The Legendre symbol for an integer a and prime p.
e
Λ(n) Von Mangoldt Function of n. Λ(n) = log p if n = p for some positive integer e,
otherwise Λ(n) = 0.
φ(n) The number of positive integers not exceeding n which are relatively prime to n.
Fundamentals
CHAPTER I.
DIVISIBILITY
Let us start from the very basics. Whenever you encounter a definition, try to make
sense of it with a few examples. As we move on to next sections, you will get used to
the divisibility terms and notation. The following definitions are designed to teach a
beginner student the basics of divisibility, so please do not bore yourself with them. This PDF was created
for Amazon.
Note (1). We will prove later that the minimum remainder is unique. That is, there
exists exactly one value for r such that b = aq + r and 0 ≤ r < a. Because of its
uniqueness and non-negativity, remainder in this book will mean minimum remainder
unless otherwise stated.
Note (2). When we talk about the the minimum absolute remainder in the division
b = aq + r, note that if a is odd, we will have a unique r. That is, there exist only one
possible value for r such that ∣r∣ ≤ ∣a/2∣. However, if a and b both are even, there can
be two possible values for r. For example, if a = 20 and b = 8, the division can be done
as both 20 = 8 ⋅ 2 + 4 and 20 = 3 ⋅ 8 − 4 and we would have two values for r: 4 and −4.
To force r to be unique in this case, we will take the positive value of r as the minimum
absolute remainder. Therefore, in our example, 20 = 2 ⋅ 8 + 4 would be accepted as the
division equation and r = 4 is the minimum absolute remainder.
∣x∣ is the absolute value of x.
1
§1. Definitions and Propositions Masum Billal, Amir Hossein
.
Remark . Some (Eastern) authors use the notation b .. a instead of a ∣ b, but it is not
as common.
Definition. If a divides b and ∣a∣ < ∣b∣, the number a is called a proper divisor of b.
Here, ∣a∣ denotes the absolute value of a. For example, ∣ − 5∣ = 5 and ∣5∣ = 5.
Example. 4 ∣ 20 and 5 ∣ 20 but 11 ∤∣ 20.
Example. 1 is a divisor of all integers.
You can also try to make sense of division in this way: 8 divides 40 because 40 has
every factor that 8 has in it. In other words, if 8 had a factor which was not a factor
of 40, then 40 would not be divisible by 8. For example, 42 does not have the factor 4,
which is a factor of 8, therefore 8 ∤ 42.
Prime and Composite Numbers. An integer n > 1 is called prime if it has exactly
two distinct (positive) divisors, namely 1 and n itself. A number greater than 1 which
is not a prime is composite. In other words, an integer n is composite if it has a proper
divisor other than 1. We do not wish to discuss primality for negative integers.
16
§1. Definitions and Propositions Masum Billal, Amir Hossein
Parity. Parity is the property of an integer being even or odd. An even number is
one which is divisible by 2. Odd numbers, on the other hand, leave a remainder of 1
when divided by 2.
Example. 2 and 4 have the same parity; they are both even. 5 and 10 are of different
parity; 5 is odd and 10 is even.
Example. 11 is a prime because no positive integer greater than 1 and less than 11
divides it. Similarly 2, 3, and 29 are primes, but 169 (divisible by 13) and 1001 (why?)
are composites. If a number is divisible by 2, it is composite. Thus, the only even prime
is 2.
If we add or subtract two numbers of the same parity, the answer will be even.
Conversely, the result of addition or subtraction of two numbers with different parities
is always an odd number. Using these two facts, you can easily find many properties of
integers related to parity. For instance, we can say that if we add or subtract an even
number to or from a positive integer n, the parity does not change; i.e., parity remains
invariant in this case. Moreover, any odd multiple of n has the same parity as n.
We usually deal only with positive integers in divisibility relations. However, some-
times negative integers or zero also come into play.
Proposition 1 (Basic Properties of Divisibility). For any three integers a, b, and c, the
following statements are true.
1. a ∣ 0.
2. a ∣ a.
3. 1 ∣ a and −1 ∣ a.
4. If a is non-zero, then 0 ∤∣ a.
2
9. If a ∣ b and b ∣ c, then a ∣ c.
3
10. If a ∣ b and b ≠ 0, then ∣b∣ ≥ ∣a∣. Consequently, if a ∣ b and ∣a∣ > ∣b∣, then b = 0.
2
Does zero divide zero? That depends on the context. In arithmetic, we can write 0 = 0 ⋅ 0 + 0,
so technically 0 ∣ 0 in number theory. However, when studying real analysis, division is defined as
multiplying by the multiplicative inverse, which means that 0/0 is undefined and therefore, 0 ∤∣ 0 with
that logic.
3
Keith Conrad states this as a mantra: “A factor of a factor is a factor.”
17
§1. Definitions and Propositions Masum Billal, Amir Hossein
Proof. Most of the parts are trivial and we prove only the important ones. A general
approach to solve this kind of problems is simply transforming them into equations.
That is, when x ∣ y, write y = kx for some integer k.
4. Assume that 0 ∣ a for some integer a. This means that a = 0k for some integer k.
Therefore, a = 0 is the only integer that is divisible by zero (in number theory).
9. a ∣ b and b ∣ c, so b = aq1 and c = bq2 for some integers q1 and q2 . Combine these
two equations to get c = aq1 q2 = aq, thus a ∣ c.
10. a ∣ b, so b = ak for some integer k. Rewrite this equation in absolute value terms:
∣b∣ = ∣ak∣ = ∣a∣ ⋅ ∣k∣. Since k is a non-zero integer, the smallest value for ∣k∣ is 1,
so ∣b∣ = ∣a∣ ⋅ ∣k∣ ≥ ∣a∣.
Note. You may think that it is straightforward to prove statement (12) in the above
Proposition. However, it is not so simple. The reason is we need to prove that if
n
b b n
= ( a)
an
Proof. The proof is quite simple using part 10 of the previous proposition. In fact, we
get ∣b∣ ≥ ∣a∣ and ∣a∣ ≥ ∣b∣, which means ∣a∣ = ∣b∣ or a = ±b.
The above proposition often comes handy when you want to prove that two expres-
sions are equal. If you can show that each expressions divides the other one and that
they have the same sign (both positive or both negative), you can imply that their
values are equal.
Proposition 3. For fixed positive integers a and b, there are unique integers q and r
so that b = aq + r with 0 ≤ r < a. In other words, the quotient and the minimum
remainder of the division are unique.
Proof. We can easily rule out the case r = 0. Just notice that a ∣ b.
We can now assume that a ∤ b. Then, b must have a nonzero remainder upon division
by a, say r. One can rewrite the equation b = aq + r as aq = b − r or q = (b − r)/a.
This simply means that uniqueness of r implies the uniqueness of q. Therefore, we only
′ ′
need to prove that r is unique. Assume that there exist integers q and r so that
b = aq + r
′ ′
= aq + r
18
§1. Definitions and Propositions Masum Billal, Amir Hossein
The answer is clearly no. Since r and r are both less than a, we have ∣r − r∣ < a.
′ ′
means two remainders are the same and the minimum remainder is unique. The proof
is complete.
Question. We know that 4 ∣ 20 and 4 ∣ 16. Do they imply 4 ∣ 20 + 16? Again, this is
not too obvious. Try to prove it first.
Proposition 4. If a ∣ b and a ∣ c, then a ∣ bx + cy for any arbitrary integers x and y.
In particular, we have a ∣ b ± ak, a ∣ b + c, and a ∣ b − c.
Proof. Since a ∣ b, there is an integer k so that b = ak. Similarly, there is an integer ℓ
so that c = aℓ. Therefore,
bx + cy = akx + aℓy
= a(kx + ℓy)
which is certainly divisible by a since it has a factor a in it.
Note. Here, x and y can be negative integers as well. This shows how negative numbers
may come into play even when we start off with positive integers.
Question. Let a, b, and n be positive integers such that a ∣ n and b ∣ n. Do we have
ab ∣ n?
This is a very common mistake among new problem solvers. Consider an integer
that is divisible by both 6 and 4. Is that integer divisible by 4 ⋅ 6 = 24? If you think
the answer is yes, think again! How about 12?
In general, the answer is a big NO. Try to find a few more counterexamples and
then find the condition when we can be certain that ab ∣ n if a ∣ n and b ∣ n. We will
now focus on prime divisors.
Proposition 5. Any integer n greater than 1 has a prime divisor.
Proof. If n itself is a prime, we are done. So, assume n is composite. By definition,
n has a proper divisor, i.e., there is an integer greater than 1 and less than n which
divides n. Call this divisor d. Now, if d is not a prime, then d has a divisor too. We can
continue like this until we reach a point where d does not have a proper divisor greater
than 1. We know by definition that only a prime number does not have a proper divisor
other than 1. Therefore, that divisor must be a prime.
Corollary 1. Let n be a positive integer larger than 1. The smallest divisor of n is a
prime.
You should be able to prove the following proposition by yourself. Even if you can
not prove it formally, at least make sense of why this is true. We will not prove it here.
4
Try not to skip it and move on. Can you use induction to prove it? How about using
the facts you already know?
4
The traditional induction process. Prove the claim for a base case, say n0 . Assume the claim is
true for n = m, then prove it for n = m + 1.
19
§1. Definitions and Propositions Masum Billal, Amir Hossein
Corollary 2. If a prime divides the product of some integers, it divides at least one of
them.
√
Proposition 7. Every composite n has a prime factor less than or equal to n.
Proof. Since n is composite, it has at least one proper prime divisor. Consider the
smallest prime factor p of n and write n = pk for some integer k. Of course p ≤ k,
because otherwise according to Corollary (1), the smallest prime factor would be k or
one of its divisors. Therefore,
2
n = pk ≥ p
√
which in turn implies p ≤ n.
This proposition is quite useful to test the primality of a number. It implies that
√
it suffices to check if n is divisible by any of the primes less than or equal to n. If
it is, then n is not a prime. Check this with some simulations by hand, say for 11, 25,
and 479. However, the test can be quite lengthy and tedious if n is too large and its
smallest prime factor is not small. If you are curious how lengthy this test can be, take
the number 357 879 581 and try finding its smallest prime divisor.
Prime Factorization. Prime factorization is the process of finding all the prime
factors of a positive integer.
The fact that every positive integer greater than 1 has a prime factorization gives
birth to the Fundamental Theorem of Arithmetic.
where p1 , p2 , ⋯pk are different primes and e1 , e2 , ⋯ek are positive integers. Using prod-
uct notation, we can write equation (1) as
k
e
n = ∏ pi i
i=1
e
= ∏p
p∣n
In the second product notation above, p runs through all primes dividing n and e is the
5
maximum power of p that divides n.
5
Make sure you understand the notations ∑ and ∏.
20
§1. Definitions and Propositions Masum Billal, Amir Hossein
Proof. We first prove by induction that the factorization indeed exists. Suppose that
all numbers k such that 1 < k < n have a factorization. If n is a prime, its factorization
is obvious. Otherwise, there exist positive integers a and b both less than n such that
α α α
ab = n. By induction hypothesis, a and b both have factorizations. Let a = p1 1 p2 2 ⋯pk k
β β β
and b = q1 1 q2 2 ⋯ql l be the prime factorizations of a and b. Then,
n = ab
α α α β β β
= p1 1 p2 2 ⋯pk k q1 1 q2 2 ⋯ql l
This is a prime factorization for n and the induction is complete.
Now, let us prove that the prime factorization of n is unique. Suppose that there
are two factorizations for n. That is,
α α α β β β
(2) p1 1 p2 2 ⋯ps s = q1 1 q2 2 ⋯qt t
are two factorization of n, where pi and qj are primes and αi and βj are positive
β β β
integers (1 ≤ i ≤ s, 1 ≤ j ≤ t). The above equation implies that p1 divides q1 1 q2 2 ⋯qt t .
By generalization of Euclid’s lemma (Corollary (2)), p1 must divide at least one of
β β β β
q1 1 , q2 2 , . . . , or qt t . Without loss of generality, suppose that p1 ∣ q1 1 . Since q1 is a
β
prime, the only prime divisor of q1 1 is q1 . This means that p1 = q1 and α1 = β1 . Divide
both sides of equation (2) by p1 to obtain
α α α β β β
p2 2 p3 3 ⋯ps s = q2 2 q3 3 ⋯qt t
α βj β
With similar reasoning, we can deduce that p2 2 is equal to some other qj , say q2 2 .
Continuing this process, one soon realizes that t = s and all prime powers in the left
side of equation (2) appear in the right side, but maybe in a different order. In other
words, the two factorizations of n are the same and the uniqueness of factorization is
implied.
Example. Try to understand the following examples and match them with the factor-
ization formula:
2
• 12 = 2 ⋅ 3. Here, p1 = 2, e1 = 2, p2 = 3, e2 = 1
2 2
• 180 = 2 ⋅ 3 ⋅ 5. So, p1 = 2, e1 = 2, p2 = 3, e2 = 2, p3 = 5, e3 = 1
The factorization of n is unique no matter in what order you factor out the primes.
Also, note that all the powers are positive. We could bring primes with power zero but
that does not make any sense (because any number to the power of zero yields 1 and
the product would not be changed).
k
e
Note. In the product n = ∏ pi i , k is the number of distinct prime factors of n. For
i=1
example, if n = 12, then k = 2 since 12 has only two distinct prime factors: 2 and 3. If
n = 180, then k = 3 because 2, 3, and 5 are the only prime factors of n.
As explained above, one way to factorize a number n is to divide it by all primes less
√
than n. Dividing a number by another would be pretty boring for large numbers. In
order to simplify the process, next section provides some rules for divisibility by some
specific numbers like 3, 5, 7, 11, etc.
21
§1. Definitions and Propositions Masum Billal, Amir Hossein
x = xk−1 xk−2 . . . x1 0 + x0
= 10 ⋅ xk−1 xk−2 . . . x1 + x0
It is now clear that the first term in the right-hand side of the latest equation is divisible
by 2 (because 2 ∣ 10). So, x is divisible by 2 if and only if x0 is even.
The proof of the rule of divisibility by 5 is very similar and left as an exercise for
the reader.
Proposition 9 (Divisibility by 5). A number is divisible by 5 if and only if it has 0 or
5 as last digit.
So far, we discovered and proved the rules of divisibility by 2 and 5. Is it always
possible to find a divisibility rule for division by a given arbitrary number n? Maybe
the question is somehow unclear at the moment. We need to define a divisibility rule
first:
Definition. Let n > 1 be any integer. A divisibility rule for n is defined to be a
process which leads to determining whether a given natural number is divisible by n.
Let’s think about the question again. Can we find a divisibility rule for any n > 1?
The answer is obviously yes. With our definition of a divisibility rule, you can consider
division by n as a divisibility rule. One can always divide a natural number by n and
find the remainder of the division. The number is divisible by n if and only if this
remainder is equal to zero.
Well, of course, that is not what we had in mind. We are looking for divisibility
rules that make our life simpler, not the ones which ask you to do it by brute force. So,
it would be wise to refine our definition:
Definition. Let n > 1 be any integer. A proper divisibility rule for n is a divisibility
rule which uses a recursive algorithm. From now on, by a divisibility rule, we mean a
proper one.
As an example, recall the rule of divisibility by 3. To find out the remainder of a
number upon division by 3, we add up all the digits to create a smaller number. This is
the recursive step: we are doing a simple process (adding the digits) to transform our
initial given number (which we suppose is large) into a new number which is smaller in
22
§1. Definitions and Propositions Masum Billal, Amir Hossein
size. Then, we find the remainder of the new smaller number by 3. We know from high
school (or elementary school) that the remainder of the new number when divided by
3 is the same as that of the original number.
In general, we are looking for divisibility rules which explain a method for creating
a smaller number from an initially large given number. This new number has one thing
in common property with the initial number: its remainder when dived by n. We can
repeat this algorithm as many times as we wish until we reach numbers small enough
for us to do the division by hand. We know that our iterative algorithm will terminate
at some point because you cannot go smaller than 1.
It is quite easy to see that the algorithm for checking divisibility by 3 is indeed
very fast and terminates quickly. That is, the algorithm is time-efficient. Suppose that
you have a 100 digit number and you want to check its divisibility by 3. Dividing the
number by 3 to find the remainder is the worst thing to do because there is probably
no calculator which can do this task for you and you would need to do the division by
hand. Now, if you use the algorithm provided above, you would need to sum up all
the digits of the number, which would be at most 100 × 9 = 900 (in case where all the
digits are the largest, 9), and then find the remainder of this sum upon division by 3. If
you are reading this text right now, you must be able to divide any three digit number
by 3 without using a calculator. So, this algorithm terminates after one iteration in
this case because you will find the remainder right after finding the sum of the digits.
Considering we started with a 100 digit number, that is assumed to be a pretty fast
algorithm.
Let’s see the mathematical idea behind the divisibility rule for 3.
Proposition 10 (Divisibility by 3). A number is divisible by 3 if and only if the sum
of digits of the number is divisible by 3.
Example. Take the number 951 which has a sum of digits 9 + 5 + 1 = 15, divisible by 3.
According to our claim, 951 should be divisible by 3 and indeed it is: 951 = 3 ⋅ 317.
Proof. The secret lies behind the fact that 10 = 3 ⋅ 3 + 1. Write your initial number
x = xk−1 xk−2 . . . x0 as
k−1 k−2
x = 10 xk−1 + 10 xk−2 + ⋯ + 10x1 + x0
k−1 k−2
= (3 ⋅ 3 + 1) xk−1 + (3 ⋅ 3 + 1) xk−2 + ⋯ + (3 ⋅ 3 + 1)x1 + x0
Try to show as an exercise that the remainder of division of (3⋅3+1) (for 1 ≤ i ≤ k −1)
i
is always equal to 1 (hint: you might want to use theorem Binomial Theorem). In other
words, there exist integers qi (for 1 ≤ i ≤ k −1) such that (3⋅3+1) = 3qi +1. Therefore,
i
k−1 k−2
x = (3 ⋅ 3 + 1) xk−1 + (3 ⋅ 3 + 1) xk−2 + ⋯ + (3 ⋅ 3 + 1)x1 + x0
= (3qk−1 + 1)xk−1 + (3qk−2 + 1)xk−2 + ⋯ + (3q1 + 1)x1 + x0
= 3(qk−1 + qk−2 + ⋯ + q1 ) + xk−1 + xk−2 + ⋯ + x1 + x0
It is now clear that 3(qk−1 + qk−2 + ⋯ + q1 ) is always divisible by 3. This means that
the remainder of x upon division by 3 is the same as that of xk−1 + xk−2 + ⋯ + x1 + x0 ,
which is the sum of digits of x. It remains to verify the other direction, but all we did
can be reversed and so the other direction also follows. The proof is complete.
23
§1. Definitions and Propositions Masum Billal, Amir Hossein
You might be curious if we can find such simple proper divisibility rules for other
numbers. Unfortunately, the recursive algorithms we find for (most of) other numbers
are not always time-efficient like that of 3 and it is possible that we need to wait for
several iterations for the algorithm to terminate.
Another issue that we need to discuss is the following: for which numbers n do we
really need a divisibility rule? For instance, now that we know the divisibility rules
for 2 and 3, do we really need another rule for divisibility by 6? No! We know that a
number is divisible by 6 if and only if it is divisible by both 2 and 3. If the previous
sentence is not clear for you, think about it for a few minutes and investigate some
examples to see why it is true. You don’t need to know a rigorous proof of this fact;
just convince yourself that it is true.
We got that there is no need for us to define a divisibility rule for 6 because we
already know rules for 2 and 3. There is nothing special about 6 = 2 ⋅ 3. In general, we
do not need a divisibility rule for pq, where p and q are distinct primes, if we already
have rules for p and q.
Proof. The only if part is pretty obvious: if n is divisible by pq, then it is divisible by
both p and q. To prove the if part, assume that a positive integer n is divisible by both
p and q. From divisibility by p, we can write n = pk for some integer k. Since p and q
are different, p is not divisible by q. Since n = pk is divisible by q, we must have that q
divides k. This means that k = ql for an integer l. Finally, n = pql, which implies that
n is divisible by pq.
You have probably figured out where this is going: we only need divisibility rules
for n when n is either a prime or a power of a prime. The other cases would follow
from the next corollary of proposition (12) (can you explain why?).
Corollary 3. Let m and n be two positive integers (not necessarily primes) which do
not share any common divisors. Then, a number is divisible by mn if and only if it is
divisible by both m and n.
We said that in order to find divisibility rules for all natural numbers, we need a
divisibility rule for primes as well as their powers. Finding divisibility rules for powers
of primes other than 2, 3, and 5 would not be something of interest for our book. We
2
will discuss only divisibility rules for powers of 2. Let’s see the most basic case, 4 = 2 .
Example. 202 390 2348 has the last two digits 4 and 8 which make the number formed
by its last two digits 48. Since 48 is divisible by 4, the number 202 390 2348 is divisible
by 4.
24
§1. Definitions and Propositions Masum Billal, Amir Hossein
3
What about 2 = 8?
If you have a curious mind, you should already notice a pattern in the divisibility
rules for 2, 4, and 8. For 2, we only check the last digit. For 4, we check the last two
1 2
digits and for 8, the last three digits. Do you see the pattern now? 2 = 2 , 4 = 2
3 4
and 8 = 2 . You can easily check that the same is true if we take 16 = 2 . To check
divisibility by 16, it suffices to test the number formed by the last 4 digits. We can
k
generalize this result for 2 .
k
Theorem 2 (Divisibility by 2 ). Let k be a positive integer. A number x is divisible
k k
by 2 if and only if the number formed by the last k digits of x is divisible by 2 .
Proof. To prove this one, suppose that you have an n digit number x, represented as
x = xn−1 ⋯x1 x0
= xn−1 ⋯x3 000 + x2 x1 x0
3
= 10 ⋅ xn−1 ⋯x3 + x2 x1 x0
The remainder of division of 1000 by 7 is 6. So, there exists a positive integer q such
that 1000 = 7q − 1 (why is that? find q). Hence,
Now, if x is divisible by 7, then so must be x2 x1 x0 − xn−1 ⋯x3 and vice versa. The proof
is complete.
25
§1. Definitions and Propositions Masum Billal, Amir Hossein
Example. Take the number 13 111. To see if it is divisible by 7 or not, first separate
the number into two parts: Form a number with last three digits and another with the
other part. In this case, we have 111 and 13. Their difference is 98, which is divisible
by 7. According to the rule of divisibility by 7, this number is divisible by 7.
There are other rules for divisibility as well, and we are just suggesting a selected
one for each number. You might have seen other divisibility rules for 7 (and other
numbers). Another famous divisibility rule for 7 is the following: take the last digit of
the number, double it, and then subtract the result from the number formed by the
rest of the digits. The resulting number would have the same remainder upon division
by 7. For instance, the steps for 13 111 would be
13 111 ⟹ 1 311 − 2 = 1 309
1 309 ⟹ 130 − 18 = 112
112 ⟹ 11 − 4 = 7
and this verifies that 13 111 is divisible by 7. Try to prove this new divisibility rule for
7.
It is very important to bear in mind that each divisibility rule is time-efficient when
applied to a number with proper number of digits. For instance, the divisibility rule
for 7 given in proposition (15) works best for numbers with a few digits (say, 6 to 10
digit numbers) and if your number has, say, 100 digits, you would need to wait for a
long time for the algorithm to terminate because you are removing three digits from
your number at each step and a 97 digit number is not much different from a 100 digit
number when it comes to computation: they are both huge! Try to figure out for what
range of numbers the other divisibility rule for 7 works best.
Proposition 16 (Divisibility by 9). A number is divisible by 9 if and only if the sum
of its digits is divisible by 9.
Proposition 17 (Divisibility by 11). A number is divisible by 11 if and only if the
difference of sums of alternating digits is divisible by 11.
Example. Take 12 047 816. The sum of digits in even places is 2 + 4 + 8 + 6 = 20 and
sum of digits in odd places 1 + 0 + 7 + 1 = 9. Their difference is 20 − 9 = 11, which is
divisible by 11. You can easily check that
12 047 816 = 11 ⋅ 1 095 256
which verifies our test.
Proposition 18 (Divisibility by 13). A number is divisible by 13 if and only if the
result of addition of four times the last digit and the the number formed by rest of the
digits is divisible by 13.
Example.
8658 ⟹ 865 + 4 ⋅ 8 = 897
897 ⟹ 89 + 4 ⋅ 7 = 117
117 ⟹ 11 + 4 ⋅ 7 = 39
And 39 = 13 ⋅ 3, so 8658 is divisible by 13.
26
§2. GCD and LCM Masum Billal, Amir Hossein
Consider 18 and list all its divisors in your mind. Do the same for 27. What do these
two lists have in common? If you have done the calculations correctly, you should come
up with 1, 3, and 9. Among these common divisors of 18 and 27, 9 is the largest. So,
we say that 9 is the greatest common divisor of 18 and 27.
Consider 18 and 27 again. This time, list all their integral multiples mentally. The
list of multiples of 18 is
18, 36, 54, 72, 90, 108, ⋯
whereas the list of multiples of 27 is
27
§2. GCD and LCM Masum Billal, Amir Hossein
There are infinitely many common numbers shared by these two lists: 54, 108, ⋯. The
smallest number in the latter list is 54, which we call the least common multiple of 18
and 27.
You may ask, what makes you think there will even be a common element in both
sets? Well, we will have at least 1 common as a divisor since it divides all the integers.
GCD and LCM. For two integers a and b which are not zero at the same time,
the greatest common d ivisor of a and b, denoted by gcd(a, b), is the greatest positive
integer which divides both a and b. For brevity, we denote this by (a, b) in this book.
The l east common multiple of a and b, denoted by lcm(a, b), is the smallest positive
integer that is divisible by both a and b. Again, for brevity, we denote this by [a, b] in
this book.
The concept of gcd and lcm is the same for more than two integers. The greatest
common divisor of a1 , a2 , ⋯, an is the largest positive integer which divides them all.
We denote this by (a1 , a2 , ⋯, an ). One can define [a1 , a2 , ⋯, an ] in a similar way.
Example. (18, 27) = 9 and [18, 27] = 54. (18, 27, 36) = 9 and [18, 27, 36] = 108.
Note. The above definition of gcd is equivalent to the following: if (a, b) equals g, then
g divides both a and b. Furthermore, if there is a positive integer c for which c ∣ a and
c ∣ b, then g ≥ c. Analogously, if [a, b] equals ℓ, then ℓ is divisible by both a and b.
Moreover, if there is a positive integer c for which a ∣ c and b ∣ c, then c ≥ ℓ.
Proposition 21 (Properties of gcd and lcm). Let a and b be two positive integers.
The following statements are true.
1. (a, b) = (b, a) = (a, −b) = (−a, −b) and [a, b] = [b, a] = [a, −b] = [−a, −b].
2. (a, 0) = a, [a, 0] = 0, (a, 1) = 1 and [a, 1] = a.
3. (a, a) = [a, a] = a.
4. [a, b] ≥ (a, b).
5. a ∣ b if and only if (a, b) = a. Similarly, a ∣ b if and only if [a, b] = b
6. For any integer k, (a, b + ak) = (a, b) and (ka, kb) = k(a, b). Furthermore,
[ka, kb] = k[a, b].
7. For any non-negative integer n, we have (a , b ) = ((a, b)) and [a , b ] =
n n n n n
([a, b]) .
n
p if p ∣ a
(a, p) = {
1 otherwise
28
§2. GCD and LCM Masum Billal, Amir Hossein
The proofs are pretty obvious and the reader is encouraged to prove them as an
exercise. We only provide a hint for part 4: use part 10 of proposition (1).
We will now prove part 12 of proposition (1) as a problem.
Problem 2. For integers a and b, if a ∣ b for some positive integer n, then a ∣ b.
n n
Definition. Two positive integers are relatively prime or relatively prime to each other
if their greatest common divisor is 1. We shall use a ⊥ b to denote that (a, b) = 1, i.e.,
that a and b are relatively prime.
29
§2. GCD and LCM Masum Billal, Amir Hossein
Proof. Let g = (a, b). We already know that g ∣ a and g ∣ b. Since b = aq + r, it follows
that g ∣ aq + r. On the other hand, g ∣ a implies g ∣ aq. As established in proposition
(4), we can subtract these two divisibility relations and find g ∣ aq + r − aq, or g ∣ r.
This means that g divides r too. That is, the greatest common divisor of a and b is
a divisor of r too. In order to show that g = (a, r), there is only one thing remained
to prove: if there exists some c for which c ∣ a and c ∣ r, then g ≥ c. We will prove
a stronger argument: if such a c exists, then c ∣ g (since c and g are both positive,
c ∣ g implies g ≥ c). Note that c ∣ a gives c ∣ aq. Adding the latter relation with c ∣ r
yields c ∣ aq + r = b. From proposition (22), we see that c ∣ (a, b) = g. The proof is
complete.
6
Euclidean algorithm is pretty useful because it helps us find the gcd only by a
series of divisions. Suppose that you have two extremely large numbers a and b such
that b > a. First, find the remainder r of b upon division by a. The remainder is
strictly less than a, and there is a chance that it would be much smaller than b because
b > a > r. According to Euclidean algorithm, instead of finding gcd of a and b, we can
calculate (a, r). In the next step, find the remainder r1 of a upon division by r. Then
(a, b) = (a, r) = (r, r1 ). As you might have noticed, the numbers are becoming smaller
and smaller. Continuing the divisions, you will reach a point where the numbers are
small enough to compute the gcd by hand.
Corollary 4. Let n, a, and b be positive integers such that n ∣ a−b. Then (n, a) = (n, b).
The proof of this corollary is exactly the same as the previous theorem. If you look
closely, you will find that we did not make use of the given inequality 0 ≤ r < a in the
process of proving Euclidean algorithm. In fact, that condition is given only to make
the algorithm more efficient.
To make sense of Euclidean algorithm, follow the next example.
Example. Let’s find (112, 20). The first division 112 = 20 ⋅ 5 + 12 gives (112, 20) =
(20, 12). By performing the second division, 20 = 12 ⋅ 1 + 8, we obtain(20, 12) = (12, 8).
The next steps result in (12, 8) = (8, 4) and (8, 4) = (4, 0). The gcd of any number and
zero is the number itself. So, (20, 112) = 4. If you understood the process correctly,
you will know that the algorithm terminates when one of a or b becomes 0.
The other way of finding the greatest common divisor relies on factorization. Before
stating the related proposition for this method, we solve the previous example again by
factorizing.
Example. First, factorize both 20 and 112:
2
20 = 2 ⋅ 5
4
112 = 2 ⋅ 7
You can easily find that since the prime factor 5 does not appear in the factoring of
112, 5 cannot appear in (20, 112). For the same reason, 7 will not appear in the gcd as
well. In other words, we just have to consider the primes that are in both 112 and 20.
6
An algorithm means a set of operations in a certain process to solve a problem or to find something.
30
§2. GCD and LCM Masum Billal, Amir Hossein
We are left with the only prime 2. The point is to pay attention to the power of 2 that
4 2
divides the numbers. 112 is divisible by 2 . However, 20 is divisible by 2 but not by
any higher power of 2. Therefore, (20, 112) cannot have a power of 2 greater than 2
2
(otherwise it will not divide 20). Since we are looking for the greatest common divisor,
2
we will take 2 as proper power of 2 in the gcd. Since there is no other prime to take
care of, we have (112, 20) = 2 .
2
Do the simulation for a few more examples to convince yourself. The following
proposition formalizes this method.
e e e
Proposition 24. Let a and b be two positive integers. If a = p11 p22 ⋯pkk and b =
f f f 7
p11 ⋅ p22 ⋯pkk , where pi are primes and ei , fi ≥ 0 are integers for 1 ≤ i ≤ k, then:
min(e1 ,f1 ) min(e2 ,f2 ) min(e ,f )
(a, b) = p1 p2 ⋯pk k k
max(e1 ,f1 ) max(e2 ,f2 ) max(ek ,fk )
[a, b] = p1 p2 ⋯pk
Note. This idea can be generalized for finding gcd or lcm of n integers. Just factorize
the numbers and select the proper powers of primes.
Proposition 25. For two integers a and b with g = (a, b), there exist integers m and
n such that a = gm and b = gn. Moreover, m and n are relatively prime.
Proof. Integers m and n exist because g ∣ a and g ∣ b, but why are m and n relatively
prime? This is true because if there were any other common factor between m and n,
that would have been included in g too. Otherwise, g could not remain the greatest
common divisor since we can make a bigger one multiplying that common factor with
g. We can think of m and n as the uncommon factors between a and b.
7
Try to find out why ei ≥ 0 whereas we consider only ei ≥ 1 when we first introduced prime
factorization.
31
§3. GCD and LCM Masum Billal, Amir Hossein
Example. Consider 18 and 27. (18, 27) = 9 and we can write 18 = 9 ⋅ 2 and 27 = 9 ⋅ 3.
Now, 9 is the largest common factor. Here, 2 is the uncommon factor from 18 which
27 does not have besides 9, and 3 is the uncommon factor of 27 which 18 does not have
apart from 9. Thinking about m and n in this way may make more sense to you.
Proposition 26. Let g and ℓ be the greatest common divisor and the least common
multiple of positive integers a and b, respectively. If we write a = gm and b = gn with
(m, n) = 1, then ℓ = gmn.
Proposition 27. Let g = (a, b) and ℓ = [a, b]. Then ab = gℓ. In words, the product of
two positive integers is equal to the product of their gcd and lcm.
First proof. By proposition (25), there exist relatively prime positive integers m and n
2
such that a = gm and b = gn. Therefore ab = gm ⋅ gn = g mn. On the other hand, by
2
proposition (26), gl = g ⋅ gmn = g mn.
The following proof uses prime factorization and is somewhat more rigorous. But
the previous one makes more sense. Even though it may look uglier, it shows how to
invoke prime factorization.
Second Proof (Using Prime Factorization). Assume that we have the prime factoriza-
tion of a and b (as in proposition (24)):
e e
a = p11 ⋯pkk
f f
b = p11 ⋯pkk
Now, can you understand the simple fact that min(x, y) + max(x, y) = x + y? If so,
then the proof should be clear to you. In fact,
e e f f e +f1 e +fk
ab = p11 ⋯pkk ⋅ p11 ⋯pkk = p11 ⋯pkk
32
§3. Numeral Systems Masum Billal, Amir Hossein
§3 Numeral Systems
§3.1 Introduction
There is a rumor that Pascal once promised 1000000 dollars to anyone who marries his
daughter. Later, when the son-in-law asked for the money, Pascal gave him only 64
dollars. Poor guy! If you got the joke, you are probably good with bases. If not, do
not worry, keep reading and you will get the point.
In daily mathematics, meaning the math you face in real life, you unconsciously
express numbers in decimal system. That is, when you say you have 15 apples, you
are using base 10 without ever realizing it. The question here is that what is this base
actually? Let us start with a simple example.
Example. Consider the number 573. Have you ever thought why we write digits in this
way to denote a number? The reason is that every digit in the number represents the
coefficient of a power of ten. That is,
2 1 0
573 = 5 ⋅ 10 + 7 ⋅ 10 + 3 ⋅ 10
Rigorously talking, each integer has to be written in a base for it to make sense. For
example, the number 15 has different values when expressed in base 6 and in base 10.
Actually, 15 in base 6 is equal to 11 in base 10. Probably it still does not make sense.
If so, just keep reading.
All of our calculations in daily life are done in base 10, which is called the decimal
system. However, this does not mean that we cannot present numbers in any other
bases other than 10. There are a limited number of digits in each base (to be precise,
the number of digits is the same as the value of base). These digits run from 0 to the
8
largest integer smaller than the base. Therefore, in base 10 the digits are 0, 1, ⋯, 9 .
Similarly, in base b the digits will be 0, 1, ⋯, b − 1. Observe the base-10 representation
of 573 in the above example again. The rightmost digit is multiplied by 1. The middle
digit, 7, is multiplied by 10 (hence the name tenths digit). Finally, the leftmost digit
is multiplied by 100 (the hundredths digit). In simpler words, each time we go left, we
multiply the multiplier by 10. If it were base b instead of base 10, we would multiply by
2
b each time. So, the multipliers would be 1, b, b , ⋯ and so on. You should understand
the formal representation of an integer in base b (for b > 1 an integer). Note that it is
pointless to take base 1 since we do not have any meaningful digit (recall that 0 is not
a meaningful digit). You can think of these multipliers as weights (or contribution) of
those digits.
Base b Representation. Let x and b be positive integers such that b > 1. In a
numeral system , the number x and its base b are written together as (x)b . If the digits
9
8
Take a wild guess why we use base 10 and not any other base.
9
A numeral system (or system of numeration) is a writing system for expressing numbers using
digits or symbols.
33
§3. Numeral Systems Masum Billal, Amir Hossein
34
§3. Numeral Systems Masum Billal, Amir Hossein
when they are represented in decimal system. For example, you may have no clue about
the real value of (1234)5 , but you surely know what is 1234 (if we do not write the base,
it is 10 by default).
10 = A, 11 = B, 12 = C, 13 = D, 14 = E, 15 = F.
Example.
4 3 2
(2FE05)16 = 2 ⋅ 16 + 15 ⋅ 16 + 14 ⋅ 16 + 0 ⋅ 16 + 5
= 131, 072 + 61, 440 + 3, 584 + 5
= 196, 101
We know how to convert numbers in any base to a number in base 10. The next
step is exactly the opposite: converting numbers in decimal system to other bases. This
is quite interesting as well. Even it is possible that you have learned the method from
school. However, instead of focusing on the method, let us focus on finding a way to
do it.
where 0 ≤ xi < b for 0 ≤ i ≤ n. Our aim is to find the value of xi ’s. Look at the
equation carefully and try to understand how we can retrieve the digits in base b. If
you are stuck, then go forward. Rewrite equation (3) as
n−1 n−2
y = b ⋅ (b xn + b xn−1 + ⋯ + x1 ) +x0
Í ÎÌ Ï
y1
We have written y as y = by1 + x0 , which means that the remainder of y when divided
by b is x0 . In fact, the rightmost digit of y in base b (x0 here) is the remainder of y
35
§3. Numeral Systems Masum Billal, Amir Hossein
when divided by b. As you can see, we are simply using the division theorem here (does
it make sense now?). Bases are related to divisibility after all!
To find the next digit, x1 , we have to divide the quotient of the above division, y1 ,
by b. The reason is the same as above: rewrite y1 as
n−2 n−3
y1 = b ⋅ (b xn + b xn−1 + ⋯ + x2 ) +x1
Í ÎÌ Ï
y2
Therefore, x1 is the remainder of y1 when divided by b. We can find the next digit x2 by
finding the remainder of y2 when divided by b. The digits x3 , x4 , ⋯, xn−1 can be found
similarly by continuing this process. The leftmost digit, xn , is the quotient of the last
division because we can no longer divide it by b (since the digits are all less than b).
Example. Let us find the representation of 215 in base 8 and base 2. Start with base
8 first. We initialize the process by dividing the given number by 8. The remainder of
this division is the rightmost digit of 215 in base 8. Then we divide the quotient by 8
again. The remainder of this division is the digit before the rightmost one. Since the
quotient of this division is less than 8, the process is over. Using long division:
26 3
8 ) 215 8 ) 26
160 24
55 2
48
7
Figure 1.1: Conversion process of 215 from decimal system to octal (base 8).
In different countries, people use different ways to demonstrate long division. The
above way is usually used in English-speaking countries such as USA or Canada. In
European and Asian countries, people (mostly) use the following way of doing long
division:
215 8 26 8
− −
16 26 24 3
55 2
−
48
7
Figure 1.2: Conversion process of 215 from decimal to octal with divisions done in a
different way (common in Europe and Asia).
36
§3. Numeral Systems Masum Billal, Amir Hossein
Thus, 215 = (327)8 , which matches the result in previous section. To find 215 in
base 2, we do the divisions as follows. If this is not how you do long divisions, just do
them in your own way.
107 53 26 13 6 3 1
2 ) 215 2 ) 107 2 ) 53 2 ) 26 2 ) 13 2 )6 2 )3
200 100 40 20 12 6 2
15 7 13 6 1 0 1
14 6 12 6
1 1 1 0
Figure 1.3: Conversion process of 215 from decimal to binary (base 2).
Reading from right to left, the quotient of the first division is the leftmost digit, and
the remainders of divisions form the other digits. So, the result is (11010111)2 .
Example. Assume we want to convert the number 196 101 to base 16.
1961 01 16 12256 16 7 6 6 16 47 16
− − − −
16 12256 112 766 6 4 47 32 2
36 105 1 2 6 15
− − −
32 96 1 1 2
41 96 1 4
− −
32 96
9 0 0
−
8 0
1 01
−
96
5
Figure 1.4: Conversion process of 196 101 from decimal to hexadecimal (base 16).
10
If you write down the divisions like we did in figure (1.4), you can see that the last
quotient is the most significant digit and the remainders of the divisions (from right to
left) form the other digits (as you move from the last remainder to the first one, the
significance of the digits decreases). We have drawn circles around those digits. Finally,
writing 15 as F and 14 as E, we have
37
§3. Numeral Systems Masum Billal, Amir Hossein
Start clustering ai digits in groups of 3, starting at the right. For convenience, assume
that n + 1 is divisible by 3 (because there are n + 1 digits a0 , a1 , ⋯, an and we are
putting them in groups of size 3). Other cases when number of digits is not divisible
by 3 will be discussed later. Then, x can be represented as
n n−1 n−2
(2 an + 2 an−1 + 2 an−2 )+
n−3 n−4 n−5 2 1
(2 an−3 + 2 an−4 + 2 an−5 ) + ⋯ + (2 a2 + 2 a1 + a0 )
which is equal to
n−2 2
2 (2 an + 2an−1 + an−2 )+
n−5 2 0 2
2 (2 an−3 + 2an−4 + an−5 ) + ⋯ + 2 (2 a2 + 2a1 + a0 )
a a/3
Since 2 = 8 for all real numbers a, we can write the above as
n−2
2
8 3
(2 an + 2an−1 + an−2 ) +
Í ÎÌ Ï
bm
n−5
2 0 2
8 3
(2 an−3 + 2an−4 + an−5 ) +⋯ + 8 (2 a2 + 2a1 + a0 )
Í ÎÌ Ï Í ÎÌ Ï
bm−1 b0
The power of 8 in all of the terms in the above sum is an integer (why?). Note that the
number 2 ai +2ai−1 +ai−2 is actually (ai ai−1 ai−2 )2 , and so it is a non-negative integer less
2
than or equal to (111)2 = 7. This means that 2 ai +2ai−1 +ai−2 is acceptable as a digit in
2
base 8 (remember that digits in base b should be less than b and non-negative). Now look
m m−1
at the last line of the above equations. It is of the form 8 bm + 8 bm−1 + ⋯ + 8b1 + b0 .
We have therefore found a relation between digits in base 2 and base 8:
n−2
m=
3
2
bj = 2 a3j+2 + 2a3j+1 + a3j
= (a3j+2 a3j+1 a3j )2
38
§4. Numeral Systems Masum Billal, Amir Hossein
There is only one point remaining: we first assumed the number of digits of the binary
number is divisible by 3 so that we can group them. What if number of digits is not
divisible by 3? It is not actually a problem. Put one or two zeros at the left side of the
binary number and make the number of digits divisible by 3, then continue the process.
The above result looks a bit scary, but it is really simple in plain English, explained
in the following theorem.
Example. Let us convert (1 010 011 010)2 to base 8. Number of digits is 10, which is not
divisible by 3. So we add two zeros to the left and start the process with the number
(001 010 011 010)2 . Now,
Notice that the zero as the most significant digit is meaningless and must be removed
after the conversion is done. We suggest you to do the conversion in a two-step method
(from base 8 to base 10 and then to base 2) to verify the answer.
You can convert a binary number to base 16 just by clustering the digits into groups
of 4 and convert each group to a hexadecimal number. In general, one can use a similar
n
approach to convert a binary number to base 2 (and vice versa). However, the cases
where n is larger than 4 are rarely used.
Similar approaches can be used for conversion between other numbers as well. For
example, to convert base 3 to base 9, one should start grouping the digits in groups of
2 and then do the conversion. The theorems are pretty similar to the above and we do
not mention them here.
39
§4. Floor and Ceiling Masum Billal, Amir Hossein
⌊x⌋
1
x
−2 −1 1 2
−1
−2
40
§4. Floor and Ceiling Masum Billal, Amir Hossein
Example. ⌊3.1415⌋ = 3, ⌊−2⌋ = −2, and ⌊5⌋ = 5. Figure 1.5 shows the value of ⌊x⌋
for x between −2 and 2. For positive real numbers, the fractional part is simply the
the non-integer part of the number. For example, the fractional part of 3.14 is 0.14.
However, the definition of fractional part for negative real numbers may be deceptive.
For instance, the fractional part of −3.14 is not 0.14, but
We can generalize the above problem now. The number of integers between two
natural numbers a and b (inclusive) which are divisible by n is
b a−1
⌊n⌋ − ⌊ n ⌋ + 1
(Can you see why we are using a − 1 in the second fraction?) Here, we have assumed
that b ≥ a.
Proposition 28 (Properties of Floor Function). For any two reals x and y and any
two integers m and n,
1. x ≥ ⌊x⌋ > x − 1,
2. if n ≤ x, then n ≤ ⌊x⌋,
3. ⌊x + n⌋ = ⌊x⌋ + n,
6. ⌊⌊x⌋⌋ = ⌊x⌋,
Example. The inequality ⌊x⌋ + ⌊y⌋ ≤ ⌊x + y⌋ (as seen in part 5) is sometimes referred
to as the triangle inequality of floor function. You can easily check why this inequality
holds and find the condition in which it becomes an equality. Put x = 3.6 and y = 2.5.
Then, ⌊x⌋ + ⌊y⌋ = 5, which is strictly less than ⌊x + y⌋ = 6. The reason why we have
a strict inequality here is somewhat obvious now: 0.6 and 0.5 add up to 1.1, which is
more than one. You can easily check that only when {x} + {y} is less than one, the
equality case occurs. Otherwise, the inequality is strict.
41
§4. Floor and Ceiling Masum Billal, Amir Hossein
3. By definition, ⌊x⌋ ≤ x and so ⌊x⌋+n ≤ x+n. On the other hand, again by definition,
x < ⌊x⌋ + 1. Therefore
This means that ⌊x⌋ + n is the largest integer less than or equal to x + n and hence
⌊x + n⌋ = ⌊x⌋ + n.
4. Write x < y as ⌊x⌋ + {x} < ⌊y⌋ + {y} and then ⌊x⌋ < ⌊y⌋ + {y} − {x}. Now by parts
2 and 3,
a + b ≤ a + a1 + b + b 1
⌊x⌋ + ⌊y⌋ = a + b
≤ ⌊a + a1 + b + b1 ⌋
= ⌊x + y⌋
⌊x + y⌋ = ⌊a + a1 + b + b1 ⌋
= a + b + ⌊a1 + b1 ⌋
⎢
⎢ ⎥
⎥
⎢ ⎥
<2
⎢
⎢ Ì ÏÍ Î ⎥
⎥
⎢
⎢ ⎥
⎥
= ⌊x⌋ + ⌊y⌋ + ⎢
⎢ a + b ⎥
⎥
⎢
⎢
1 1
⎥
⎥
⎢
⎢ ⎥
⎥
⎣ ⎦
≤ ⌊x⌋ + ⌊y⌋ + 1
2. {x + n} = {x},
42
§4. Floor and Ceiling Masum Billal, Amir Hossein
⌈x⌉
1
x
−2 −1 1 2
−1
−2
3. {{x}} = {x},
Proofs are straightforward and we leave them for the reader as an exercise.
Now, we get to the other way of solving problem 3. First, we subtracted the number
of multiples less than 10. This time we find out the first multiple of 7 that is greater
than or equal to 10, and the greatest multiple less than or equal to 100 (this part is
same as before). 14 = 7 ⋅ 2 is the first multiple of 7 greater than 10. Since 98 = 7 ⋅ 14 is
the largest multiple of 7 less than 100, the answer to the problem would be the number
of integers between 2 and 14 (inclusive). There are 14 − 2 + 1 = 13 such integers.
Consequently, this makes us define ceiling. Try to make sense how this relates to the
properties of this function.
Ceiling Function. We call the function ⌈x⌉ ∶ R → Z the ceiling function and for
every real x, ⌈x⌉ (read ceiling of x) is the smallest integer greater than or equal to x.
Proposition 30 (Properties of Ceiling Function). For any two reals x, y and any two
integers m, n,
1. x ≤ ⌈x⌉ < x + 1
2. if n ≥ x, then n ≥ ⌈x⌉
3. ⌈x + n⌉ = ⌈x⌉ + n
43
§4. Floor and Ceiling Masum Billal, Amir Hossein
6. ⌈⌈x⌉⌉ = ⌈x⌉
8. ⌈x⌉ ≥ x ≥ ⌊x⌋
The proofs are pretty much the same as those of floor function and we do not provide
them here.
Theorem 6. For any two positive integers n and k, the following equation holds
n+1 n 1 if k∣n + 1
⌊ ⌋−⌊ ⌋={
k k 0 otherwise
n+1 2 n 2 2 n+1 − 1 if k ∣ n + 1
⌊ ⌋ −⌊ ⌋ ={ k
k k 0 otherwise
Proof. We will prove the first identity. The second one can be proved in a similar way.
Let n + 1 = kq + r for some positive integers q and r such that 0 ≤ r < k. Then,
n+1 n kq + r kq + r − 1
⌊ ⌋−⌊ ⌋=⌊ ⌋−⌊ ⌋
k k k k
r r−1
= ⌊q + ⌋ − ⌊q + ⌋
k k
r r−1
= (q + ⌊ ⌋) − (q + ⌊ ⌋)
k k
r r−1
=⌊ ⌋−⌊ ⌋
k k
Now, since r < k, if r ≠ 0, both ⌊r/k⌋ and ⌊(r − 1)/k⌋ are zero and so is their difference.
However, when r = 0, we have ⌊r/k⌋ = 0 and ⌊(r − 1)/k⌋ = −1 and in this case,
n+1 n
⌊ ⌋−⌊ ⌋=1
k k
x+n ⌊x⌋ + n
⌊ m ⌋=⌊ m ⌋
x+n ⌈x⌉ + n
⌈ m ⌉=⌈ m ⌉
44
§4. Floor and Ceiling Masum Billal, Amir Hossein
Proof. We only show the equality occurs for floor function. The proof for ceiling func-
tion is almost the same and is left as an exercise to the reader. Let f ∶ R → R be a
function defined by f (x) = (x + n)/m. We want to show that ⌊f (x)⌋ = ⌊f (⌊x⌋)⌋. We
know that ⌊x⌋ ≤ x. If ⌊x⌋ = x (i.e., if x is an integer) there is nothing to prove. So,
suppose that ⌊x⌋ < x. The function f (x) is strictly increasing. That is, if x1 < x2 for
two reals x1 and x2 , then f (x1 ) < f (x2 ). Therefore ⌊x⌋ < x implies f (⌊x⌋) < f (x).
Now by part 4 of proposition 28,
⌊f (⌊x⌋)⌋ ≤ ⌊f (x)⌋
We will show that ⌊f (⌊x⌋)⌋ < ⌊f (x)⌋ does not happen. Suppose on the contrary that
it does happen. Let k = ⌊f (x)⌋ and y = km − n. Then,
y+n
f (y) = m
(km − n) + n
= m
=k
= ⌊f (x)⌋
Theorem 8. Let f be any continuous and strictly increasing function with the property
that if f (x) is an integer, then so is x. Then,
⌊f (⌊x⌋)⌋ = ⌊f (x)⌋
⌈f (⌈x⌉)⌉ = ⌈f (x)⌉
Problem 4. Prove that for every positive real x, the following relations hold
√
⌊ ⌊x⌋⌋ = ⌊x⌋
√
⌈ ⌈x⌉⌉ = ⌈x⌉
45
§4. Floor and Ceiling Masum Billal, Amir Hossein
which gives m < logb n < m + 1. Since m is an integer, by definition of floor function,
m = ⌊logb n⌋.
vp (x) = α.
46
§4. Floor and Ceiling Masum Billal, Amir Hossein
Example. If p and q are two different prime numbers, then vp (p q ) = α. This can also
α β
be shown as p ∥p q .
α α β
Proposition 32. For any two positive integers x and y, and any prime p, we have
s t s+t
Proof. The first equation follows from the product rule of exponentiation (a ⋅a = a ).
To make sense the other equation, you can think of a simple example: take x = 9 and
3
y = 18. Obviously, 3 does not divide any of x or y, but it divides their sum.
This means that we have to find the largest power of p in each of integers 1, 2, ⋯, n. As
we were finding a solution for problem 3, we found out the answer to the question that
”how many integers between 1 and n are divisible by p¿‘ The answer is ⌊n/p⌋, the first
term in the sum. Similarly, there are ⌊n/p ⌋ numbers among these n numbers which
2
are divisible by p . It is now clear that vp (n!) is the sum of ⌊n/p⌋, ⌊n/p ⌋, ⌊n/p ⌋, ⋯.
2 2 3
We have chosen the upper bound of infinity since the value these floors will be zero
after somewhere. If you want to write a sum which includes only non-zero terms, the
upper bound would be vp (n) (why?).
There is another way for finding vp (n!) using bases. Before we state the alternative
version of Legendre’s theorem, we need a definition.
Definition. Let n be a positive integer and let p be a prime number. We denote by
sp (n) the sum of the standard base p digits of n. That is, if n = (nk nk−1 . . . n1 n0 )p ,
then sp (n) = nk + nk−1 + ⋯ + n1 + n0 .
Theorem 10. Let p be a prime number and let n be a positive integer. Then
n − sp (n)
vp (n!) =
p−1
47
§4. Floor and Ceiling Masum Billal, Amir Hossein
k−1
nk−1 p + ⋯ + n1 p + n0 and
k k−1
n nk p + nk−1 p + ⋯ + n1 p + n0
⌊ i⌋ = ⌊ ⌋
p pi
k−i k−i−1
= nk p + nk−1 p + ⋯ + ni+1 p + ni
48
§4. Floor and Ceiling Masum Billal, Amir Hossein
We see that three carries happen. Therefore, Kummer’s theorem tells us that (28 11
) is
3 4
divisible by 3 but not by 3 . If we calculate the value of this binomial coefficient, we
obtain
28
(11) = 21474180
2 3
= 2 × 3 × 5 × 7 × 13 × 19 × 23
which verifies our result.
Let us prove Kummer’s theorem now.
Proof. Let the representation of m, n, and m − n in base p be
k k−1
m = mk p + mk−1 p + ⋯ + m1 p + m0
k k−1
n = nk p + nk−1 p + ⋯ + n1 p + n0
k k−1
m − n = qk p + qk−1 p + ⋯ + q1 p + q0
Let’s find the number of carriers in addition of m and m − n in base p. We can write
q0 + n0 = m0 + x1 p
q1 + n1 + x1 = m1 + x2 p
..
.
qk + nk + xk = mk
49
§4. Floor and Ceiling Masum Billal, Amir Hossein
m
vp (( n )) = vp (m!) − vp (n!) − vp ((m − n)!)
a − sp (a)
vp (a!) =
p−1
where sp (a) denotes the sum of the standard base p digits of a. Therefore,
m m − sp (m) n − sp (n) (m − n) − sp (m − n)
vp (( n )) = − −
p−1 p−1 p−1
m − (mk + mk−1 + ⋯ + m0 )
=
p−1
n − (nk + nk−1 + ⋯ + n0 )
−
p−1
(m − n) − (qk + qk−1 + ⋯ + q0 )
−
p−1
(qk + qk−1 + ⋯ + q0 ) + (nk + nk−1 + ⋯ + n0 ) − (mk + mk−1 + ⋯ + m0 )
=
p−1
=s
Corollary 6. Let p be a prime and let n be a positive integer. For any positive integer
n
k such that 0 < k ≤ p ,
n
p
vp (( )) = n − vp (k)
k
n
Proof. When you add p − k and k in base p, you get a 1 followed by n zeros. Starting
the addition from the rightmost digits and moving to the left, you get a carry as soon
as both digits in the column are not zero. In other words, the first carry happens at
the first (rightmost) non-zero of k in base p and you will have a carry for all digits
after that. So, we are searching for the rightmost non-zero digit of k in base p. This is
exactly the (vp (k) + 1) digit (why?). Thus, the number of carries would be
th
50
§5. Some Useful Facts Masum Billal, Amir Hossein
m m+1
Solution. The condition p < n < p means that n has m+1 digits when represented
in base p. By Kummer’s theorem, vp ((nk)) is the number of carries in addition k+(n−k)
in base p. Obviously, the number of carries must be less than number of digits of n in
base p (why?). The conclusion follows.
We will provide another solution for problem 261 stated in section §4.
Problem 6 (China 2015). Determine all integers k such that there exists infinitely
many positive integers n satisfying
2n
n+k ∤(n)
Problem 7. Let n be a positive integer. Show that n divides (nk) for all k such that
1 ≤ k ≤ n − 1 if and only if n is a prime.
Solution. We will first prove that n must be a power of a prime. Suppose the contrary.
Take any prime divisor p of n and let v = vp (n). By Lucas’ theorem, it follows that
p ∤ (pnv ), which contradicts the assumption that n ∤ (pnv ). Thus, n must be a power of
a prime.
r
Write n = p for some prime p and positive integer r. if r > 1, then from corollary
6,
2 n
p ∤ (pr−1 )
In this section, we provide some theorems which may help you solve problems more
easily. Though you will find that we have emphasized not to be dependent on theorems
or making them the core of solving problems, they help us a great deal and make our
lives a lot easier. Therefore, you will find a lot of theorems in this book. But it does
not mean in any way that theorems are the best way to improve in number theory.
51
§5. Some Useful Facts Masum Billal, Amir Hossein
They merely help us speed up the process of solving problems. Nothing more. One
could rediscover all the theorems while solving a problem and the end result would still
be the same. The point is: you can get to the top of a mountain in many ways and
the view is same. But the pleasure might be different based on the approach you take.
If you use a helicopter to reach the peak of the mountain or climb all the way to the
top. But definitely the latter approach brings you more pleasure. Anyway, we hope
you understand our primary intention.
Theorem 12. Two integers a and b are of the same parity if and only if their sum and
difference is even. Equivalently, they are of different parity if their sum and difference
is odd.
Corollary 7. Exactly one of the two integers a and b is even if and only if a ± b is odd.
k
Theorem 13. Every positive integer n can be written in the form n = 2 s, where k is
a non-negative integer and s is an odd positive integer.
Note.
Problem 8. Let n be a positive integer and let S = {1, 2, ⋯, 2n}. Choose n+1 numbers
a1 , a2 , ⋯, an+1 out of S so that
Theorem 14. Every composite positive integer n can be written as ab where a and b
are relatively prime positive integers larger than 1.
11
The pigeonhole principle states that if n items are put into m containers, with n > m, then at
least one container must contain more than one item.
52
§5. Some Useful Facts Masum Billal, Amir Hossein
a = rs
b = tu
c = rt
d = su
Proof. Let (a, c) = g1 . By proposition (25), there exist integers x1 and y1 such that
a = g1 x1 and c = g1 y1 with x1 ⊥ y1 . Also, let (b, d) = g2 , then there exist integers x2
and y2 such that b = g2 x2 and d = g2 y2 with x2 ⊥ y2 . Substitute these equations into
the given equation ab = cd to get
g1 g2 x1 x2 = g1 g2 y1 y2
Then,
e e f f
ab = p11 ⋯pkk q11 ⋯qℓ ℓ
53
§5. Some Useful Facts Masum Billal, Amir Hossein
e
Since ab = n , we get
e e f f a e a e b e b e
p11 ⋯pkk q11 ⋯qℓ ℓ = p11 ⋯pkk q11 ⋯qℓ ℓ
The exponents of the primes in both sides must be equal. Therefore, ei = ai e (for
i = 1, 2, . . . , k) and fj = bj e (for j = 1, 2, . . . , ℓ). Therefore,
a a e
a = (p11 ⋯pkk )
b b e
b = (q11 ⋯qℓ ℓ )
Note. You should think about why we considered the prime factorization and try to
understand what led us into that way of thinking.
Corollary 8. If a and b are relatively prime positive integers such that ab is a perfect
square, then a and b both are perfect squares.
2
Theorem 18. Let a, b, and c be positive integers such that ab = c . Then there exist
integers g, u, and v with u ⊥ v so that
2
a = gu
2
b = gv
c = guv
Proof. Let g = (a, b). Then there exist relatively prime integers x and y such that
a = gx and b = gy. Then g xy = c so that g ∣ c , or g ∣ c (see the example provided
2 2 2 2
right after proposition (21) for a proof). This implies that there exists some positive
2
integer k for which c = gk. Substituting this into the equation, we find k = xy with
2 2
x ⊥ y. From corollary (8), there exist integers u and v such that x = u and y = v .
2 2
Thus, a = gu , b = gv , and c = guv.
Now, we introduce a simple but really useful method for factorization: Simon’s
12
Favorite Factorization Trick , or SFFT in brief.
Proposition 33 (SFFT). For any real numbers x, y, j, and k, the following relation
holds:
xy + xk + yj + jk = (x + j)(y + k)
xy + x + y + 1 = (x + 1)(y + 1)
xy − x − y + 1 = (x − 1)(y − 1)
12
Named after Simon Rubinstein-Salzedo, a member of AoPS.
54
§5. Some Useful Facts Masum Billal, Amir Hossein
Let’s see the motivation behind this trick. Once Mr. Simon was studying number
theory, he found this problem: find all positive integers x and y such that xy − x + y =
49. Simon probably hates expressions of this form because he cannot factorize them.
However, if he adds −1 to both sides of his equation, he finds the nice and factored form
(x + 1)(y − 1) = 48, which is much easier to solve than the original equation. In fact,
to solve the factorized equation, he only needs to find the divisors of 48 (see theorem
Theorem 22 for more details). If you look closely, SFFT is inspired by the so-called
Completing the Square Method :
2
k k 2
= (x + )
2
x + kx +
4 2
In fact, the act of adding jk to xy + xk + yj in order to be able to factor it could be
called completing the rectangle in analogy to the famous completing the square trick.
Theorem 19. If N is the least common multiple of positive integers upto n, that is,
N = [1, 2, ⋯, n], then for a prime p, the maximum integer α for which p ∣ N is
α
α α+1
the unique non-negative integer α so that p ≤ n < p . In other words, if pi is a
prime less than or equal to n, and for that prime, αi is the unique integer such that
α α +1
pi i ≤ n < pi i then,
α α
N = p1 1 ⋯pk i
Since one of k or k − 1 must be even (why?), we can write k(k − 1) = 2ℓ for some integer
2 2
ℓ. Then n = 8ℓ + 1, and so n leaves a remainder of 1 when divided by 8.
Theorem 21. Every number of the form 4k + 3 has at least one prime factor of the
form 4k + 3.
Proof. The idea comes from the fact that if we multiply two numbers of the form 4k +1,
say 4a + 1 and 4b + 1, the result will be
55
§5. Some Useful Facts Masum Billal, Amir Hossein
which is, again, of the form 4k + 1. Clearly, all prime factors of a number n of the
form 4k + 3 are odd, and therefore are either of the form 4k + 1 or 4k + 3. If all prime
factors of n are of the form 4k + 1, then by the logic represented in above lines, any
product of powers of these primes, including n, should be of the form 4k + 1. So, we
get a contradiction and there exists at least one prime factor of n which is of the form
4k + 3.
Theorem 22. Let n be a positive integer. The number of pairs (a, b) of positive integers
which satisfy the equation
ab = n
Theorem 23. Every prime greater than 3 is either of the form 6k + 1 or of the form
6k − 1.
6k − 2, 6k − 1, 6k, 6k + 1, 6k + 2, 6k + 3
Numbers of the form 6k − 2, 6k + 2, 6k, 6k + 3 cannot be prime because the first two
are divisible by 2 and the last two are divisible by 3. Thus, if n is a prime, it must be
either 6k − 1 or 6k + 1.
Note that (k) + (3k ± 1) is odd. From corollary (7), k and 3k ± 1 have different parity
2 2
and k(3k ± 1) is divisible by 2. Let k(3k ± 1) = 2ℓ, then p = 24ℓ + 1, or p − 1 = 24ℓ,
which proves the theorem.
56
§5. Some Useful Facts Masum Billal, Amir Hossein
Theorem 25. If the sum of two positive integers is a prime, they are relatively prime
to each other.
Proof. Assume that a+b = p, where p is a prime. If (a, b) = g then there exist relatively
prime positive integers x and y for which a = gx and b = gy. So,
p = a + b = g(x + y)
which means g divides p. Since p is a prime, its only divisors are itself and 1. Hence, the
only possible values for g are 1 and p. However, g = p cannot happen since otherwise
x + y = 1 would lead to one of x or y being zero. Thus, (a, b) = g = 1.
Proof. We can just use induction on n, but we will try to avoid using induction as much
as possible. For the first identity, define
n−1 n−2 n−1
S=a +a b+⋯+b
n n−1 n−1 n−1 n−2 2 n
Then, aS = a + a b+⋯+b a and bS = a b+a b + ⋯ + b . Subtracting, we
obtain
n n
(a − b)S = a − b
which finishes the proof. The second identity can be proved by using the first identity
and the fact that when n is odd, we have a + b = a − (−b) .
n n n n
n n
Corollary 9. Let a and b be any two integers. Then a − b divides a − b for all positive
n n
integers n. Also, a + b divides a + b for odd n.
if m ∣ n.
57
§5. Some Useful Facts Masum Billal, Amir Hossein
m n m n m m n−m
a − 1 ∣ a − 1 − (a − 1) = a − a = a (a − 1)
k k
If a > 2, then a − 1 will divide a − 1 which is absurd because a − 1 is a prime. So,
a must be 2. Suppose that k is composite. Then, k = pℓ for some prime p and integer
ℓ > 1. Therefore,
k p ℓ
a − 1 = (a ) − 1
p p(ℓ−1) p(ℓ−2)
= (a − 1)(a +a + ⋯ + 1)
Proof. Here, we will use Euclidean algorithm as the idea is applicable to many similar
m m
problems. If m = n, the result is trivial since both sides are a − b . So, we can take
58
§5. Some Useful Facts Masum Billal, Amir Hossein
13
m > n without loss of generality . Then we can write m = n + k for some k ∈ N.
Therefore,
m m n+k n+k
a −b =a −b
n k k k n n
= a (a − b ) + b (a − b )
Note that, this is the descending step of Euclidean algorithm! If we repeat the same
process a couple of times, we would eventually reach (m, n) in the exponent.
As a conclusion to this chapter, we define factorial and binomial coefficient.
Factorial. Let n be a positive integer. The factorial of n, denoted by n!, is the
product of all positive integers less than or equal to n. That is,
n! = 1 × 2 × ⋯ × n
n n!
(k ) =
k!(n − k)!
59
§6. Solved Problems Masum Billal, Amir Hossein
Theorem 32. Let n be a positive integer. Then, n is a prime if and only if n divides
(nk) for all 0 < k < n.
p p−1
k( ) = p( )
k k−1
Obviously, the right side is divisible by p, so must be the left side. From the definition
of prime numbers, p⊥k. So, by the second part of the previous proposition, we can say
p must divide (kp).
§6 Solved Problems
Well, now that we have a basic understanding of how divisibility relations work, it is
the time to see how to apply those propositions to solve problems. Let us start with
some really easy problems so that the reader has a firm idea about how to approach a
problem. We will gradually discuss more difficult problems. Most importantly, we will
not focus on how to use theorems to solve problems or implement them. We want to
improve the intuitive ability of the reader instead.
This can be solved in a variety of ways. Before we solve this, it would be pleasant
to share some experience. This may not directly help readers understand how to solve
the problem, but it may help them understand how different people think when they
encounter a problem.
The first author was coaching a group of average students who barely had the idea
of problem solving back in 2014. After showing them some basic facts about divisibility,
he threw this problem at them. Here is how they approached it: most of them started
trial and error to find the solution. They were checking different values for n to see
if they satisfy the condition. Not all student could realize that this method will not
work in general for all numbers even if you find some initial solutions. One or two of
the students went for the idea that if n divides n + 3, then n + 3 is at least twice n.
However, when increasing n, 2n becomes larger than n + 3 after some n, and this leads
to a solution. Another student solved the problem in the old fashioned way: by division
process. That is, he divided n + 3 by n and found out that n must divide 3. Other
than those few students, most of them got that n = 1 and n = 3 work but could not
prove that these are the only solutions. In fact, that is the most difficult part of solving
a number theory problem.
60
§6. Solved Problems Masum Billal, Amir Hossein
Note the difference between the first and the second solution. There are pretty
much no differences other than the fact that the latter is more systematic. You will
eventually find that solving problems this way is particularly useful in Olympiads.
For now, we will keep the use of inequality in store and solve a few problems by
twisting up left and right sides of divisibility relations.
Solution. This time we have to remove n like before, but notice that there is an extra
2 attached.
We can overcome this easily: just see that n ∣ 2n and then it is the same as the
previous problem: n ∣ 2n + 3 − 2n = 3.
61
§6. Solved Problems Masum Billal, Amir Hossein
n + 1 ∣ 3n + 4 − (3n + 3) = 1
4n + 2 ∣ 12n + 10 − (12n + 6) = 4
So, 4n + 2 must be one of 1, 2, or 4. None of these values give a valid solution for n.
If you have not noticed already, this idea can be generalized to find all n satisfying
an + b ∣ cn + d, where a, b, c, and d are integers. Then what shall we multiply both sides
with? Here is a hint: consider the lcm of a and c. Why a and c?
Problem 13. Find all positive integers n for which 8n + 9 ∣ 12n + 5.
Solution. Our working principle is: we want to eliminate the variables on the right
side so we get a constant value. That is, we want the right side to be a number, not
a variable. In order to do this, we must construct two divisibility relations to subtract
from each other and get a constant value. In other words, we have to find a and b such
that the difference of right sides of 8n + 9 ∣ a(8n + 9) and 8n + 9 ∣ b(12n + 5) does not
include n. So, the coefficients of n must be equal in the two. The minimum value for
this common coefficient will be the lcm of 8 and 12, which is [8, 12] = 24. Therefore,
a = 3 and b = 2 and hence,
8n + 9 ∣ 3(8n + 9) = 24n + 27
8n + 9 ∣ 2(12n + 5) = 24n + 10
62
§6. Solved Problems Masum Billal, Amir Hossein
Solution. We are asked to find positive integers which would divide n + 4 and n + 12
both, no matter what. If d is such a positive integer then
d∣n+4
d ∣ n + 12
d ∣ (n + 12) − (n + 4) = 8
Solution. This can be done easily considering parity. When you encounter a problem
with primes (especially if you are asked to find a prime), it may be helpful to separate
the problem into two cases. The first case is p = 2 which works here. The second case
is when p is odd. It is trivial that as p is odd, 9p + 1 is even. However, we want 9p + 1
be a prime. This is a contradiction because 9p + 1 is larger than 2. Therefore, the only
solution is p = 2 for which 9p + 1 = 19 is also a prime.
7n + 1 ∣ 8(7n + 1) = 56n + 8
7n + 1 ∣ 7(8n + 55) = 56n + 385
• 13 ∣ 377 because 37 + 4 ⋅ 7 = 65 = 13 ⋅ 5.
So, we find the factorization of 377 to be 377 = 13 ⋅ 29. This means that 7n + 1 is a
divisor of 13 ⋅ 29. Notice that 7n + 1 is a number which leaves remainder 1 when divided
by 7. Therefore, look for numbers among 13, 29, 13, and 377 which leave a remainder
of 1 when divided by 7. The only possibility is 7n + 1 = 29, which gives n = 4.
2
Problem 17. Find all n ∈ N for which n + 3 divides n + 2.
63
§6. Solved Problems Masum Billal, Amir Hossein
We should again remove the variables from the rights side of n + 3 ∣ n + 2. Here
2
n + 3 ∣ 3n − 2
The problem is now similar to the ones we solved earlier. In fact, subtracting
n + 3 ∣ 3n + 9
n + 3 ∣ 3n − 2
Solution (Second Solution). This one is more elegant. In order to avoid the second
step, we can directly multiply n + 3 by n − 3 to obtain
2
n+3∣n −9
3 3
x + 10 ∣ (x + 1000) − (x + 10) = 990
Solution. How do we approach this problem? One idea is to go ahead like we did in
the first solution of problem (17), by eliminating powers of n one by one. Here is a
better solution.
First write it as, 7n + 1 ∣ n (n + 1). The problematic part is n . Many beginners
4 2 4
4
make mistakes in such situations claiming that 7n + 1 does not divide n , and so
7n + 1 ∣ n + 1. This is wrong. In general, the following statement is wrong:
2
64
§6. Solved Problems Masum Billal, Amir Hossein
This is another common mistake new problem solvers make. You can check this using
an example: 14 divides 28 = 7 × 4 but 14 does not divide 7. But in this problem, we
4 4
can still take n off because n is relatively prime to 7n + 1. Just notice that 7n + 1
4
leaves a remainder of 1 when divided by n, so n ⊥ 7n + 1. Evidently, n ⊥ 7n + 1 by
4
part 4 of proposition (23). Using part 2 of the same proposition, we can cancel out n
and get
2
7n + 1 ∣ n + 1
2 2
7n + 1 ∣ (49n + 49) − (49n − 1) = 50.
Note that 7n + 1 leaves a remainder of 1 when divided by 7. Therefore, we look for
divisors of 50 which leaves a remainder 1 when divided by 7. The divisors of 50 are
1, 2, 5, 10, 25, and 50. Only 1 and 50 leave the desired property among these numbers.
Since n is a positive integer, 7n + 1 ≥ 7 ⋅ 1 + 1 = 8. Therefore, 7n + 1 = 50 or n = 7.
Remark . We could handle the last part in another way. Write 7n+1 ∣ (n +1)−(7n+1),
2
so that
2
7n + 1 ∣ n − 7n
⟹ 7n + 1 ∣ n(n − 7)
Again, n ⊥ 7n + 1 implies 7n + 1 ∣ n − 7. If n = 7, we have a solution. Otherwise,
7n + 1 would have a larger value than ∣n − 7∣ and we get a contradiction.
Problem 20. If ax + by = 1, find (a, b).
Solution. Assume that (a, b) = g. Then we can find two relatively prime integers m
and n so that a = gm and b = gn. Setting these into the given equation, we observe
g(mx + ny) = 1. This implies that g divides 1, and so g = 1.
Note. We can similarly show that (x, y) = (x, b) = (a, y) = 1.
Problem 21. Find the number of solutions to the equation
1 1 1
x + y = 2015
in positive integers.
Solution. We can rewrite the equation as
x+y 1
xy =
2015
Multiplying both sides by 2015xy, we find xy = 2015(x + y). This can be represented
as
2
(x − 2015)(y − 2015) = 2015
According to theorem Theorem 22, we get that the number of solutions is the number
of positive divisors of 2015 , τ (2015 ).
2 2
65
§6. Solved Problems Masum Billal, Amir Hossein
Note. Did you realize that this was actually SFFT? And what do you think the result
would be if we considered solutions in integers (not necessarily positive)?
Problem 22. Find all n ∈ N such that 2 + n ∣ 8 + n.
n n
3
Solution. There is 8 on the right side and 2 on the left side. Since 8 = 2 , this should
certainly provoke us to use the fact that a + b ∣ a + b . In this case,
3 3
n n 3 3
2 + n ∣ (2 ) + n
n n 3
⟹ 2 +n∣8 +n
n n 3 n
⟹ 2 + n ∣ (8 + n ) − (8 + n)
n 3
⟹ 2 +n∣n −n
Now we need to find all n such that 2 + n ∣ n − n. If you play around with the small
n 3
values of n, you will clearly see that 2 grows a lot faster than n . Since 2 + n ∣ n − n,
n 3 n 3
we must have
n 3
2 + n ≤ n − n.
The following lemma gives us the limit we need for n. Once again, you have to prove
it. You can use induction to do so (can you use logarithm?).
n 3
Lemma 1. For n > 9, the inequality 2 + n > n − n holds.
By the lemma, if n > 9, there are no solutions. Now we are left with a few possibil-
ities for n because n must be less than or equal to 9. We can easily check by hand that
there are no solutions for this case as well.
Problem 23 (IMO 1959, Problem 1). Prove that for any integer n, the fraction
14n + 3
21n + 4
is irreducible.
Solution. We must make sense of the problem first. It asks to prove that a fraction is
irreducible. That means the fraction cannot be simplified anymore. In other words, we
must prove that the numerator (14n + 3) and denominator (21n + 4) of the fraction are
relatively prime to each other. How do we prove this? We will show this in two ways:
1. Let g = (14n + 3, 21n + 4). Then,
g ∣ 14n + 3
g ∣ 21n + 4
We already know we have to prove that g = 1. So, let us try to remove the n on
the right side. Since [14, 21] = 42 and 42 = 14 ⋅ 3 = 21 ⋅ 2, we can make use of the
following two relations:
g ∣ 3(14n + 3) = 42n + 9
g ∣ 2(21n + 4) = 42n + 8
Thus, g ∣ (42n + 9) − (42n + 8) = 1 and g = 1.
66
§6. Solved Problems Masum Billal, Amir Hossein
2. Take 14n + 3 = gx and 21n + 4 = gy for some integers x and y. Note that
3(14n + 3) − 2(21n + 4) = 1, and so
3gx − 2gy = 1
Remark . You should understand that both solutions are essentially the same, but
with different approaches or thinking styles.
n m
Problem 24. Show that if a prime is of the form 2 + 1, then n = 2 for some integer
m.
m
Solution. According to theorem Theorem 13, write n = 2 s, where s is an odd positive
integer. By theorem (26), we can write
m m s
n 2 s 2
p=2 +1=2 + 1 = (2 ) + 1
m m m m
2 2 (s−1) 2 (s−2) 2
= (2 + 1)(2 +2 +⋯+2 + 1)
m
Clearly, as p is a prime, this is impossible unless s = 1. So n = 2 .
Solution. Yes, this looks similar to SFFT. It has three variables instead of two, so
we cannot directly use Simon’s trick. However, if you already learned the motivation
behind that trick, the form of the problem does not matter. Here, 1 is missing! Add it
to both sides to get
abc + ab + bc + ca + a + b + c + 1 = 1
The left hand side shows you how SFFT looks like for three variables. Try to compute
(a + j)(b + k)(c + ℓ) and remember it. You will soon realize that the left hand side of
the above equation factors as (a + 1)(b + 1)(c + 1). Therefore,
(a + 1)(b + 1)(c + 1) = 1
The rest of the solution is just case work. If the product of three integers equals 1,
what can they be? The solutions are
(a, b, c) ∈ {(0, 0, 0), (−2, −2, 0), (−2, 0, −2), (0, −2, −2)}
Problem 26 (Turkey TST 2014, Day 2, Problem 4). Find all odd positive integers m
and n such that
n ∣ 3m + 1
2
m∣n +3
67
§6. Solved Problems Masum Billal, Amir Hossein
Solution. Do not panic! Even some TST problems can be solved using simple tricks.
The general idea is to first see if there are infinitely many solutions. Check some
numbers and some special values for m and n. For instance, put m = n to see if it fits
in. In this problem, we cannot find a pattern to construct infinitely many solutions,
so we guess that there are finite solutions and continue. To be honest, many of such
divisibility problems (with finite solutions) rely heavily on case working, and you need
to know how to start the case work. One of the best ways to handle this situation is to
find a limit for m and n. Remember the properties of divisibility from proposition (1).
Limit means bounds, and bounds means inequality (see part 10 of that proposition).
Actually, we will use the fact that if a ∣ b for positive integers a and b, then a ≤ b. After
we have found the limit, the case work begins.
Write n ∣ 3m + 1 as 3m + 1 = nk or m = nk−1 3
. Now try to rewrite the second
divisibility relation as
nk − 1 2
∣n +3
3
×3 2
⟹ nk − 1 ∣ 3n + 9
×k 2
⟹ nk − 1 ∣ 3n k + 9k
On the other hand, we know that nk − 1 ∣ 3n(nk − 1) = 3n k − 3n. Subtract these two
2
We start case work on the parameter k (you will know why). Since m is odd and
3m + 1 = nk, k is even. We check some possible values of k:
(a) If k = 2, then from nk − 1 ∣ 3n + 9k we have 2n − 1 ∣ 3n + 18, and thus
2n − 1 ∣ 2(3n + 18) − 3(2n − 1) = 39
This means that 2n − 1 = 1, 3, 13, or 39. None of these values make a solution for
the problem.
(b) If k = 4, then from nk − 1 ∣ 3n + 9k we have 4n − 1 ∣ 3n + 36, and thus
4n − 1 ∣ 4(3n + 36) − 3(4n − 1) = 147
This means that 4n − 1 = 1, 3, 7, 21, 49, or 147. Checking the values of n, we find
that n = 1 and n = 37 satisfy the conditions of the problem and give us the solutions
(m, n) = (1, 1) and (m, n) = (49, 37).
68
§6. Solved Problems Masum Billal, Amir Hossein
69
§7. Exercises Masum Billal, Amir Hossein
§7 Exercises
Problem 27. Find all pairs of positive integers (x, y) for which
2 2
x +y
x−y
is an integer that divides 1995.
Problem 28. Let x, y, and z be integers such that
2 2 2
(x − y) + (y − z) + (z − x) = xyz
Problem 29. Let k and m, with k > m, be positive integers such that the number
km(k − m ) is divisible by k − m . Prove that (k − m) > 3km.
2 2 3 3 3
is divisible by 112.
Note: for any real number x, ⌊x⌋ is the largest integer not exceeding x.
√ m √ m
Hint. Show that each term is equal to 4 − (2 + 2) − (2 − 2) .
m
Problem 35. Let Pn = (19 + 92)(19 + 92 )⋯(19 + 92 ) for each positive integer n.
2 2 n n
Determine, with proof, the least positive integer m, if it exists, for which Pm is divisible
33
by 33 .
70
§7. Exercises Masum Billal, Amir Hossein
n n+1
Problem 36. Prove that we can choose 2 numbers from 2 positive integers such
n
that their sum is divisible by 2 .
12 8
Problem 37 (Baltic Way 1993). Prove that for any odd positive integer n, n − n −
4 9
n + 1 is divisible by 2 .
Problem 38. Let m and n be two positive integers. Does there exist positive integers
a, b, and c all greater than m such that abc is divisible by a + n, b + n, and c + n?
Problem 39 (Baltic Way 1997). Prove that in every sequence of 79 consecutive positive
integers written in the decimal system, there is a positive integer whose sum of digits
is divisible by 13.
Problem 40 (Baltic Way 2006). A 12−digit positive integer consisting only of digits
1, 5, and 9 is divisible by 37. Prove that the sum of its digits is not equal to 76. This PDF was created
for Amazon.
1976 1976
Problem 41. Prove that the number 19 + 76
4
2
1. is divisible by the (Fermat) prime number F4 = 2 + 1, and
71
§7. Exercises Masum Billal, Amir Hossein
Problem 51 (BrMO 2003, Modified). Determine all triples (x, y, z) of integers greater
than 1 with the property that x divides yz − 1, y divides zx − 1 and z divides xy − 1.
Problem 52 (All Russian Olympiads, P10.7). Positive integers x > 1 and y satisfy the
2 15
equation 2x − 1 = y . Prove that 5 divides x.
Problem 53. Find all pairs (a, b) of positive integers such that 2a − 1 and 2b + 1 are
relatively prime and a + b divides 4ab + 1.
Problem 54. Determine all pairs (m, n) of positive integers such that m > n and
Problem 56. Let x ≥ 1 be a real number. Prove or disprove that there exists a positive
integer n such that gcd (⌊x⌋, ⌊nx⌋) = 1.
Problem 57. Find all pairs of positive integers (a, b) such that
ab = 160 + 90 gcd(a, b)
Problem 59. Let {an }n≥1 be a sequence of positive integers such that if i ≠ j, then
gcd(ai , aj ) = gcd(i, j)
Problem 60. Let a and b be two positive integers such that a > b. We know that
gcd(a − b, ab + 1) = 1 and gcd(a + b, ab − 1) = 1. Prove that (a − b) + (ab + 1) is not
2 2
a perfect square.
72
§7. Exercises Masum Billal, Amir Hossein
• Prove that for every positive integer a, the equation f (x) = ax has a solution
x ∈ N.
• Prove that, for a positive integer a, the equation f (ax) = ax has exactly one
0
solution x ∈ N if and only if a is a power of 2 (where 1 = 2 is also considered as
a power of 2).
Problem 63. Let a0 , a1 , a2 , ⋯ be a sequence of positive integers such that the greatest
common divisor of any two consecutive terms is greater than the preceding term; in
symbols, gcd(ai , ai+1 ) > ai−1 . Prove that an ≥ 2 for all n ≥ 0.
n
73
CHAPTER II.
MODULAR ARITHMETIC
Consider the timestamp we use in our daily life. Certainly, there was a point when
people started counting time. Then, why is it not something like, 2147483647? Rather
we say something like 12.09 am (and there is a date of course, that separates two 12.09
am). The reason is, each time the hour hand in a clock crosses 12, it starts from 1
again, not 13. If the numbers kept going large, we would have a hard time realizing
what time we are living in. Similarly, when the second hand ticks 60 times, it starts
from 1 again (meaning it has been 1 minute, letting the minute hand tick once). Here,
intentionally or inadvertently, we have been using what number theorists call modular
arithmetic. The idea is, we keep the integers that leave the same remainder (when
divided by a certain integer) in the same class. It will be clear afterwards what exactly
we mean by class here when we discuss complete set of residue class. This PDF was created
for Amazon.
Definition. For a non-zero integer m, integers a and b are congruent modulo m if and
only if m ∣ a − b. We show this by the notation
a ≡ b (mod m)
If m does not divide a − b, we say that a and b are not congruent modulo m and denote
/ b (mod m).
it by a ≡
Note.
Proposition 35. Assume that a and b are two integers and m is a positive integer.
Then the following propositions are correct.
iii. a ≡ a (mod m). We call this the reflexivity property of modular congruences.
iv. If a ≡ b (mod m), then b ≡ a (mod m). We call this the symmetry property.
v. If a ≡ b (mod m) and b ≡ c (mod m), then a ≡ c (mod m). We call this the
transitivity property.
Proposition 36. If n is a positive integer and a ≡ b (mod m), then a ≡ b (mod m).
n n
Proposition 37. If f (x) is a polynomial with integer coefficients and a ≡ b (mod m),
then f (a) ≡ f (b) (mod m).
Proposition 38. If a is an integer and n is a positive integer, then exactly one of the
following relations holds.
a ≡ 0 (mod n)
a ≡ 1 (mod n)
..
.
a ≡ n − 1 (mod n)
76
§1. Basic Modular Arithmetic Masum Billal, Amir Hossein
7 ≡ 4 (mod 15)
which is clearly false. But, why? Here is the reason: 15 = 5 ⋅ 3. And when we canceled
5 without thinking where that 5 came from in 15, we accidentally took out the only
portion where 5 came from. So we can not do that recklessly. However, this also means
that if we took out 5 from all sides, it would be true:
7 ≡ 4 (mod 3)
Proof.
(a) The greatest common factor of c and m is d, so there exist integers c1 and m1 such
that
c = c1 d
m = m1 d
gcd(c1 , m1 ) = 1
a ≡ b (mod m1 )
as desired.
(b) Because b ≡ c (mod m), there exists an integer k for which b − c = mk. So
gcd(b, m) ∣ c. On the other hand, from definition of gcd, it is clear that gcd(b, m) ∣
m. Now by proposition 22 we have gcd(b, m) ∣ gcd(c, m). Similarly, one can show
that gcd(c, m) ∣ gcd(b, m). Using Proposition 2, we get gcd(c, m) = gcd(b, m).
a, a + d, a + 2d, a + 3d, ⋯
77
§1. Basic Modular Arithmetic Masum Billal, Amir Hossein
78
§1. Basic Modular Arithmetic Masum Billal, Amir Hossein
This is not a finite sequence. But is the sum divergent or convergent? The terms
of the above sequence are gradually decreasing and approach zero. To see this, notice
that the ninth term is
1
= 0.00390625
256
which is very close to zero. So, on a second thought, we can guess that the given sum
has a finite value. In general, when the absolute value of common ratio of a geometric
progression is less than one, that is, when the absolute value of each term of the sequence
is smaller that its preceding term, then the geometric series (either finite or infinite)
2
has a finite value . We will see this from a different point of view. This is due to
Chamok Hasan, a teacher of the first author.
Consider a pumpkin. Let us assume that it is totally symmetrical. Now, divide it
in half and put aside half of it. You have half of the pumpkin to yourself. Divide it
in half again. Keep one to yourself and discard the other half. So now you have one
fourth of the pumpkin. Again, cut it in half. Keep one, discard one. Now you have
one eighth. See that if you keep going this way, you end up getting 12 , 41 , 18 , 16
1
, ⋯ and
dividing them. And the fun fact is, you can keep doing this for as many times as you
want. Obviously, if we put together all the parts again, we get the whole pumpkin.
That is, if we take all the discarded portions and put them back, the pumpkin becomes
whole again. This shows us without any rigorous proof that
1 1 1 1
+ + + + ... = 1
2 4 8 16
Now you should be able to make sense how a sequence with infinite terms can have a
finite sum. We have
a (r − 1)
n n
∑ ai =
r−1
i=1
We have used Theorem 26 to write the last line. Since r ≠ 1, we can divide both sides
by r − 1 to get the desired result. Did you notice anything? In fact, this is a special
n n
case of what we encountered in divisibility. Recall the expansion of a − b and try to
find a correlation between the two. Take the geometric progression with ∣r∣ < 1, then
the sum converges. More precisely,
a
∑ ai =
1−r
i≥1
2
to put it differently, it converges to a fixed value.
79
§2. Modular Exponentiation Masum Billal, Amir Hossein
Example.
1 i 1
∑( ) = =2
2 1− 1
i≥0 2
This is a geometric sequence with common ratio −3 and initial term 2. The last
10
term equals 2(−3) . So,
10 11
i
2((−3) − 1)
∑ 2(−3) = = 88, 573
i=0
(−3) − 1
§2 Modular Exponentiation
In the early stage of problem solving, we all calculate big integers modulo an integer.
For example, consider the next problem.
n n
Problem 72. Define an = 6 + 8 . Find the remainder of a49 when divided by 49.
49
The first idea that crosses your mind might be calculating 6 and finding the re-
mainder when divided by 49. This would be a large integer and the calculation is really
tedious, not to mention, pointless. A slight improvement would be multiplying 6 with
6 and taking modulo 49 each time. We need to do this for 49 times but at least, now
we do not have to deal with that large numbers anymore. Let us call this iterative
exponentiation method.
k
Suppose we want to find c ≡ a mod n. The iterative exponentiation method
0 1 2 k k
computes the values 1 = a , a , a , ⋯, a = c modulo n instead of directly calculating a
i
modulo n. Suppose that we have computed a modulo n for some i < k and the result
i+1
is b. According to the above theorem, to calculate a , all we need to do is to compute
i
a ⋅ b mod n. Obviously, a ⋅ b is much smaller than a when i is large. This is why this
method takes less time for computations. Iterative exponentiation may be expressed as
an algorithm as shown below.
1. Set k1 ⟵ 0 and c ⟵ 1.
80
§2. Modular Exponentiation Masum Billal, Amir Hossein
2. Increase k1 by 1.
Remark . In the above example where a is small (compared to modulus n), we can
increase k1 more than one unit in each iteration of the algorithm. For example, in
2 4 20
above example, we could increase k1 two units each time to compute 5 , 5 , ⋯, 5 . In
this case, the number of calculations is divided by two and therefore there will be less
time needed to find the result. This is done in general case but one must notice that
2
when one increases k1 , say, two units at each step, he is in fact computing a ⋅ c mod n
instead of a ⋅ c mod n in step 3 of the algorithm to reduce the number of iterations of
the algorithm. If a is small, there will be no difference in computation time. But if a
2
is (too) large, computing a ⋅ c mod n may will be more time consuming and it may
reduce the time efficiency of algorithm.
81
§2. Modular Exponentiation Masum Billal, Amir Hossein
We just saw a way of converting binary numbers into decimal. How does that help
us in modular exponentiation? Assume that we want a (mod n). We will not compute
k
doing this until k = 0. In the end we will see r ≡ a (mod n). Again, make sense why
k
this works. Do the example above this way and see if the result matches. Algorithm to
find a (mod n).
k
1. Set R ⟵ 1.
6. Go to step 2.
However, we face another concern here. What if Ra is very large? We can take care of
it the same way. Express a in binary and take modulo from there. Algorithm to find
ab (mod n) for large b.
1. Set R = 1.
6. Go to step 2.
We can call this modular multiplication. This way, we will not have to actually multiply
two numbers to get the remainder. The proofs for the last two ideas were not shown
deliberately. We expect that you can do it easily. By the way, did you notice something
else too? In modular exponentiation, we do not have to iterate k times. The number of
times we need to iterate is actually ⌊log2 (k)⌋ + 1 (again, why?). Same goes for modular
multiplication. Therefore, it is a very desirable improvement. In fact, these methods are
highly used in primality tests or similar fields (we will discuss about primes in Chapter
IV).
Notice that, we can write modular exponentiation algorithm in a better fashion.
82
§3. Modular Exponentiation Masum Billal, Amir Hossein
1. Set R = 1.
2. Represent k in binary. Assume k = (x0 x1 ⋯xl )2 .
3. If k = 0, return R.
4. Find r = (k (mod 2)).
5. If r = 1, set R ⟵ Ra (mod n).
6. Set k ⟵ ⌊k/2⌋.
7. Set a ⟵ a (mod n).
2
8. Go to step 3.
Example. Let us calculate 5 (mod 751) this way. First, we need to find the binary
20
83
§3. Residue Systems Masum Billal, Amir Hossein
i 1 2 3 4 5
Ri 25 625 121 372 200
20
Table 2.2: Applying modular exponentiation method to find 5 modulo 751.
§3 Residue Systems
Residue systems are very simple definitions which will help you make a good sense of
some later-explained theorems such as Fermat’s and Euler’s.
Proposition 39. The set A = {a1 , a2 , ⋯, ak } is a complete residue set (or system)
/ aj (mod m) for i ≠ j.
modulo m if and only if k = m and ai ≡
Proposition 40. Let A = {a1 , a2 , ⋯, am } be a complete residue set modulo m and let
a, b be integers such that a⊥m. Then the set
84
§3. Residue Systems Masum Billal, Amir Hossein
A function is like a machine. It takes a number as its input, functions on the number,
and gives another number as its output with the property that each input is related to
exactly one output. This property seems logical. Consider a weighing scale designed to
measure the weight of people. Obviously, a person cannot be both 70 and 75 kilograms
at the same time. The weight of a person (in a specific time) is a constant number, and
hence the weighing scale actually works as a function: it takes a person as its input,
measures his weight, and then shows the person’s weight as its input.
Another example would be a function that takes a real number x as its input and
2
gives x as its output. For convenience, we can call this function f ∶ R → R and write
its relation as f (x) = x for all x ∈ R. The notation f ∶ S → T means that the function
2
f takes its inputs from the domain S (the set of inputs) and assigns them an output
from the codomain T (the set of outputs and maybe some additional elements). For
the previous example, we see that both domain and codomain of f are R. However,
+
the range (or image) of f , which is the set containing only outputs of f , is R , the set
of all positive real numbers.
Euler’s Totient Function. For every positive integer n > 1, φ(n) is the number of
positive integers less than or equal to n which are relatively prime to n. We call this
3
function Euler’s phi function (or totient function).
1 1 1
φ(n) = n(1 − p )(1 − p )⋯(1 − p )
1 2 k
α −1 α −1 α −1
= p1 1 p2 2 ⋯pk k (p1 − 1)⋯(pk − 1)
3
You might be wondering what totient means. In Latin, tot means so many. The suffix of iens is
probably from the Sanskrit.
The function f is increasing if for a1 > a2 , we have f (a1 ) > f (a2 ).
4
The function f ∶ X → Y is surjective if for every y ∈ Y , there exists x ∈ X such that f (x) = y.
6
85
§3. Residue Systems Masum Billal, Amir Hossein
86
§4. Bézout’s Lemma Masum Billal, Amir Hossein
Proposition 43. Let A = {a1 , a2 , ⋯, aφ(m) } be a reduced residue set modulo m and let
a be an integer such that a⊥m. Then the set
The proof of this theorem is pretty easy, try it for yourself. Pay attention to the
difference between this proposition and the similar Proposition 40 for complete systems.
The latest theorem says that there are infinitely many reduced residue systems for
any m. So, it makes sense to define a set as the original reduced residue system for any
positive integer m. We call this set Um .
Definition. Let m be a positive integer. The set of units modulo m, Um , is the set of
positive integers g1 , ⋯, gφ(m) less than m which are relatively prime to m.
Example. U8 = {1, 3, 5, 7}, and U15 = {1, 2, 4, 7, 8, 11, 13, 14}. If p is a prime, then
Up = {1, 2, ⋯, p − 1}.
You might be wondering why we call Um the set of units. In algebraic structures, a
unit is an element a for which there exists some element b such that ab = 1. In our case,
the number a is a unit if there exists some b such that ab ≡ 1 (mod m). As proved
before, a is a unit if and only if it is relatively prime to m, and this shows us why Um
is called the set of units.
§4 Bézout’s Lemma
In this section, we are going to explain the simple but useful Bézout’s lemma and then
introduce modular multiplicative inverses.
ax + by
87
§4. Bézout’s Lemma Masum Billal, Amir Hossein
Theorem 34 (Bézout’s Identity). For two nonzero integers a and b, there exists x, y ∈
Z such that
ax + by = (a, b)
You are probably familiar with this theorem. A simple proof uses Euclidean division,
but it doesn’t show you where exactly to use this identity. So, we prove a stronger
theorem and the proof of Bézout’s identity is immediately implied from it.
Theorem 35. Let a, b, m be integers such that a, b are not zero at the same time. Then
the equation
ax + by = m
Proof. The first part is easy. Suppose that there exist integers x0 and y0 such that
ax0 + by0 = m
We know that (a, b) ∣ a and also (a, b) ∣ b, thus (a, b) ∣ m and we are done.
Conversely, if (a, b) = d and m is divisible by d, then we want to prove that there
exist some positive integers x and y for which ax + by = m. First, we show that it’s
sufficient to show that there exist x and y such that
ax + by = d
∣a∣
0 < ∣a∣ = a a + b ⋅ 0
and if b ≠ 0, then
∣b∣
0 < ∣b∣ = a ⋅ 0 + b
b
7
Because of well-ordering principle , A contains a least element. Let this smallest element
be t. So there exist integers x0 and y0 such that
ax0 + by0 = t
7
The well-ordering principle states that every non-empty set of positive integers contains a least
element.
88
§4. Bézout’s Lemma Masum Billal, Amir Hossein
a = tq + r
and thus
If r ≠ 0, then r is a positive integer written in the form ax1 + by1 , which is a positive
integer linear combination of a and b, so r ∈ A. But r < t, which is in contradiction
with minimality of t. Therefore r = 0 and t ∣ a. We can prove that t ∣ b in a similar
way. By Proposition 22, we find that t ∣ d. Also, according to the first part of the
proof, we have d ∣ t. Following Proposition 2, t = d. This means that d ∈ A and there
exist integers x and y such that
ax + by = d
Bézout’s Identity has many interesting applications. We will see one such application
in Chapter V, to prove Chicken McNugget Theorem.
We are now ready to represent a stronger version and also a generalization of
Bézout’s lemma.
Corollary 11 (Stronger Form of Bézout’s Identity). The smallest positive integer linear
combination of a and b is (a, b).
Corollary 12. If a ⊥ b for non-zero integers a and b, then there exist integers x and
y such that
ax + by = 1
a1 x1 + a2 x2 + ⋯ + an xn = m
ax ≡ b (mod m)
89
§4. Bézout’s Lemma Masum Billal, Amir Hossein
Problem 73. Let a, b, and c be non-zero integers such that (a, c) = (b, c) = 1. Prove
that (ab, c) = 1.
ax + cy = 1
bz + ct = 1
This means that we have found a linear combination of c and ab which is equal to 1.
From Corollary 11 it follows that (ab, c) = 1 (why?).
Solution. The problem is obvious for c = 0. Assume that c ≠ 0. Since (a, b) = 1, there
exist integers x and y such that ax + by = 1. Multiply both sides of this equation by c
to obtain acx + bcy = c. Because a divides both acx and bcy, it must also divide their
sum, which is equal to c.
ax ≡ 1 (mod m)
−1
Once defined, x may be denoted by a and simply called inverse of a.
Note. Unlike real numbers which have a unique reciprocal, an integer a has either no
inverse, or infinitely many inverses modulo m.
3 ⋅ 5 ≡ 1 (mod 7)
90
§4. Bézout’s Lemma Masum Billal, Amir Hossein
16 31 16
Example. An inverse for 2 + 1 modulo 2 − 1 is 2 − 1. In fact,
16 16 32 31 31
(2 − 1)(2 + 1) = 2 − 1 = 2(2 − 1) + 1 ≡ 1 (mod 2 − 1)
Theorem 38. Let a be an integer and let m be a positive integer such that a ⊥ m.
Then a has an inverse modulo m. Also, every two inverses of a are congruent modulo
m.
Proof. The proof is a straightforward result of corollary (12). Since a ⊥ m, the equation
ax + my = 1 has solutions. Now take modulo m from both sides to complete the proof
of the first part. For the second part, assume that x1 and x2 are inverses of a modulo
m. Then,
as desired.
The uniqueness of inverse of an integer a modulo m gives us the following corollary.
Corollary 13. For a positive integer m, let {a1 , a2 , ⋯, aφ(m) } be a reduced residue
system modulo m. Then {a1 , a2 , ⋯, aφ(m) } is also a reduced residue system modulo
−1 −1 −1
m.
Problem 75. Find the unique odd integer t such that 0 < t < 23 and t + 2 is the
modular inverse of t modulo 23.
Solution. This means that t(t + 2) ≡ 1 (mod 23). Add 1 to both sides of this con-
gruence relation to get (t + 1) ≡ 2 ≡ 25 (mod 23). Therefore, 23 ∣ (t + 1) − 25 or
2 2
≡ 1 (mod p)
−1
a⋅a
n −1 n
⟹ a ⋅ (a ) ≡ 1 (mod p)
−1 n n −1
⟹ (a ) ≡ (a ) (mod p)
as desired.
91
§4. Bézout’s Lemma Masum Billal, Amir Hossein
Theorem 39. Let a, b be integers and x, y, and n be positive integers such that (a, n) =
(b, n) = 1, a ≡ b (mod n), and a ≡ b (mod n). Then,
x x y y
(x,y) (x,y)
a ≡b (mod n)
Proof. By Bézout’s identity, we know there are integers u and v so that ux+vy = (x, y).
Therefore,
(x,y) ux+vy
a ≡a
x u y v
(1) ≡ (a ) ⋅ (a )
x u y v
(2) ≡ (b ) ⋅ (b )
ux+vy
(3) ≡b
(x,y)
≡b (mod n)
Remark . Thanks to Professor Greg Martin, we should point out a very important
detail here. In the computations above, we used the fact that there exist integers u
and v such that ux + by = 1. One must notice that these integers u and v need not be
positive. In fact, if x and y are both positive, then u and v cannot be both positive
(why?). But that doesn’t make our calculations wrong, due to Proposition 44. If it’s not
clear to you yet, think of it in this way: suppose that, say, u is negative. For instance,
consider the example when x = 3 and y = 15. Then, since 3 ⋅ (−4) + 15 ⋅ 1 = (3, 15), we
have u = −4 and v = 1 . Then, equation (2), would look like
3 −4 15 1 3 −4 15 1
(a ) ⋅ (a ) ≡ (b ) ⋅ (b ) (mod n)
This might not seem normal because we have a −4 in the exponents. So, using Propo-
sition 44, we can write the above congruence equation as
4 4
−1 3 15 1 −1 3 15 1
((a ) ) ⋅ (a ) ≡ ((b ) ) ⋅ (b ) (mod n)
(m,n) m
Problem 76. Prove that, m
(n) is an integer.
Since this problem is juxtaposed with this section, it is obvious we are going to use
this theorem. But in a real contest, that may not be the case at all. Try solving it
without seeing the solution first and you will know what we mean.
Solution. Since there are integers x, y with (m, n) = mx + ny, it is easy to deduce
92
§5. Chinese Remainder Theorem Masum Billal, Amir Hossein
that:
gcd(m, n) m mx + ny m
m ( n ) = m (n)
m ny m
= x( n ) + m ( n )
m ny m m − 1
= x( n ) + m ⋅ n ( n − 1 )
m m−1
= x( n ) + y( n − 1 )
Chinese Remainder Theorem –usually called CRT – is a very old principle in mathe-
matics. It was first introduced by a Chinese mathematician Sun Tzu almost 1700 years
ago. Consider the following example.
Problem 77. A positive integer n leaves remainder 2 when divided by 7 but has a
remainder 4 when divided by 9. Find the smallest value of n.
You might have encountered similar problems when you were in 4th or 5th grade.
May be even more basic ones. But the idea is essentially the same. If the problem was
a bit different, like
n ≡ 2 (mod 7)
n ≡ 4 (mod 9)
93
§5. Chinese Remainder Theorem Masum Billal, Amir Hossein
n≡2⋅9⋅v+4⋅7⋅u (mod 7)
n≡4⋅7⋅u+2⋅9⋅v (mod 9)
And now, we have what we want! We can say,
n≡2⋅9⋅v+4⋅7⋅u (mod 7 ⋅ 9)
since 7 ⊥ 9. We have our solution! Think more on our approach and what led us to do
this. Question is, is this n the smallest solution? If we take r with 0 ≤ r ≤ mn so that
n ≡ r ≡ 18v + 28u (mod 63)
94
§5. Chinese Remainder Theorem Masum Billal, Amir Hossein
Theorem 40 (Chinese Remainder Theorem for Two Integers). For two positive integers
a⊥b,
x ≡ m (mod a)
x ≡ n (mod b)
has a solution
x0 ≡ (mbba + naab ) (mod ab)
−1 −1
If we take n relatively prime integers instead of two, the same process will work! So
we can generalize this for n variables.
Theorem 42 (CRT). For n pairwise relatively prime integers a1 , a2 , ⋯, an there exists
a solution to the congruences
x ≡ r1 (mod a1 )
x ≡ r2 (mod a2 )
..
.
x ≡ rn (mod an )
M
If M = a1 a2 ⋯an and Mi = a and Mi ei ≡ 1 (mod ai ), then the smallest modulo M is
i
given by
x0 ≡ (r1 M1 ei + ⋯ + rn Mn en )
n
≡ (∑ ri Mi ei ) (mod M )
i=1
95
§5. Chinese Remainder Theorem Masum Billal, Amir Hossein
x ≡ r1 (mod a1 )
x ≡ r2 (mod a2 )
..
.
x ≡ rn (mod an )
ri ≡ rj (mod (ai , aj ))
for all i and j. Any two solutions x, y are congruent modulo the least common multiple
of all ai . That is, if M = [a1 , ⋯, an ] and x, y are two solutions, then x ≡ y (mod M ).
Problem 79. Prove that, for any n there are n consecutive integers such that all of
them are composite.
Solution. We will use CRT here forcibly, even though it has a much easier solution.
Consider the following congruences:
x ≡ −1 (mod p1 p2 )
x ≡ −2 (mod p3 p4 )
..
.
x ≡ −n (mod p2n−1 p2n )
96
§6. Chinese Remainder Theorem Masum Billal, Amir Hossein
Problem 80. Suppose that {s1 , s2 ⋯, sϕ(m) } is a reduced residue set modulo m. Find
all positive integers a for which {s1 + a, s2 + a⋯, sϕ(m) + a} is also a reduced residue set
modulo m.
Solution. We claim that the given set is a reduced residue system modulo m if and
only if a is divisible by each prime factor of m.
α
First, suppose that m has a factor p and a is not divisible by p. Let m = p n for
some positive integer n relatively prime to p. Since n⊥p, by CRT, there exists some
integer k such that
k ≡ −a (mod p)
k ≡ 1 (mod n)
Since k ≡ −a ≡ / 0 (mod p), we have k⊥p. Also, let (k, n) = d. Then d ∣ n ∣ k−1 and d ∣
k, meaning d ∣ 1 and so d = 1. It follows that k⊥m. So, k ∈ {s1 , s2 ⋯, sφ(m) }. But k + a
is divisible by p, and therefore not relatively prime to n, forcing {s1 +a, s2 +a⋯, sφ(m) +a}
not a reduced residue system.
For the converse, suppose that a is an integer which is divisible by all prime factors
of m. Obviously, s1 + a, s2 + a⋯, sφ(m) + a are all distinct modulo m. We just need
to show that if s is relatively prime to m, then so is s + a. For any prime p which
divides m, we have s + a ≡ s (mod p) because as assumed, a is divisible by p. Since s
is co-prime to p, so is s + a. Thus s + a is co-prime to all prime factors of m, making
it relatively prime to m as well.
Problem 81 (1997 Czech and Slovak Mathematical Olympiad). Show that there exists
an increasing sequence {an }n=1 of natural numbers such that for any k ≥ 0, the sequence
∞
It is a standard example of CRT because it is not obvious how CRT comes into the
play here.
Solution. Let pk be the kth prime number. Set a1 = 2. For n ≥ 1, let an+1 be the
least integer greater than an that is congruent to −k modulo pk+1 for all k ≤ n. Such
an integer exists by the Chinese Remainder Theorem. Thus, for all k ≥ 0, k + an ≡ 0
(mod pk+1 ) for n ≥ k + 1. Then at most k + 1 values in the sequence {k + an } can be
prime since the ith term onward for i ≥ k + 2, the values are nontrivial multiples of
pk+1 and must be composite. This completes the proof.
Note. We could deal with this using an = (pn − 1)! as well, combining with Wilson’s
theorem. Because if k > 1 then pn − 1 > k for sufficiently large n so it will be composite
from that n. Otherwise (p − 1)! + 1 is divisible by p, so it is composite as well.
§6 Wilson’s Theorem
97
§6. Wilson’s Theorem Masum Billal, Amir Hossein
We have probably discussed that if n > 4 is a composite integer, then (n−1)! is divisible
by n. What if n is a prime? Take n = 3, then (n − 1)! = 2, not divisible by 3. Take
n = 5. (n − 1)! = 24, which is not divisible by 5. Take n = 7, then (n − 1)! = 120 which
is not divisible by 7. Take n = 11, (n − 1)! = 3 628 800 and this is not divisible by 11
either. Since they are not divisible by the primes (as expected), we should check for
remainders. 2! leaves a remainder 2 when divided by 3. 4! leaves 4 when divided by 5,
6! leaves 6 when divided by 7. If you calculate further, you will see the pattern goes
on. So it suggests us to conjecture that the remainder of (p − 1)! when divided by the
prime p is p − 1. In fact, this is what we call Wilson’s theorem.
Theorem 44. Let p be a prime number and a is a positive integer. Show that if the
inverse of a modulo p is equal to a, then a ≡ 1 or p − 1 (mod p).
Proof. The proof for p = 2 is obvious, so assume that p > 2. The inverse of a is itself,
so a ≡ 1 (mod p). This means that p ∣ a − 1. So, p divides (a − 1)(a + 1). We know
2 2
(p − 1)! ≡ (p − 1) (mod p)
9! = 1 ⋅ 2⋯9
= (2 ⋅ 6) ⋅ (3 ⋅ 4) ⋅ (5 ⋅ 9) ⋅ (7 ⋅ 8)
= 12 ⋅ 12 ⋅ 45 ⋅ 56
≡ 1 ⋅ 1 ⋅ 1 ⋅ 1 (mod 15)
Does it make sense now why the theorem above is necessary? If not, think a little bit
more. Then proceed and you will realize we have actually found the crucial step to
prove Wilson’s theorem.
According to this theorem, the only two numbers in the set {1, 2, . . . , p − 1} which
have their inverse equal themselves are 1 and p − 1. This will help us to prove the
Wilson’s theorem.
Theorem 45 (Wilson’s Theorem). The positive integer p > 1 is a prime if and only if
(p − 1)! ≡ −1 (mod p).
Proof. We divide the proof of this theorem into two parts. First, we show that if p is a
prime, then (p−1)! ≡ −1 (mod p). The result is obvious for p = 2 and 3. So we assume
that p ≥ 5. According to the Theorem 44, the only two numbers among {1, 2, . . . , p − 1}
which have their inverse equal themselves are 1 and p − 1. Put them away and consider
98
§6. Wilson’s Theorem Masum Billal, Amir Hossein
the set A = {2, 3 . . . , p − 2}. There are p − 3 elements in this set, and each of them has
an inverse modulo p, as proved in Theorem 38. Furthermore, inverse of each number is
congruent to p. This means that the inverses of elements of A are distinct. So we can
divide the elements of A into (p − 3)/2 inverse pairs. Thus
2 ⋅ 3⋯(p − 2) ≡ 1 (mod p)
Multiply 1 and p − 1 to both sides of the above equation and the proof is complete.
Now, we should show that if n is not a prime number, then (n − 1)! ≡
/ −1 (mod n).
The theorem is obviously true for n = 3 and n = 4. So assume that n ≥ 5 is a composite
number. We can write n = pq where p and q are integers greater than 1. If p ≠ q, then
both p and q appear in (n − 1)!, which means (n − 1)! ≡ 0 (mod n). In case p = q, we
have n = p . Note that n > 2p and so both p and 2p appear in (n − 1)!, which again
2
99
§7. Euler and Fermat’s Theorem Masum Billal, Amir Hossein
Rewriting the last equation, we find that 2 is the modular inverse of −10! modulo 13.
Therefore, the answer is the modular inverse of 2 mod 13, which is 7.
Try the next problem yourself!
Problem 84. Let p be a prime such that p ≡ 1 (mod 4). Prove that
p−1 2
(( )!) ≡ −1 (mod p)
2
10 (mod 11). After you have done all the work, you should realize, like in Wilson’s
10
theorem, we are getting 1 again. This should encourage you to experiment with some
further values such as 2 (mod 5), 3 (mod 7) etc. Surprisingly, the result is always
4 6
1 when the exponent is 1. Pierre De Fermat was the first one to observe and propose
this.
8
Theorem 46 (Fermat’s Little Theorem). If p is a prime and a is a positive integer
such that a⊥p. Then
p−1
a ≡ 1 (mod p)
8
Fermat proposed (but did not prove) another theorem in number theory which is much more
difficult than this one. So they call this theorem the “little” one. The other theorem is called Fermat’s
Last Theorem.
100
§7. Euler and Fermat’s Theorem Masum Billal, Amir Hossein
Again, let’s see an example. Take a = 3 and p = 7. And consider the numbers
3 ⋅ 1, 3 ⋅ 2, 3 ⋅ 3, 3 ⋅ 4, 3 ⋅ 5, 3 ⋅ 6 modulo 7. They are respectively 3, 6, 2, 5, 1, 4. Notice
anything? It’s just a rearrangement of 1, 2, . . . , 6. In fact we already proved it before!
Now we will just multiply them all to get
3 ⋅ 1 × 3 ⋅ 2 × 3 ⋅ 3 × 3 ⋅ 4 × 3 ⋅ 5 × 3 ⋅ 6 ≡ 1 ⋅ 2 ⋅ 3 ⋅ 4 ⋅ 5 ⋅ 6 (mod 7)
Since 1, 2, . . . , 6 are all co-prime to 7, we can divide both sides of the above equation
by 1 ⋅ 2⋯6 to obtain
6
3 ≡ 1 (mod 7)
It is now clear that the same argument works for the general case. This PDF was created
for Amazon.
Proof. From the Definition §3, it is clear that the set A = {0, 1, . . . , p − 1} is a complete
′
residue system modulo p. We know that a⊥p, so from Proposition 40 the set A =
{0 ⋅ a, 1 ⋅ a, . . . , (p − 1) ⋅ a} is also a complete residue system modulo p. Putting aside the
′
first element, 0, it is clear that the product of the elements of A and A are congruent
modulo p:
In congruence equation (4), we can use the fact that (p, (p − 1)!) = 1 to divide both
sides by (p − 1)! and obtain a ≡ 1 (mod p).
p−1
You can find some other proofs for Fermat’s Little Theorem that use either number
theoretic techniques or even combinatorial approaches. For a very strange yet interest-
9
ing proof of this theorem, read the proof by counting necklaces in Engel.
Fermat’s little theorem comes in handy in so many situations, but it only handles
prime numbers. So we present the Euler’s theorem which is a more general form of
Fermat’s little theorem. The proof is similar as well. Let’s take the following example.
20 40 60
Problem 85. Show that 4 + 6 + 12 is divisible by 13.
9
Arthur Engel
1998 Problem-solving strategies, 1st ed., Springer, doi: 10.1007/b97682.
101
§7. Euler and Fermat’s Theorem Masum Billal, Amir Hossein
Solution. A common approach for this kind of problems is to take different moduli
(the first ones would be primes, obviously). Here, we will make use of modulo 29. We
will show that for any n of the form 28k +1 (for k ≥ 1), the number (2 +1) +4 will be
2n 2
102
§7. Euler and Fermat’s Theorem Masum Billal, Amir Hossein
Proof. Before we start the proof, remember Definition §3 where we defined Euler’s
totient function. The proof is very similar to the proof of Fermat’s theorem and you
only need to apply Proposition 43 once. Let A = {a1 , a2 , ⋯, aφ(m) } be a reduced residue
set mod m. Then so is B = {aa1 , aa2 , ⋯, aaφ(m) }. From the definition of reduced
systems, any number which is relatively prime to m is congruent to exactly one element
of A and exactly one element of B. Thus, the product of all elements of A must be
congruent to that of B, modulo B. Therefore
(aa1 )(aa2 )⋯(aaφ(m) ) ≡ a1 a2 ⋯aφ(m) (mod m)
φ(m)
⟹ a ⋅ (a1 a2 ⋯aφ(m) ) ≡ a1 a2 ⋯aφ(m) (mod m)
φ(m)
(5) ⟹ a ≡ 1 (mod m)
Note that in equation (5) we have used the fact that ai ⊥ m for 1 ≤ i ≤ φ(m), which
results in a1 a2 ⋯aφ(m) ⊥ m.
We can easily conclude the Fermat’s little theorem from Euler’s theorem: for a
≡ 1 (mod p) for any integer a not
φ(p) p−1
prime p, we have φ(p) = p − 1 and so a ≡a
divisible by p.
Problem 88. Let a and b be positive integers. Prove that in the arithmetic progression
ak + b (for k ≥ 0 an integer), there exist infinitely many terms with the same prime
divisors.
Solution. It’s not obvious at all how we should approach this problem. First, let us
discard the common factor between a and b so they do not have any common factor.
Then we see that ak + b = d(uk + v) for some relatively prime u, v. Since d is a fixed
positive integer, we now have to worry about uk + v only. We want to show that there
are many k such that uk + v has a fixed set of prime divisors. So, if we could show
anyhow that uk + v is the power of the same number for infinitely many k, that would
give us a solution (note that the converse does not have to be true).
Let d = (a, a + b). There exist positive integers a1 and c such that
a = da1
a + b = dc
nφ(a )
Also, (a1 , c) = 1 and c > 1 (why?). Using Euler’s theorem, one can write c 1
≡1
(mod a1 ) for any positive integer n. This means that there exists a positive integer tn
nφ(a1 )
such that c − 1 = tn a1 . Now,
a(ctn + 1) + b = da1 (ctn + 1) + (dc − da1 )
= dc(tn a1 + 1)
nφ(a1 )
= dc (c )
nφ(a1 )+1
= dc
Therefore, the only prime divisors of the term a(ctn + 1) + b in the progression are
prime divisors of dc, which are fixed (because d and c depend only on a and b, which
are fixed). This means that there exist infinitely many terms in the sequence which
have the same prime divisors and we are done.
103
§8. Quadratic Residues Masum Billal, Amir Hossein
§8 Quadratic Residues
Let n be a fixed positive integer. There are many cases when we are interested in
2
integers a relatively prime to n for which there exists another integer x such that a ≡ x
(mod n). As an example, assume that we want to solve the quadratic congruence
relation
2
ax + bx + c ≡ 0 (mod n)
2 2
(2ax + b) ≡ b − c (mod n)
which is of the form y ≡ z (mod n). Therefore, solving any quadratic congruence rela-
2
This means that the only quadratic residues modulo 7 are 1, 2, and 4.
104
§8. Quadratic Residues Masum Billal, Amir Hossein
p−1 2
1 ,2 ,...,( )
2 2
(mod p)
2
These numbers are distinct modulo p, because otherwise if x ≡ y (mod p) for some
2 2
x, y ∈ {1, 2, . . . , p−1
2
}, then
2 2
p∣x −y
⟹ p ∣ (x − y)(x + y)
p−1 2
1 ,2 ,...,( )
2 2
2
(ii) the product of two quadratic non-residues is also a quadratic residue, and
(iii) the product of a quadratic residue and a quadratic non-residue is a quadratic non-
residue.
105
§8. Quadratic Residues Masum Billal, Amir Hossein
Proof. The first one is obvious. If a ≡ x (mod p) and b ≡ y (mod p), then ab ≡ (xy)
2 2 2
(mod p). Let’s prove (iii) now. Assume that a ≡ x is a residue and b is a non-residue
2
modulo p and suppose to the contrary that ab is a residue and ab ≡ y (mod p). Then
2
2
ab ≡ x b
2
≡y (mod p)
2 −1 2
b ≡ (x ) ⋅y
−1 2 2
≡ (x ) ⋅ y
2
≡ (x (mod p)
−1
⋅ y)
(The proof is easy, try it yourself). From Theorem 48, we see that there are exactly (p−
1)/2 quadratic residues among {a, 2a, . . . , (p − 1)a}. Assume that a is a fixed quadratic
non-residue modulo p. From the proof of (iii), we can say that whenever a is multiplied
p−1
by one of quadratic residues of the set {1, 2, . . . , p−1}, the result is a non-residue.
2
Therefore, each non-residue element of {a, 2a, . . . , (p − 1)a} is multiplication of a by a
residue in the same set. This means that the multiplication of a by any non-residue
element of the set {a, 2a, . . . , (p − 1)a} is a residue, and we are done.
Theorem 49 gives us a nice result. Quadratic residues and quadratic non-residues
act just like 1 and −1. How? Notice that 1 × 1 = 1, (−1) × 1 = −1, and (−1) × (−1) = 1,
and this guides us to a point that quadratic residues behave like 1, and quadratic non-
residues behave like −1. We can represent this result using Legendre’s notation.
Legendre Symbol. We call ( ap ) the Legendre symbol for a prime p. It is defined by:
⎧
⎪0 if p ∣ a
⎪
⎪
a ⎪
(p) = ⎨1 if a is a quadratic residue of p
⎪
⎪
⎪
⎪
⎩−1 otherwise
Remark . Clearly, the same relation holds for the product of any n integers, that is,
a1 a2 ⋯an a1 an
( p ) = ( p )⋯( p )
106
§8. Quadratic Residues Masum Billal, Amir Hossein
Example. Theorem (50) is helpful specially when dealing with big numbers. For in-
stance, let’s see if 18 is a quadratic residue modulo 73. According to the theorem,
18 3 3 2
( ) = ( )( )( )
73 73 73 73
18 2
( )=( )
73 73
18 2
( )=( )=1
73 73
107
§8. Quadratic Residues Masum Billal, Amir Hossein
Theorem 51 (Euler’s Criterion). Let p be an odd prime and let a be an integer relatively
prime to p. Then
p−1 a
a 2
≡ (p) (mod p)
p−1
p−1
a 2
≡x ≡ 1 (mod p)
Now assume the case where a is a quadratic non-residue modulo p. Then we should
p−1
prove that a 2 ≡ −1. We will use an interesting approach here. Let b ∈ {1, 2, . . . , p −
1}. Since (b, p) = 1, the congruence equation bx ≡ a has a unique solution x ≡
a ⋅ b (mod p). Also, x ≡ / b (mod p) because otherwise b ≡ a (mod p) which is in
−1 2
contradiction with a being a non-residue. This means that the set {1, 2, . . . , p − 1} can
be divided into p−1
2
pairs (b, x) such that bx ≡ a (mod p). So
(p − 1)! = 1 × 2 × ⋯ × (p − 1)
≡a×a×⋯×a
Í ÎÌ Ï
p−1
2
times
p−1
≡a 2
(mod p)
p−1
By Wilson’s theorem, (p − 1)! ≡ −1 (mod p) and therefore a 2 ≡ −1 (mod p), as
desired. The proof is complete.
p−1
If p ≡ 1 (mod 4), that is, if p = 4k + 1, then p−1
2
is even and so (−1) 2 = 1. On the
other side, we know that ( −1
p
) is either 1 or −1. So in this case it must equal one. This
108
§8. Quadratic Residues Masum Billal, Amir Hossein
means that
p ≡ 1 (mod 4)
−1
⟺ ( p )=1
p−1
Note that the only if part of the above statement is true because if (−1) 2 = 1, then
p−1
2
= 2k for some integer k. So p = 4k + 1, or p ≡ 1 (mod 4). You can easily check
that the following statement is also true
p ≡ 3 (mod 4)
−1
⟺ ( p ) = −1
Each prime has either the form p ≡ 1 (mod 4) or p ≡ 3 (mod 4), so these primes
together make all primes. All in all,
−1 1, if p ≡ 1 (mod 4) or p = 2
( p )={
−1, if p ≡ 3 (mod 4)
Theorem 54. Let a and b be relatively prime positive integers. Then every prime
2 2
divisor of a + b is either 2 or of the form 4k + 1.
2 2
Proof. Let p be a prime divisor of a + b . If a and b both are odd then p can be 2.
Now assume p is larger than 2. Then
2 2
a ≡ −b (mod p)
p−1 p−1
2 2
⟹ (a ) 2
≡ (−b ) 2
(mod p)
p−1
If p is of the form 4k + 3, then 2
= 2k + 1 is odd, hence,
p−1 p−1
2 2
(a ) 2
≡ (−b ) 2
(mod p)
p−1 p−1
⟹ a ≡ −b (mod p)
But this is impossible because a⊥b. So p⊥a and p⊥b. By Fermat’s little theorem,
≡ 1 (mod p), which is in contradiction with the above equation since p is
p−1 p−1
a ≡b
2 2
odd. So, p cannot be of the form 4k + 3 and therefore every odd prime divisor of a + b
is of the form 4k + 1.
109
§8. Quadratic Residues Masum Billal, Amir Hossein
110
§8. Quadratic Residues Masum Billal, Amir Hossein
However, we only have even integers in A. For example, take p = 11. Then A =
{2, 4, 6, 8, 10} and B = {1, 2, 3, 4, 5}. Now, we want to construct 5! using the product
of elements of A. Clearly, the elements 2 and 4 are directly chosen from A. Now it
remains to somehow construct the product 1 × 3 × 5 with the elements 6, 8, 10. The
trick is pretty simple: just notice that 10 ≡ −1, 8 ≡ −3, and 6 ≡ −5 (mod 11). This
means that 6 × 8 × 10 ≡ (−1) ⋅ 1 × 3 × 5, and so
3
3
(7) 2 × 4 × 6 × 8 × 10 ≡ (−1) ⋅ 5!
Let’s go back to the solution of the general problem. As in the example of p = 11, we
are searching for the power of (−1) appeared in the congruence relation. In fact, this
power equals the number of even elements bigger than p−1 2
and less than or equal to
p − 1. Depending on the remainder of p modulo 8, this power of (−1) can be even or
odd. Consider the case when p ≡ 1 (mod 8). Then p − 1 = 8k for some positive integer
k and so the even numbers less than or equal to p−1 2
= 4k in the set A = {2, 4, . . . , 8k}
are 2, 4, . . . , 4k, which are 2k + 1 numbers. Therefore
2k+1 items 2k items
Ì ÏÍ Î Ì ÏÍ Î
2 × 4 × ⋯ × (p − 1) = (2 × 4 × ⋯ × 4k) ⋅ ((4k + 2) × (4k + 4) × ⋯ × 8k)
≡ (2 × 4 × ⋯ × 4k) ⋅ ((−(4k − 1)) × (−(4k − 3)) × ⋯ × (−1))
2k
≡ (−1) ⋅ (4k)!
p−1
≡ (−1) ⋅ ( )! (mod p)
2k
2
111
§8. Quadratic Residues Masum Billal, Amir Hossein
The process is similar for p ≡ 3, 5, 7 (mod 8) and we put it as an exercise for the
reader.
After all this work, we are finally done computing ( p2 ). The final result is stated in
the following theorem.
Theorem 55.
2 1, if p ≡ 1 or 7 (mod 8)
(p) = {
−1, if p ≡ 3 or 5 (mod 8)
We can generalize the method used in the solution of Problem 92 to find ( ap ) for all
integers a and primes p.
Theorem 56 (Gauss’ Criterion). Let p be a prime number and let a be an integer
relatively prime to p. Let µ(a, p) denote the number of integers x among
p−1
a, 2a, . . . , a
2
such that x > p/2 (mod p). Then
a µ(a,p)
( p ) = (−1)
ri < p + r
ri = p + s
≡ s (mod p)
112
§8. Quadratic Residues Masum Billal, Amir Hossein
where a1 , a2 , . . . , an are divisors of a. This means that if we know the value of ( pq ) for
a prime q, we can find the values of ( ap ) for any a.
So let’s discuss on the value of ( pq ). If q is a big prime number, then by Corollary
q
16, we can reduce q modulo p until we reach some c < p and find ( p ) by some method
(Euler’s or Gauss’s criteria). So we can handle the case when q is a big prime.
Now, what about the case when p is a big prime? In this case, finding ( pq ) would
be very hard with theorems and methods stated by now. There is a very nice property
of prime numbers which helps us to handle this case. This property is called the Law
of Quadratic Reciprocity which relates ( pq ) and ( pq ). So, in case q is big, we can first
calculate ( pq ) and then use this law to find ( pq ).
11 6661
( )( ) = (−1)
5⋅3330
(8) = −1
6661 11
The proof of this theorem is a bit complicated and it would make you lose the
continuity of the context. For this reason, we will provide the proof in section (§9).
113
§8. Quadratic Residues Masum Billal, Amir Hossein
Also, we define ( a1 ) to be 1.
Remark . The immediate result of the above definition is that if gcd(a, n) = 1, then
( na ) is either +1 or −1. Otherwise, it equals zero.
Example.
14 14 14 14 2
( ) = ( )( )( )
2535 3 5 13
2 4 1 2
= ( )( )( )
3 5 13
= (−1) ⋅ 1 ⋅ 1
= −1
Example.
2 2 2
( ) = ( )( )
15 3 5
= (−1) ⋅ (−1)
=1
Proof. The if part is easy to prove. Assume that a is a quadratic residue modulo n
α
and a ≡ x (mod n) for some integer x. Then a ≡ x (mod pi i ) since pi s are relatively
2 2
α
prime to each other. Now the only if part: assume that a ≡ xi (mod pi i ) for all i,
2
114
§9. Quadratic Residues Masum Billal, Amir Hossein
where xi are integers. According to Chinese Remainder Theorem, since the numbers
α
pi i are pairwise relatively prime, the system of congruence equations
α
x ≡ x1 (mod p1 1 )
α
x ≡ x2 (mod p2 2 )
..
.
α
x ≡ xk (mod pk k )
α
has a solution for x. Now x ≡ xi ≡ a (mod pi i ), and therefore x ≡ a (mod n), which
2 2 2
Theorem 60. Let a and b be any two integers. Then for every two odd integers m and
n, we have
ab a b
( n ) = ( n )( n )
a + bn a
( n ) = (n)
m n m−1 n−1
( n )( m ) = (−1) 2 2
⋅
a a a
( mn ) = ( n )( m )
−1 n−1
( n ) = (−1) 2
2
2 n −1
( n ) = (−1) 8
Theorem 61. If a positive integer is a quadratic residue modulo every prime, then it
is a perfect square.
13
This is a really cool theorem. However, proving this might be challenging! Give
it a try.
Theorem 62. Let b, n > 1 be integers. Suppose that for each k > 1 there exists an
n n
integer ak such that b − ak is divisible by k. Prove that b = A for some integer A.
115
§9. Wolstenholme’s Theorem Masum Billal, Amir Hossein
§9 Wolstenholme’s Theorem
Well, not exactly. We are more interested in this sum modulo p where p is a prime.
But how do we calculate fractions modulo p? The answer should be obvious by now. ab
(mod p) is actually ab (mod p) where b (mod p) is the inverse of b modulo p. So
−1 −1
116
§9. Wolstenholme’s Theorem Masum Billal, Amir Hossein
p−1
Note. According to our assumption, the sum ∑k=1 1/k has been written in lowest
terms, that is, as a fraction a/b such that (a, b) = 1.
Remark . Theorem (63) is not the original theorem stated by Wolstenholme. Actually
the theorem was as stated below.
2p 3
( p ) ≡ 2 (mod p )
2p − 1 3
( p − 1 ) ≡ 1 (mod p )
This seems to be a very interesting theorem, however the proof is not straightfor-
ward. Let us tackle this theorem step by step (these steps are really intuitive and
very useful in olympiad problems). But first we will show a weaker version of the
Theorem 64.
2p 2
( p ) ≡ 2 (mod p )
The last line is true because from Theorem 32, for 0 < i < p, we have
p
( i ) ≡ 0 (mod p)
2
p 2
( i ) ≡ 0 (mod p )
S ≡ 0 (mod p)
117
§9. Wolstenholme’s Theorem Masum Billal, Amir Hossein
Proof. The proof is straightforward. There are p − 1 terms in the sum and since p > 3
is an odd prime, the number of terms is even. So we can write S as sum of pairs of the
1
form k1 + ˚ p−k , for k = 1, 2, . . . , p−1
2
. Thus
1 1 1
S =1+ + +⋯+
2 3 p−1
1 1 1 1 1
= (1 + ) + ˚( + ) + ⋯ + ( p−1 + )
p−1 2 p−2 p−1
+1
2 2
p−1
2
1 1
= ∑( + )
k=1
k p − k
p−1
2
(k) + (p − k)
=∑
k=1
k(p − k)
p−1
2
p
=∑
k=1
k(p − k)
p−1
2
1
=p⋅∑
k=1
k(p − k)
≡ 0 (mod p)
a
In the last line of above equations, the sum can be written as (p−1)! , where a is some
integer. Note that (p, (p − 1)!) = 1 and that’s why we can conclude
p−1
2
1
p⋅∑ ≡ 0 (mod p)
k=1
k(p − k)
Proof. We recommend you re-read section (§4.2) if you have forgotten the definition of
multiplicative inverse. We already know that
2 2 2 (p − 1)(p)(2p − 1)
1 + 2 + ⋯ + (p − 1) =
6
Clearly, the sum is an integer. Therefore (p − 1)(p)(2p − 1) is divisible by 6. Now since
p > 3, we have (p, 6) = 1 and thus p divides (p − 1)(p)(2p − 1)/6. Therefore,
2 2 2
1 + 2 + ⋯ + (p − 1) ≡ 0 (mod p)
118
§9. Wolstenholme’s Theorem Masum Billal, Amir Hossein
equal. A proof is as follows: from Theorem 38, for any x ∈ A, there exists some y ∈ B
such that xy ≡ 1 (mod p). This y is unique, because if there exists some other z ∈ B
for which xz ≡ 1 (mod p), then xy ≡ xz (mod p), and since (x, p) = 1, we have y ≡ z
(mod p) which means y = z (why?). So there exists a unique y ∈ B for each x ∈ A,
and thus A = B since A and B have equal number of elements. Finally,
−1 2 −1 2 −1 2 2 2 2
(1 ) + (2 ) + ⋯ + ((p − 1) ) ≡ 1 + 2 + ⋯ + (p − 1)
≡ 0 (mod p)
Proof.
≡ 1 (mod p)
−1
a⋅a
n −1 n
⟹ a ⋅ (a ) ≡ 1 (mod p)
−1 n n −1
⟹ (a ) ≡ (a ) (mod p)
1 (p − 1)!
2
= ⋅∑
(p − 1)! i=1 i(p − i)
119
§9. Wolstenholme’s Theorem Masum Billal, Amir Hossein
Define
(p − 1)!
ai =
i(p − i)
for i = 1, 2, . . . , p−1
2
. From Wilson’s theorem, we know that (p − 1)! ≡ −1 (mod p).
Observe that
i ⋅ (p − i) ⋅ ai = (p − 1)! ≡ −1 (mod p)
Notice that the above equations are true for i = 1, 2, . . . , (p − 1)/2. Now, (9) means
2
that ai is the multiplicative inverse of i modulo p. So we have proved that
(p − 1)!
(11) ai =
i(p − i)
2 −1
(12) ≡ (i ) (mod p)
where (i )
2 −1 2
for i = 1, 2, . . . , p−1
2
means the multiplicative inverse of i modulo p. We
(p−1)/2
should now prove that the sum of all ai s is divisible by p. Let a = ∑i=1 ai . According
to (11),
p−1
2
a = ∑ ai
i=1
p−1
2
2 −1
= ∑(i )
i=1
p−1
2
−1 2
(13) a ≡ ∑(i ) (mod p)
i=1
We want to show that a ≡ 0 (mod p). The trick is to convert (13) to what we proved
120
§9. Wolstenholme’s Theorem Masum Billal, Amir Hossein
p−1 p−1
2 2
−1 2 −1 2
2a ≡ a + a ≡ ∑(i ) + ∑(i )
i=1 i=1
p−1 p−1
2 2
−1 2 −1 2
≡ ∑(i ) + ∑(−(i) )
i=1 i=1
p−1 p−1
2 2
−1 2 −1 2
≡ ∑(i ) + ∑((−i) )
i=1 i=1
p−1 p−1
2 2
−1 2 −1 2
≡ ∑(i ) + ∑((p − i) )
i=1 i=1
p−1
2 p−1
−1 2 −1 2
≡ ∑(i ) + ∑ (i )
i=1 p+1
i= 2
p−1
−1 2
≡ ∑(i )
i=1
≡ 0 (mod p)
Thus a ≡ 0 (mod p) and we are done.
We are ready to prove Wolstenholme’s theorem now.
Proof of Wolstenholme’s Theorem. According to Lemma 2, we can write S as
p−1
2
1
S =p⋅∑
i=1
i(p − i)
From Lemma 5, we know that the above sum is divisible by p, so S is divisible by
2
p.
Problem 93. Let p ≥ 5 be a prime number, and
1 1 a
1 + + ... + p =
2 b
where a and b are two relatively prime integers. Show that p ∣ ap − b.
4
121
§9. Wolstenholme’s Theorem Masum Billal, Amir Hossein
where a and b are two relatively prime integers. Show that p ∣ a − b + bp.
3
where x and y are relatively prime integers with y⊥p (we have used Wolstenholme’s
theorem in the last line). Now,
2
a px
+p−1=p⋅ y
b
3
⟹ (a − b + bp)y = p xb
Problem 95. For any prime p and a positive integer k such that 1 ≤ k ≤ p − 1, prove
that
p−1 k
( ) ≡ (−1) (mod p)
k
Solution. We use the fact that p − i ≡ −i (mod p) and that (i, p) = 1 for 0 < i < p.
122
§9. Wolstenholme’s Theorem Masum Billal, Amir Hossein
Solution. The approach is not obvious here unless one knows the above theorem.
In problems like this, it is usually hard to pin down how to approach the problem.
However, one should of course try to make use of the fact that
p p p p
2 = (1 + 1) = 1 + (1) + ⋯ + (p − 1) + 1
p p−1 p p−1
=1+ ( 0 )+⋯+ ( )+1
1 p−1 p−2
So,
Now, the problem is in a suitable shape and we can use the theorem above to write
p
2 −2 1 p−1 1 p−1 1 p−1
p = 1 ( 0 ) + 2 ( 1 ) + ⋯ + p − 1 (p − 2)
0 1 1 1 p−3
≡ (−1) + (−1) + ⋯ + (−1)
2 p−1
1 1
≡1− +⋯− (mod p)
2 p−1
Corollary 18. For an odd prime p,
p−1
2 −1 1 1
p ≡1− +⋯− (mod p)
2 p−2
Problem 97. Let p ≥ 5 be a prime. Prove that
2
p 5
(p) ≡ p (mod p )
123
§10. Wolstenholme’s Theorem Masum Billal, Amir Hossein
14
A result from Carlitz.
Problem 98. Let k be a non-negative integer and p ≥ 5 be a prime. Prove that
1 1 1 2
+ + ... + ≡ 0 (mod p )
kp + 1 kp + 2 kp + (p − 1)
Hint. Use the following:
p−1 p−1
1 1 1 1
∑ = ∑( + )
i=1
kp + i 2 i=1 kp + i kp + p − i
124
§10. Lucas’ Theorem Masum Billal, Amir Hossein
In 2010, the following problem was posed in Bangladesh national mathematical Olympiad:
Problem 103. Find the number of odd binomial coefficients in the expansion of (a +
2010
b) .
Here is a hint: you need to find the value of (2010
i
) (mod 2) for 0 ≤ i ≤ 2010. One
idea for doing that is to count the exponent of 2 in (2010 i
) using Legendre’s theorem.
Then look for the condition when a coefficient can be odd.
Here, we will focus on a generalized version of such problems. In problems like this,
it happens that we need to find the remainder of division of the binomial coefficient
(mn
) by a prime number p. Édouard Lucas found patterns in Pascal triangle which
16
resulted in the following theorem. Lucas proved the following theorem as part of his
investigation into the Lucas sequences of first kind and second kind.
Theorem 66 (Lucas’s Theorem). Let p be a prime and let m and n be non-negative
integers. Then
k
m mi
( n ) ≡ ∏ ( n ) (mod p)
i
i=0
where
k k−1
m = mk p + mk−1 p + ⋯ + m1 p + m0
k k−1
n = nk p + nk−1 p + ⋯ + n1 p + n0
are the base p expansions of m and n respectively. This uses the convention that (m
n
)=0
if m < n.
Example. For p = 7, m = 67, and n = 10. Now
2
67 = 1 ⋅ 7 + 2 ⋅ 7 + 4
2
10 = 0 ⋅ 7 + 1 ⋅ 7 + 3
and therefore
67 1 2 4
(10) ≡ (0)(1)(3)
≡1⋅2⋅4
≡ 1 (mod 7)
16
Edouard Lucas
1878 “Théorie des Fonctions Numériques Simplement Périodiques”, American Journal of Mathematics,
vol. i, no. 3, pp. 197-240, doi: 10.2307/2369311, Page 230, § XXI.
125
§10. Lucas’ Theorem Masum Billal, Amir Hossein
Proof. We will use induction on r to prove them lemma. The base case r = 1 is easy:
for any integer k such that 1 ≤ k ≤ p − 1, we know that (kp) ≡ 0 (mod p). Now
p p p 2 p p−1 p
(1 + x) ≡ 1 + (1)x + (2)x + ⋯ + (p − 1)x + x
p
≡1+x (mod p)
r r
Now suppose that (1 + x) (mod p) is true for some integer r ≥ 1. Then
p p
≡1+x
r+1 r p
p p
(1 + x) ≡ ((1 + x) )
r p
p
≡ (1 + x )
p p pr p 2pr p (p−1)p
r p pr+1
≡ (0) + (1)x + (2)x + ⋯ + (p − 1)x + (p)x
r+1
p
≡1+x (mod p)
k k−1
m mk p +mk−1 p +⋯+m1 p+m0
(1 + x) = (1 + x)
k k−1
p mk p mk−1 p m1 m0
= [(1 + x) ] [(1 + x) ] ⋯[(1 + x) ] (1 + x)
k k−1
p mk p mk−1 p m1 m0
≡ (1 + x ) (1 + x ) ⋯(1 + x ) (1 + x) (mod p)
k
m mi
( n ) ≡ ∏ ( n ) (mod p)
i
i=0
126
§10. Lucas’ Theorem Masum Billal, Amir Hossein
Corollary 20. The binomial coefficient (nk) is divisible by p if and only if at least one
of the digits of k in base p is greater than the corresponding digit n in base p.
Corollary 21. Let s, t, q, r be non-negative integers and p p be a prime such that 0 ≤
q, r ≤ p − 1. Then
sp + q s q
( tp + r ) ≡ ( t )(r) (mod p)
Problem 104. How many ordered triples (a, b, c) of positive integers satisfy a + b + c =
94 and 3 does not divide
94!
?
a!b!c!
Solution. Write c = 94 − a − b, and hence
94! 94 94 − a
=(a)⋅( b )
a!b!(94 − a − b)!
S = {1, 3, 4, 9, 10, 12, 13, 81, 82, 84, 85, 90, 91, 93, 94}
By symmetry, we only need to find a, b, c which are elements of S. There exist six such
triples (a, b, c) which sum to 94:
(1, 3, 90), (1, 9, 84), (1, 12, 81), (3, 9, 82), (3, 10, 81), (4, 9, 81)
2pq − 1
( pq − 1 ) ≡ 1 (mod pq)
if and only if
2p − 1
( p − 1 ) ≡ 1 (mod q)
2q − 1
( q − 1 ) ≡ 1 (mod p)
127
§11. Lagrange’s Theorem Masum Billal, Amir Hossein
Solution. Since 2pq − 1 = (2q − 1)p + p − 1, the rightmost digit of 2pq − 1 when
represented in base p is p − 1 and the other digits form 2q − 1. Analogously, the
rightmost digit of pq − 1 when represented in base p is p − 1 and the other digits form
q − 1. Applying corollary (21), we find
2pq − 1 2q − 1 p − 1
(14) ( pq − 1 ) ≡ ( q − 1 )(p − 1)
2q − 1
(15) ≡ ( q − 1 ) (mod p)
The if part is obvious since p and q are different primes. We will prove the only if part
now.
Suppose that (2pq−1
pq−1
) ≡ 1 (mod pq). This means that (2pq−1pq−1
) ≡ 1 (mod p). By
equation (15), (2q−1
q−1
) ≡ 1 (mod p) as desired. Proving (2p−1
p−1
) ≡ 1 (mod q) is similar.
Problem 107. Let n and k be arbitrary positive integers and let p be an odd prime
p. Prove that
2 pk k
p ∣ (pm) − (m)
pm p(n−m)
Hint. Induct on n and equate the coefficients of a b in both sides of
pn p(n−1) p
(a + b) = (a + b) (a + b)
3 4 2
P (x, y, z) = 2x + xy − 7xyz + 3zy − 6
5
Note. We only work with polynomials of a single variable and with integer coefficients
in this book.
128
§11. Lagrange’s Theorem Masum Billal, Amir Hossein
Definition. Consider a polynomial P (x) with integer coefficients. The degree of P (x)
is the largest exponent of x in P (x). That is, if
n n−1
P (x) = an x + an−1 x + ⋯ + a1 x + a0
where ai , 0 ≤ i ≤ n are integers and an ≠ 0, then the degree of P (x) is n. We show this
by deg P (x) = n.
Definition. Let
n n−1
P (x) = an x + an−1 x + ⋯ + a1 x + a0
be a polynomial with integer coefficients. Assume that at least one coefficient of P (x)
is not divisible by p. For any prime p, the degree of P (x) modulo p is the largest integer
k, 0 ≤ k ≤ n, for which p ∤ ak . We denote this by degp P (x) = k.
P (x) is 2 modulo 7.
∀i, k ∈ N, we have P (x + kp) ≡ 0 (mod p) as well. This means that we only need to
search for solutions in the set {0, 1, . . . , p − 1}. The term incongruent solutions in the
above theorem is there just for the same reason.
Example. Let P (x) = 10x +3x +12x+17. The degree of P (x) modulo 5 is 2. According
3 2
to Lagrange’s theorem, the equation P (x) ≡ 0 (mod 5) has at most 2 solutions modulo
5. To check this, note that
3 2
P (x) = 10x + 3x + 12x + 17
2
≡ 3x + 12x + 12
2
≡ 3(x + 2)
≡ 0 (mod 5)
129
§11. Lagrange’s Theorem Masum Billal, Amir Hossein
where ak , ak−1 , . . . , a0 are coefficients of P (x). It is clear that for k = 0, the equation
f (x) = a0 has no solutions modulo p because p ∤ a0 . Assume that the claim is true
for all polynomials of degree up to k − 1 modulo p. Assume that P (x) ≡ 0 (mod p)
has d solutions. If d < k, we are done. Otherwise, if d ≥ k, take x1 , x2 , . . . , xk to be k
arbitrary incongruent solutions of P (x) ≡ 0 (mod p). Define
Q(x1 ) ≡ Q(x2 )
≡⋯
≡ Q(xk )
≡ 0 (mod p)
which means Q(x) ≡ 0 (mod p) has at least k solutions. The induction hypothesis
forces that Q(x) ≡ 0 (mod p) for all x. It follows that
This means that P (x) ≡ 0 (mod p) if and only if x − xi ≡ 0 (mod p) for some i ∈
{1, 2, . . . , k}. So, x1 , x2 , . . . , xk are the only solutions to P (x) ≡ 0 (mod p). The
induction is complete.
In this section, we will discuss only the following result and see how to apply it to
prove some other theorems.
Theorem 68 (Lagrange). If p is a prime and
p−1 p−2
(16) (x + 1)(x + 2)⋯(x + p − 1) = x + a1 x + ⋯ + ap−2 x + (p − 1)!
or equivalently,
130
§11. Lagrange’s Theorem Masum Billal, Amir Hossein
Substituting the expressions for f (x) and f (x + 1) in equation (16), we see that
p−1 p−2
pf (x) = px + pa1 x + ⋯ + pap−2 x + p!
p p−1
(x + 1)f (x + 1) = (x + 1) + a1 (x + 1)
2
+ ⋯ + ap−2 (x + 1) + (x + 1)(p − 1)!
p p−1 2
xf (x) = x + a1 x + ⋯ + ap−2 x + x(p − 1)!
i i i i i−1 i i−2 i i
(x + 1) − x = (x + (1)x + (2)x + ⋯ + (i − 1)x + 1) − x
i i−1 i i−2 i
(19) = (1)x + (2)x + ⋯ + (i − 1)x + 1
and a1 ((x + 1) − x )). Using (19) to calculate these two terms, we get
p−1 p−1
p p−1
pa1 = (2) + ( 1 )a1
From Theorem 32, we know that p divides (kp) for any 0 < k < p. So, p divides (p2),
therefore p divides a1 .
p−3
Equating coefficient of x , we find
p p−1 p−2
pa2 = (3) + ( 2 )a1 + ( 1 )a2
Here, p divides (p3) and a1 , so p divides a2 . Continuing this process in a similar way, we
find that a1 , a2 , . . . , ap−2 are divisible by p. To check correctness of this, we can equate
the coefficient of x and find
p p−1 2
pap−2 = (p − 1) + (p − 2)a1 + ⋯ + (1)ap−2
131
§11. Lagrange’s Theorem Masum Billal, Amir Hossein
a1 = 1 + 2 + ⋯ + p − 1
a2 = 1 ⋅ 2 + ⋯ + 1 ⋅ (p − 1) + 2 ⋅ 3 + ⋯ + 2 ⋅ (p − 1) + ⋯
..
.
You should already guess what a1 , . . . , ap−2 are. a1 is the sum of all 1, ⋯, p − 1. a2 is
the sum of products of two numbers from 1, ⋯, p − 1 (all possible (p−1 2
) combinations).
Similarly, ap−2 is the sum of products of p − 2 numbers taken at a time. In general ai
the sum of all possible products of i numbers taken from 1, 2, ⋯, p − 1. Therefore, we
can state Theorem 68 as
Theorem 69. If p is an odd prime and 0 < k < p − 1, then the sum of all possible
products of k numbers taken at a time from 1, 2, . . . , p − 1 is divisible by p.
Let’s see just how powerful this theorem can be, if used properly. We can take
advantage of the fact that the theorem is actually an identity, so we can choose x freely
as we wish.
and so,
p! = 1 + a1 + ⋯ + ap−2 + (p − 1)!
Here, left side is divisible by p so must be right side. Again, since a1 , . . . , ap−2 are
multiples of p, we have x + (p − 1)! is a multiple of p.
p−1
p−1
x ≡ −(p − 1)! (mod p)
132
§12. Order, Primitive Roots Masum Billal, Amir Hossein
As for the last demonstration, we will use it to prove Wolstenholme’s theorem, which
we also proved before. The theorem requires us to show that for p > 3 a prime, the
numerator of
1 1
1+ +⋯+
2 p−1
2
is divisible by p in its reduced form.
Proof of Wolstenholme’s Theorem. The numerator is the sum of products of p−2 num-
bers taken from 1, 2, . . . , p − 1. So, it is ap−2 . Since the denominator of the fraction is
(p − 1)!, which is not divisible by p, we only need to show that p ∣ ap−2 .
2
which gives
p−2 p−3 2
ap−2 = p + a1 p + ⋯ + ap−3 p
2
If p > 3, then p − 2 ≥ 2 and all the terms on the right side are divisible by p .
Note. You should try to guess what motivates us to set exactly those values of x to
get nice results.
Recall the examples we took while discussing Fermat’s little theorem. We were working
with something like 2 (mod 7) or 6 (mod 7). While calculating, we found that 6 ≡ 1
6 6 2
Along with the ideas we used there, did you conjecture anything else? We left a hint
when we said that since 6 ≡ 1 (mod 7), 6 ≡ 1 (mod 7) and 6 ≡ 1 (mod 7) as well.
2 4 6
We hope that this is sort of obvious by now. But it should also trigger you to think
of something. If we can find the smallest exponent for which 2 ≡ 1 (mod 7), then
x
we can say 2 ≡ 1 (mod 7) for all multiples of x (y here). We will shortly prove this
y
formally. Moreover, it also encourages us to study these smallest values for which we
get 1. The motivation is obvious. Whenever we get 1, we get a cycle of remainders
from which point, the remainders repeat. Just finish the examples above if you did not
entirely understand what we meant. We call this smallest integer order. And it should
be clear to you why the study of order is important.
133
§12. Order, Primitive Roots Masum Billal, Amir Hossein
Theorem 70. Let a and n be positive integers. If ordn (a) = d and a ≡ 1 (mod n),
x
then d ∣ x.
Proof. If x < d, it would contradict the fact that, d is such smallest positive integer
that a ≡ 1 (mod n). We are left with the case x > d. Assume that x = dq + r with
d
0 ≤ r < d.
x dq r
a ≡a ⋅a (mod n)
d q r
≡ (a ) ⋅ a (mod n)
r
≡ 1 ⋅ a (mod n)
r
≡ a (mod n)
So a ≡ a ≡ 1 (mod n). Since 0 ≤ r < d and d is the order of a, this is impossible
r x
Proof. a ≡ a (mod n) implies a ≡ 1 (mod n). By Theorem 70, we have ordn (a) ∣
k l k−l
k − l. The reverse of this approach can be applied to prove the other part of the
corollary.
One could ask if we know the order of a modulo n, how do we find the order of
other powers of a. Or, if we know order of a modulo two positive integers m and n,
then what would be the order of a modulo mn?
Theorem 71. If m and n are relatively prime positive integers such that ordm (a) = d
and ordn (a) = e, then ordmn (a) = [d, e].
Proof. Let ordmn (a) = h, so
h
a ≡ 1 (mod mn)
which gives a ≡ 1 (mod m) and a ≡ 1 (mod n) as well. By Theorem 70, since d and
h h
134
§12. Order, Primitive Roots Masum Billal, Amir Hossein
Theorem 72. Let a, b, and n be positive integers such that ordn (a) = k and ordn (b) = l,
where k⊥l. Then ordn (ab) = kl.
Proof. Let ordn (ab) = h. First, note that
lh lh lh
a ≡a ⋅b (mod n)
lh
≡ (ab) (mod n)
h l
≡ ((ab) ) (mod n)
≡ 1 (mod n)
So, by Theorem 70, we have k ∣ lh and since (k, l) = 1, it follows that k ∣ h. We can
similarly prove that l ∣ h. So kl ∣ h. On the other hand,
kl k l l k
(ab) ≡ (a ) ⋅ (b ) (mod n)
≡ 1 (mod n)
Again, by Theorem (70), we have h ∣ kl. This finishes the proof.
k
Theorem 73. If the order of a modulo n is d, then the order of a modulo n is d/(d, k).
k h
Proof. Let the order of a modulo n be h. Then (a ) ≡ a ≡ 1 (mod n). Theorem 70
k kh
says that d must divide kh. Assume that (k, d) = g, so there exist relatively prime
positive integers l and e such that k = gl and d = ge. Rewriting d ∣ kh implies
ge ∣ glh ⟹ e ∣ lh
and since l⊥e, e must divide h. Since dl = ke = gel,
k e d l
(a ) ≡ (a )
≡ 1 (mod n)
k
This means that the order of a modulo n must divide e. So, h divides e as well. We
get that
d
h=e=
(d, k)
must hold.
The previous theorem also implies the following one.
k
Theorem 74. The order of a modulo n is the same as the order of a modulo n if and
only if (k, n) = 1.
Here is a very useful theorem, often used to solve Diophantine equations.
Theorem 75. Let q be a prime and x be a positive integer. Every prime divisor of the
number
q−1
1+x+⋯+x
is either q or congruent to 1 modulo q.
135
§12. Order, Primitive Roots Masum Billal, Amir Hossein
S ≡ 1 + 1 + ⋯ + 1 (mod p)
which gives 0 ≡ q (mod p). So, p = q. Now assume the case that d = q. Because of
Fermat’s little theorem,
p−1
x ≡ 1 (mod p)
These two notes tell us that if g is a primitive root of n, then the set {g, g , ⋯, g }
2 φ(n)
is equal to Un , where Un is the set of units modulo n (as defined in Definition §3). Notice
that equality of these two sets is considered modulo n. Actually, the set {g, g , ⋯, g }
2 φ(n)
may contain some elements larger than n. We reduce those elements modulo n so that
we have all elements less than n. This new set is now equal to Un . We may denote this
by the notation {g, g , ⋯, g } ≡ Un (mod n).
2 φ(n)
Theorem 76. A primitive root g modulo n (if existing) is a generator of Un . That is,
for any a ∈ U, there is a unique k with 0 < k ≤ φ(n) such that g ≡ a (mod n).
k
136
§12. Order, Primitive Roots Masum Billal, Amir Hossein
This is not possible unless u = v. The reason is simple: if u ≠ v, then we have found
some x = u − v such that 0 < x ≤ φ(n) and g ≡ 1 (mod n), which is in contradiction
x
2. Let’s see if there exists a primitive root modulo 15. To show this, a possible way
i
is to start from a = 2 and compute all the powers a for i = 2, . . . , φ(15) − 1 = 7
modulo 15 one by one:
2 3 4
2 ≡ 4, 2 ≡ 8, 2 ≡1
4
We stop at 2 because we got 1 mod 15, and this shows that 2 is not a primitive
root modulo 15. Then, we should do the same process, but this time for a = 4 (we
don’t check 3 because it’s not relatively prime to 15). Now you should be able to
do the math much faster, and come up with 4 ≡ 1 (mod 15), which shows a = 4
2
is not a primitive root modulo 15. Fortunately, we don’t need to check a = 5 and
a = 6. For a = 7, the computations are not as easy as a = 2 and a = 4, but still
not hard
2 3 4
7 ≡ 4, 7 ≡ 13, 7 ≡1
So, 7 is not a primitive root mod 15 either. Now, we don’t need to do the
−1
computations for a = 8 because in this case, a is 2 and we showed that 2 is
not a primitive root (why is that enough?). The next values for a to check are
−1
11, 13, and 14. Since 13 = 7 , we don’t need to worry about 13. Check 11 and 14
for yourself and verify that neither of them are primitive roots mod 15 (we can’t
do the modular arithmetic invers trick here because 11 and 14 are the inverse of
themselves modulo 15). This shows that there is no primitive root mod 15.
3. Let’s assume that elements gi of Un are sorted in ascending order. That is,
g1 < ⋯ < gφ(n) . Then we have g1 = 1 and gφ(n) = n − 1.
Corollary 24. If g is a primitive root of p then
1 2 p−1
G = {g , g , . . . , g }
137
§12. Order, Primitive Roots Masum Billal, Amir Hossein
Theorem 77. Let n be a positive integer and let a be a quadratic non-residue modulo
n such that a⊥n. Assume that Un = {g1 , g2 , . . . , gφ(n) }. Then
φ(n)
g1 g2 ⋯gφ(n) ≡ a 2
(mod n)
Proof. According to Theorem 37, for any gi , there exists some x such that
(20) gi x ≡ a (mod n)
Here is a nice theorem which relates primitive roots and quadratic residues modulo
a prime p.
Theorem 78. If g is a primitive root modulo a prime p, then the quadratic residues of
2 4 p−1
p are g , g , . . . , g .
Proof. By Euler’s criterion, we know that if a is a quadratic residue modulo p, then
p−1
a 2
≡ 1 (mod p)
2 4 p−1
Using Fermat’s little theorem, it follows that g , g , . . . , g are all quadratic residues
modulo p. Since the set {g , g , . . . , g } is a complete residue set modulo p and we
1 2 p−1
138
§12. Order, Primitive Roots Masum Billal, Amir Hossein
But this would contradict the minimality of φ(n) since k is less than φ(n), meaning
that g is not a primitive root.
For the “only if” part, assume that for every prime divisor p of φ(n), we have
φ(n)
g p
/ 1 (mod n)
≡
We want to show that g is a primitive root modulo n. Let d = ordn (g), so that d ∣ φ(n).
If d < φ(n), then we must have d ∣ φ(n)/p for some prime p dividing φ(n). Letting
φ(n) = pdl,
φ(n)
dl
g p
≡g (mod n)
d l
≡ (g ) (mod n)
≡ 1 (mod n)
Note. In the proof above, we could just take p to be the smallest prime divisor of φ(n).
Then we must have that d is a divisor of φ(n)/p. This is because the greatest divisor
of n less than n is n/p, where p is the smallest prime divisor of n (can you sense why?).
m
Corollary 25. Let m be a positive integer. If g is a primitive root of n, then g is also
a primitive root modulo n if and only if m⊥φ(m).
Proof. Let (m, φ(n)) = d, so that mφ(n) = d ⋅ [m, φ(n)]. According to Theorem 79,
m
g is a primitive root modulo n if and only if
d⋅[m,φ(n)]/p
(21) g / 1 (mod n)
≡
for all prime divisors p of φ(n). Now, if d ≠ 1, there exists a prime q which divides d.
In that case, write d = qk for some integer k. But then,
d⋅[m,φ(n)]/q k⋅[m,φ(n)]
g ≡g (mod n)
[m,φ(n)]
and since [m, φ(n)] is divisible by φ(n), we have g ≡ 1 (mod n). Thus,
d⋅[m,φ(n)]/q [m,φ(n)] k
g ≡ (g )
≡ 1 (mod n)
which is in contradiction with equation (21) since q is a prime divisor of φ(n) (why?).
So, we must have d = 1, and the proof is complete.
Assume that some positive integer n has a primitive root. An interesting question
is to find the number of primitive roots which are incongruent modulo n. The next
theorem answers this question.
Theorem 80. For any positive integer n, if there exists a primitive root modulo n, then
there are exactly φ(φ(n)) incongruent primitive roots modulo n.
139
§12. Order, Primitive Roots Masum Billal, Amir Hossein
Note. In case the word incongruent is somewhat unclear to you: two integers a and b
/ b (mod n).
are called incongruent modulo a natural number n if and only if a ≡
Proof. Assume that g is a primitive root modulo n. We aim to find all primitive roots of
n. Since we are looking for incongruent primitive roots modulo n, it suffices to search in
the set Un . Theorem 76 tells us that {g, g , ⋯, g } ≡ Un (mod n) and so we should
2 φ(n)
search for primitive roots in the set {g, g , ⋯, g }. On the other hand, Corollary 25
2 φ(n)
implies tha we should only investigate powers g of g for which (m, φ(n)) = 1. The
m
We are back to the first question: for which integers n do we have a primitive root?
The process of finding such n is long, and we will break it into smaller parts. The first
step is to see if there exist primitive roots modulo primes. We will soon prove that
there always exists a primitive root modulo any prime. We need the following lemma
to prove our claim.
d d 2 d k−1
P (x) = 1 + x + (x ) + ⋯ + (x )
Then,
p−1 d
(22) x − 1 = (x − 1)P (x)
So, this equation has exactly p − 1 = dk solutions. From (22), each of these dk solutions
is either a solution of P (x) ≡ 0 (mod p) or a solution of x − 1 ≡ 0 (mod p). However,
d
Lagrange’s theorem says that P (x) ≡ 0 (mod p) has at most d(k − 1) solutions and
that x − 1 ≡ 0 (mod p) has at most d solutions. Since dk = d(k − 1) + d, this is only
d
possible when x − 1 ≡ 0 (mod p) has exactly d solutions and also P (x) ≡ 0 (mod p)
d
Theorem 81. Let p be a prime. There are exactly φ(p − 1) incongruent primitive roots
modulo p.
Proof. The case p = 2 is obvious. If there exists one primitive root of p, then by
Theorem 80 there are exactly φ(φ(p)) = φ(p − 1) incongruent primitive roots of p.
So we just need to construct a primitive root for p. The trick is to factorize φ(p) =
p − 1 into product of prime powers. Let q be a prime such that q ∣ p − 1 for some
k
integer k ≥ 1. We want to show that there exists some integer a for which ordp (a) = q .
k
k
By previous lemma, the equation x − 1 ≡ 0 (mod p) has exactly q solutions. Take a
q k
k
to be one of these solutions. Then a ≡ 1 (mod p), and so by Theorem 70, it follows
q
that ordp (a) ∣ q . So ordp (a) = q for some integer 0 ≤ j ≤ k. This means that a is
k j
140
§12. Order, Primitive Roots Masum Billal, Amir Hossein
j
a solution to the equation x − 1 ≡ 0 (mod p). If j = k, we have found such an a.
q
j
Otherwise, suppose that j < k. Let i = k − j ≥ 1. Note that if x ≡ 1 (mod p), then,
q
k−1 j k−j−1
q q
x ≡ (x ) (mod p)
j i−1
q
≡ (x ) (mod p)
≡ 1 (mod p)
j k−1
≡ 1 (mod p) is also a solution to x ≡ 1 (mod p).
q q
That is, every solution to x
k−1
≡ 1 (mod p) is exactly
q
According to the preceding lemma, number of solutions of x
k
≡ 1 (mod p) but not
k−1 k k−1 q
q . So there are exactly q − q integers x which satisfy x
k−1
≡ 1 (mod p). If we select a from these solutions, we will have ordp (a) = q .
q k
x
To finish the proof, let
α α α
p − 1 = q1 1 q2 2 ⋯qt t ,
be the prime factorization of p − 1. From what we have just proved, there exists some
α
integer ai for each qi such that ordp (ai ) = qi i . According to Theorem (72), since qi are
relatively prime,
t
degp (∏ ai ) = degp (a1 ) degp (a2 )⋯ degp (at )
i=1
α α α
= q1 1 q2 2 ⋯qt t
=p−1
= φ(p)
t
and so ∏i=1 ai is a primitive root modulo p.
The next step is to find what other numbers have a primitive root. We will show,
by the help of the following lemma, that all powers of an odd prime number have a
primitive root.
Lemma 8. Let p be an odd prime and let g be a primitive root modulo p such that
/ 1 (mod p ). Then,
p−1 2
g ≡
k
φ(p ) k+1
g / 1 (mod p
≡ )
Proof. We will induct on k. The base case k = 1 is immediately followed from the
k
φ(p )
/ 1 (mod p ). As the induction hypothesis, consider that g /
p−1 2
assumption that g ≡ ≡
k
φ(p )
1 (mod p ) for some k ≥ 1. From Euler’s theorem, g ≡ 1 (mod p ), which means
k+1 k
k
φ(p ) k
g = 1 + mp
141
§12. Order, Primitive Roots Masum Billal, Amir Hossein
for some m. The induction hypothesis implies that p ∤ m. By Proposition 41, we know
that
k+1 k+1 k
φ(p )=p −p
k k−1
= p (p − p )
k
= p ⋅ φ(p )
Hence,
k+1
φ(p ) k p
g = (1 + mp )
p k p k 2 p k p−1 k p
= 1 + (1)mp + (2)(mp ) + ⋯ + (p − 1)(mp ) + (mp )
Í ÎÌ Ï
divisible by pk+2
k+1 k+2
≡ 1 + mp (mod p )
k+1 k+2
As m is not divisible by p, mp is not divisible by p . So,
k+1
φ(p ) k+2
g / 1 (mod p
≡ )
as desired.
Theorem 82. Let p be an odd prime and let g be a primitive root modulo p (as we
k
know exists from Theorem 81). Then, either g or g + p is a primitive root modulo p
for any integer k ≥ 1.
This is obviously true for k = 1. Suppose that equation (23) holds for some k ≥ 1.
We will prove that it also holds for k + 1. Let ordpk+1 (g) = m. Then
m k+1
g ≡ 1 (mod p )
m k
⟹ g ≡ 1 (mod p )
impossible to have m = ordpk+1 (g) = φ(p ). So, m = φ(p ) and we are done.
k k+1
142
§12. Order, Primitive Roots Masum Billal, Amir Hossein
Í ÎÌ Ï
divisible by p2
2
Taking modulo p ,
p−1 p−1 p−2
(g + p) ≡g + (p − 1)g p
p−2
≡1−g p
2
/ 1 (mod p )
≡
because p ∤ g. We can now apply the same approach we followed in the first case,
but now with g + p instead of g. So g + p is a primitive root modulo all powers
of p and the proof is complete.
Theorem 83 (Primitive Root Theorem). Let n > 1 be a positive integer. There exists
a primitive root modulo n if and only if n ∈ {2, 4, p , 2p } for some odd prime p and a
k k
positive integer k.
Proof. Obviously, g = 1 and g = 3 are primitive roots modulo 2 and 4, respectively. So,
n = 2 and n = 4 are off the list. Let’s consider the “if” part first. If n has a primitive
k k
root, we will prove n must be of the form p or 2p , where p is an odd prime. First,
k
let us show that 2 does not have a primitive root for k > 2. It is obvious that if a is
k
a primitive root modulo 2 , then a is odd. We leave it as an exercise for the reader to
prove by induction that for any odd a and k > 2,
k−2
k 2
2 ∣a −1
143
§12. Order, Primitive Roots Masum Billal, Amir Hossein
by Corollary (22), we find that d ∣ φ(a) and e ∣ φ(b). Hence, by Theorem (71),
ordab (g) = [d, e]
≤ [φ(a), φ(b)]
φ(a)φ(b)
=
(φ(a), φ(b))
φ(ab)
=
(φ(a), φ(b))
φ(ab)
≤
2
where we have used the fact that (φ(a), φ(b)) is at least 2. This gives us the contra-
k k
diction we were looking for. So, n must be of the form p or 2p .
The only remaining part is to prove that for an odd prime p and k ≥ 1, there exist
k k
primitive roots modulo the numbers p and 2p . According to Theorem 81, p has a
primitive root, say g. It now follows from Theorem 82 that either g or g+p is a primitive
k
root modulo p . Since Euler’s totient function is multiplicative, we have
k k
φ(2p ) = φ(2) ⋅ φ(p )
k
= φ(p )
k
Let g be a primitive root modulo p .
1. If g is odd, then
a k
g ≡ 1 (mod p )
a k
⟺ g ≡ 1 (mod 2p )
144
§12. Order, Primitive Roots Masum Billal, Amir Hossein
Hint. Combine Theorems 83 and 79 along with the fact that if p is an odd prime and
k is a positive integer, then p ∣ a − 1 implies p ∣ a + 1 or p ∣ a − 1.
k 2 k k
Theorem 84. Let g be a primitive root modulo n. Then n−g is a primitive root modulo
n as well if 4 divides φ(n).
Proof. We have a criteria to see if x is a primitive root modulo n. We need to check if
/ 1 (mod n) for any prime p which divides φ(n). Therefore, to check if n − g
φ(n)/p
x ≡
is a primitive root of n, we just need to prove the following holds
φ(n)/p
(n − g) / 1 (mod n)
≡
for any prime divisor p of φ(n). Now, since 4 ∣ φ(n), we have 2 ∣ φ(n)/2. So, φ(n)/p
is even for any proper p. Using the fact that g ≡ (n − g) (mod n), we get
2 2
φ(n) φ(n)
2
(n − g) p
≡ ((n − g) ) 2p
φ(n)
2
≡ (g ) 2p
φ(n)
≡g p
/ 1 (mod n)
≡
we either have
n−1
p (p − 1) ∣ k(p − 1)
145
§12. Order, Primitive Roots Masum Billal, Amir Hossein
which is not a quadratic residue modulo 3. Using the law of quadratic reciprocity and
the fact that p ≡ 1 (mod 4),
3 p (p−1)/2
( p )( ) = (−1) =1
3
Therefore, all quadratic-non residues are primitive roots modulo p, and as we have
shown 3 is among them, we are done.
Solution (2). Just like the previous solution, we will use the fact that 3 is not a
quadratic residue modulo p. Therefore, by Euler’s criterion,
p−1 3
(25) 3 2
≡ ( p ) = −1 (mod p)
m−1
2
(26) ⟹ 3 ≡ −1 (mod p)
146
§12. Order, Primitive Roots Masum Billal, Amir Hossein
Problem 111. Let p and q be prime numbers such that p = 2q + 1. Let a be an integer
2
relatively prime to p and incongruent to −1, 0, and 1 modulo p. Show that −a is
primitive root modulo p.
This, together with Fermat’s little theorem, implies (2l + 1)k ∣ p − 1 = 2q and hence
k = 2. Therefore, a ≡ 1 (mod p) and by Fermat’s little theorem 4 ∣ 2q, which leads to
4
2
a contradiction as q is prime. Hence, −a is a primitive root modulo p.
Problem 112. Let q be a prime such that q ≡ 1 (mod 4) and that p = 2q + 1 is also
prime. Prove that 2 is a primitive root mod p.
• Assume that 2 ≡ −1 (mod p). Let ordp (2) = d. Then, d ∣ φ(p) = p − 1 = 2q.
q
d ∈ {1, 2, q, 2q}
147
§13. Order, Primitive Roots Masum Billal, Amir Hossein
• Assume that 2 ≡ 1 (mod p). Multiply both sides of this equation by 2 to get
q
p ≡ 2q + 1
≡ 3, 5 (mod 8)
Problem 113. Suppose that p is an odd prime number. Prove that there exists a
positive integer x such that x and 4x are both primitive roots modulo p.
Solution. We will prove a stronger claim: there exists some x such that both x and
2
d x are primitive roots mod p for any integer d. Let g be a primitive root modulo p.
2
Since d is a quadratic residue mod p, it follows by Theorem 78 that
2 2k
d ≡g (mod p)
n
for some integer k. We then find by Corollary 25 that any power g of g is a primitive
root modulo p if and only if (n, p − 1) = 1.
Now, it suffices to show there exist two integers a and b such that
b − a = 2k
gcd(b, p − 1) = gcd(a, p − 1)
=1
a
because then x = g would be a solution. This is luckily easy. Let 2, q1 , q2 , . . . , qz be
the prime divisors of p − 1. Suppose that a1 , a2 , . . . , az are integers such that 2k ≡ ai
(mod qi ) for each 1 ≤ i ≤ z. By CRT, there exists an a such that
a ≡ 1 (mod 2)
a ≡ −ai + pi (mod qi )
up some questions.
Problem 115. How do we find the minimum d such that a ≡ 1 (mod n) holds for
d
Let’s proceed slowly. We will develop the theories that can solve these problems.
For doing that, we have to use properties of order and primitive roots we discussed in
previous sections.
Carmichael Function. For a positive integer n, λ(n) is the smallest positive integer
≡ 1 (mod n) holds for any positive integer a relatively prime to n. This
λ(n)
for which a
number λ(n) is called the Carmichael function of n. Sometimes, it is also called the
lambda function of n or the minimum universal exponent (mod m) Sierpiński and
18
Schinzel. Note that Theorem (70) implies the following theorem.
Theorem 85. If a ≡ 1 (mod n) holds for all a relatively prime to n, then λ(n) ∣ d.
d
The following theorem is self-implicating and solves the first problem, if we can
prove that λ(n) exists. For now, let’s assume it does.
Theorem 86. Let n be a positive integer. There exists a positive integer a relatively
prime to n such that ordn (a) = λ(n).
k
Let’s focus on finding λ(n). First, consider the case n = 2 .
149
§13. Carmichael Function, Primitive λ-roots Masum Billal, Amir Hossein
k−2
− 1 = 2 t for some t. Using the identity a − b = (a − b)(a + b),
2 k 2 2
or equivalently, x
we can write
k−1 k−2 k−2
2 2 2
(27) x − 1 = (x − 1)(x + 1)
k k
(28) = 2 t(2 t + 2)
k+1 k−1
(29) =2 t (2 t + 1)
k−1
≡ 1 (mod 2 ), and the induction is complete.
2 k+1
This gives x
k−2
Now, we should prove that 2 indeed is the smallest such integer. Again, by
induction, the base case is to find an x for which ord8 (x) = 2. Obviously, any x =
8j ± 3 satisfies this condition. Assume that for all numbers t from 1 up to k, we have
k−1
λ(2 ) = 2 . Let λ(2 ) = λ. Since we proved that x ≡ 1 (mod 2 ) for all odd
l l−2 k+1 2 k+1
α + 2 < (k − 1) + 2 = k + 1
ordpk (g) = φ(p ) and we immediately have φ(p )∣d. Thus, d = φ(p ). A very similar
k k k
λ(a) = d
λ(b) = e
λ(ab) = h
150
§13. Carmichael Function, Primitive λ-roots Masum Billal, Amir Hossein
Then
d
x ≡ 1 (mod a)
e
x ≡ 1 (mod b)
h
x ≡ 1 (mod ab)
This means that [d, e] = h since [d, e] is the smallest positive integer that is divisible
by both d and e.
The next theorem combines the above results and finds λ(n) for all n.
e e e
Theorem 91. Let n be a positive integer with prime factorization n = p11 p22 ⋯prr .
Also, let p be a prime and k be a positive integer. Then
⎧
⎪ φ(n) if n ∈ {2, 4, p , 2p }
k k
⎪
⎪
⎪
λ(n) = ⎪
φ(n)
⎨
⎪
k
if n = 2 with k > 2
⎪
⎪ 2
⎪
⎪ e1
1 ), ⋯, λ(pr ))
er
⎩ lcm(λ(p otherwise
The proof is left as an exercise for the reader. We are now ready to fully solve
Problem 114.
Theorem 93. For fixed positive integers n and d, there exists a positive integer a
relatively prime to n so that ordn (a) = d if and only if d ∣ λ(n).
Proof. The “if” part is true by Theorem 70. For the “only if” part, assume that g is
an integer with ordn (g) = λ(n) and λ(n) = de. Then ordn (g ) = d, as desired.
e
We finish this section by proposing a theorem. We will leave the proof for the reader
as an exercise.
Recall that n is square-free if it is not divisible by any perfect square other than 1.
151
§13. Carmichael Function, Primitive λ-roots Masum Billal, Amir Hossein
Carmichael calls a usual primitive root a φ-primitive root, and they are, in fact, a
special case of λ-primitive roots. Now, the existence of a primitive root is generalized
to the following theorem from Carmichael’s original paper.
Theorem 95 (Carmicahel’s primitive root theorem). For any positive integer n, the
congruence equation
λ(n)
x ≡ 1 (mod n)
has a solution a which is a primitive λ-root, and for any such a, there are φ(λ(n))
primitive roots congruent to powers of a.
We can show that this theorem is true in a similar fashion to what we did in last
section, and we leave it as an exercise.
As we mentioned earlier in Proposition 41, φ(n) is always even for n > 2. As it
turns out, λ and φ share some common properties.
Problem 117. If λ(n) > 2, the number of primitive λ-roots modulo n is even.
The next theorem generalizes 108, which itself was a generalization to Wilson’s
theorem.
Theorem 96. Let n be a positive integer such that λ(n) > 2. Also, suppose that g is
a primitive λ-root modulo n. The product of primitive λ-roots of n is congruent to 1
modulo n.
19
Carmichael, “Note on a new number theory function” cit., Page 232 − 233, Result II.
20
Peter J. Cameron and D. A. Preece
2014 “Primitive Lambda-Roots” (Jan. 2014), https://cameroncounts.files.wordpress.com/2014/
01/plr1.pdf.
152
§14. Pseudoprimes Masum Billal, Amir Hossein
Proof. Since λ(n) > 2, we can easily argue that it must be even. If g is a primitive
λ-root modulo n, all the primitive λ-roots are
e e e
{g 1 , g 2 , ⋯, g k }
where ei (for 1 ≤ i ≤ k) are all (distinct) positive integers with (ei , λ(n)) = 1. Also,
e
note that we can pair them up since λ(n) is even if n > 2. In fact, we can pair g i with
λ(n)−ei
g for all i. Then,
e e ek λ(n) λ(n)
g 1 ⋅ g 2 ⋯g ≡g ⋯g
≡ 1 (mod n)
Corollary 27. For any n, there are φ(λ(n)) primitive λ-roots modulo n.
§14 Pseudoprimes
153
§14. Pseudoprimes Masum Billal, Amir Hossein
and
340 10 34
2 ≡ (2 )
34
≡ (1024)
34
≡ (1)
≡ 1 (mod 11)
≡ 1 (mod 341).
340
which yields 2
Theorem 97. For any integer a > 1, there are infinitely many Fermat pseudoprime to
base a.
Proof. Let p ≥ 3 be any prime number such that p ∤ a − 1. We show that
2
2p
a −1
n=
a2 − 1
is a Fermat pseudoprime to base a. First, n is composite because
p p
a −1 a +1
n= ⋅
a−1 a+1
≡ a (mod p) and therefore p ∣ a − a . Since p does
2p 2 2p 2
By Fermat’s little theorem, a
2
not divide a − 1, it divides
2p 2
a −a
n−1=
a2 − 1
2p−2 2p−4 4 2
=a +a +⋯+a +a
which is an even integer. We can now deduce that 2p ∣ n − 1 because p is odd. Now,
a − 1 = n (a − 1) which means a ≡ 1 (mod n). Thus a ≡ 1 (mod n) and n is a
2p 2 2p n−1
154
§14. Pseudoprimes Masum Billal, Amir Hossein
ii. n is squarefree.
Now we will prove the third one. To prove this, we will use a classical technique.
Let p be a prime divisor of n. Since a ≡ a (mod n), we can say a ≡ a (mod p) for
n n
− 1), thus p ∣ a
n n−1 n−1
all a. Choose a so that a⊥p. Then p divides a − a = a(a − 1.
Also from Fermat’s little theorem, p ∣ a − 1.
p−1
Here is the crucial part. From Theorem 81, we know that there is a primitive root
for all primes p, i.e., there is a positive integer g with ordp (g) = p − 1. For that g,
n−1
g ≡ 1 (mod p)
p−1
g ≡ 1 (mod p)
where ( na ) is the Jacobi symbol, then n is called an Euler pseudoprime to base a and
denoted by epsp(a).
Corollary 28. Let a > 1 be an odd integer. Then every Euler pseudoprime to base a
is also a Fermat pseudoprime to base a.
There are infinitely many epsp(a) for any integer a > 1. Actually, even more is
true: there exist infinitely many Euler pseudoprimes to base a which are product of k
distinct primes and are congruent to 1 modulo d, where k, d ≥ 2 are arbitrary integers.
You may wonder if there exist absolute Euler pseudoprimes, numbers which are Euler
pseudoprimes to every base relatively prime to themselves. The answer is negative. In
fact, it can be shown that an odd composite integer n can be Euler pseudoprime for at
most 12 φ(n) bases a, where 1 < a < n and (a, n) = 1. The proof needs some algebraic
background and we do not include it in this book.
155
§15. Using Congruence in Diophantine Equations Masum Billal, Amir Hossein
3 3 2
( )=( ) =1
121 11
for some integer 0 ≤ r < s. Then n is called a strong pseudoprime to base a and is
denoted by spsp(a). It can be proved that every spsp(a) is also a epsp(a) (and hence
a psp(a)). There exist infinitely many strong pseudoprimes to base a for every integer
a ≥ 1. We show a special case of this where a = 2 in the following proposition.
Proposition 46. There are infinitely many strong pseudoprimes to base 2.
≡ 1 (mod n) and so 2 −1 =
n−1 n−1
Proof. If n is a Fermat pseudoprime to base 2, then 2
n
nk for some integer k. Choose m = 2 −1. We will show that m is a strong pseudoprime
to base 2. To proceed, notice that m − 1 = 2 − 2 = 2 (2
n n−1 n−1
− 1) and 2 − 1 is an odd
n−1
≡ 1 (mod m). Now,
2 −1
integer. So it suffices to show that 2
n−1
2 −1 nk
2 =2
n k
= (2 )
k
≡ 1 ≡ 1 (mod m)
Diophantine equations are an especial kind of equations which allow solutions only in
integers. They have been studied for a really long time. The name is taken after the
156
§15. Using Congruence in Diophantine Equations Masum Billal, Amir Hossein
Since there does not exist many squares below 123, you may try to do it by hand.
And after exhausting all possible cases, you must conclude there are no such integers.
2 2
But if you are clever, you don’t have to go through trial and error. Let’s write a + b =
123 and notice the following. Exactly one of a or b must be odd since 123 is odd.
Without loss of generality, assume a is even (you can take b if you want). Then b
is odd, and we know b ≡ 1 (mod 4). Thus, a + b ≡ 1 (mod 4), whereas 123 ≡ 3
2 2 2
(mod 4). This is a straight contradiction implying there are no such positive integers
a and b. The idea seems simple enough, yet powerful to be of great use.
For reaching such a contradiction (it is often the case, Diophantine equations usually
do not have any solutions), we use some common facts. The main idea is the same:
find a proper n so that the two sides of the equation leave different remainders modulo
n.
You might ask what happens if the equation actually does have a solution in integers?
Let us explain this with an example. Suppose that you are given the simple linear
Diophantine equation 6x + 5y = 82 and you want to solve it over non-negative integers.
Let’s solve this problem by trial and error. First, notice that x ≤ 13 (otherwise 6x
would exceed 82). We can draw a table to find the solutions.
x 0 1 2 3 4 5 6
y none none 14 none none none none
x 7 8 9 10 11 12 13
y 8 none none none none 2 none
Now, consider the same linear equation 6x + 5y = 82 again. We are going to solve
it using modular arithmetic this time. Take modulo 5 from both sides of the equation.
The left side would be x while the right side is 2, giving us the relation x ≡ 2 (mod 5).
Although this does not give us the solution directly, it helps us find the solutions much
157
§15. Using Congruence in Diophantine Equations Masum Billal, Amir Hossein
faster. Just notice that we already know x must be less than or equal to 13, and it must
have a remainder of 2 when divided by 5. The only choices for x then are 2, 7, and 12.
We can now plug these values of x into the equation and find the solutions with only
three calculations (instead of thirteen).
Sometimes we need to use some theorems such as Fermat’s little theorem or Wilson’s
theorem and pair them up with some modular arithmetic. Here are some highly useful
congruences:
Most of congruences above can be proved easily. Some are direct consequence of
Fermat’s or Euler’s theorem. Or you can just consider the complete set of residue of
the modulus and then investigate their powers. Whatever the case, we will leave the
proofs as exercises. Sometimes you may notice that Fermat’s little theorem or Euler’s
theorem is disguised in the equation.
Problem 118. The sum of two squares is divisible by 3. Prove that both of them are
divisible by 3.
2 2
Solution. Assume that a + b is divisible by 3. If a is divisible by 3, so must be b. So,
take a not divisible by 3. Then, from the properties above, we have a ≡ 1 (mod 3) and
2
(mod 3).
2 2
Remark . We could just use Theorem 54 which shows that every prime factor of a + b
is of the form 4k + 1 if a and b are coprime.
2 2
Problem 119. Show that there are no integers a, b, c for which a + b − 8c = 6.
Solution. The term −8c guides us to choose the right modulo. Consider the equation
modulo 8. We have a + b ≡ 6 (mod 8). By Theorem 99, a ≡ 0, 1, or 4 (mod 8). Now
2 2 2
you may check the possible combinations to see that a + b ≡ 6 (mod 8) is impossible.
2 2
4 2 y
Problem 120. Solve the Diophantine equation x − 6x + 1 = 7 ⋅ 2 in integers.
158
§15. Using Congruence in Diophantine Equations Masum Billal, Amir Hossein
Solution. There are no solutions for y < 0. So assume y ≥ 0. Add 8 to both sides of
the equation to get
2 2 y
(x − 3) = 7 ⋅ 2 + 8
Note that if y ≥ 3, the right hand side of above equation is divisible by 8. So taking
modulo 8 may seem reasonable. However, it leads to (x − 3) ≡ 0 (mod 8) and no
2 2
further results are included. We should look for another modulo. If y ≥ 4, then the
right hand side is congruent to 8 modulo 16. However, the left hand side, (x − 3) is
2 2
a square and so it’s 0, 1, 4, or 9 modulo 16. The only left cases are y = 0, 1, 2, and 3
which imply no solutions. Hence, no solutions at all.
Let’s see another problem in which we will also see an application of Fermat’s method
of infinite descent. This is a technique for solving Diophantine equations but we briefly
use the idea here.
Problem 121. Find all integer solutions to the equation
2 2 2 2
x + y = 7(z + t )
Solution. First of all, using the same approach as in previous problem, we can prove
that 7 divides both x and y. Let x = 7a and y = 7b and substitute them in the equation.
After dividing by 7,
2 2 2 2
z + t = 7(a + b )
Note that this equation looks like the original one. However, z and t in the latter
equation are strictly smaller than x and y in the original equation. We can continue
this process by noting the fact that z and t are divisible by 7. So, assume that z = 7u
and t = 7v and rewrite the equation as
2 2 2 2
u + v = 7(a + b )
This process can be done infinitely many times. Thus, we get that x and y are divisible
i
by 7 for all positive integers i, which is not possible. So, the equation does not have
any solutions. The process of finding new equations similar to the original one is called
the method of infinite descent.
Problem 122. Show that the following equation does not have any solutions in positive
integers:
n m
5 − 7 = 1374
Solution. The most important thing in solving a Diophantine equation is to take the
right modulo. In this case, it’s obvious that the easiest mods to take are 5 and 7. Let’s
take modulo 5 from both sides of the equation. Since 7 ≡ 2 (mod 5),
m m
m
−2 ≡ −1 (mod 5)
m
⟹ 2 ≡ 1 (mod 5)
159
§15. Using Congruence in Diophantine Equations Masum Billal, Amir Hossein
k 4
Since ord5 (2) = 4, we have 4 ∣ m. Let m = 4k for some integer k. So 7 = 7 = (7 ) .
m 4k
2 4 m
This reminds us of the fact that x (and thus x ) is either 0 or 1 modulo 4. So, 7 ≡ 1
(mod 4). Taking modulo 4 from the original equation, we get
n 4k
5 − 7 ≡ 2 (mod 4)
⟹ 1 − 1 ≡ 2 (mod 4)
Solution. You can usually use modular arithmetic to solve the problem when there
is a factorial term in the given equation. The interesting property of n! is that it is
divisible by all integers less than or equal to n. In this problem, if we find the right
modulo k, we can assume n ≥ k and take modulo k from the equation (we will check
≡ m (mod k). As said before, we guess
2014 4
the cases when n < k later). It will be 10
the equation does not have any solutions. So, we are searching for a modulo k for
4 2014
which m cannot be congruent to 10 . We should first try the simplest values for
4 4
k, i.e., values of k for which m can have a few values. For k = 16, we have m ≡ 0
(mod 16), no contradiction. For k = 17, we have m ≡ 8 (mod 17), which is impossible
4
4
because m can only have the values 0, ±1, or ±4 modulo 17. We have found our desired
contradiction, and we just have to check the values of n < 17. This is easy. Obviously,
2014 2014 2014
n! + 10 is bigger than 10 . However, the smallest perfect square bigger than 10
is
1007 2 2014 1007
(10 + 1) = 10 + 2 ⋅ 10 +1
2014
which is way bigger than 10 + 16!. So, no solutions in this case as well.
2 3
Problem 124. Prove that the equation x + 5 = y has no integer solutions.
2 3
Solution. Taking modulo 4, since x + 5 is congruent to either 1 or 2 modulo 5, but y
is never congruent to 2 modulo 4, we have x + 5 ≡ y ≡ 1 (mod 4), and so x is even,
2 3
Note that since y ≡ 1 (mod 4), we have y + y + 1 ≡ 3 (mod 4). According to theorem
2
(21), we know that every number congruent to 3 modulo 4 has a prime divisor also
congruent to 3 modulo 4. Let p ≡ 3 (mod 4) be that prime divisor of y + y + 1. Then
2
2
x + 4 ≡ 0 (mod p)
160
§15. Using Congruence in Diophantine Equations Masum Billal, Amir Hossein
This is the contradiction we were looking for and the equation does not have integer
solutions.
Problem 125 (Romania JBMO TST 2015). Solve in nonnegative integers the equation
x y 2
21 + 4 = z
y = 1 gives the solution (x, y, z) = (1, 1, 5). Assume y ≥ 2. Take modulo 8 from
is divisible by 8 and so 7 − 3 ≡ 0 (mod 8). But this does
y+1 x x
equation (32). 2
not happen for any x (just consider two cases when x is even or odd). So the only
solution in this case is (x, y, z) = (1, 1, 5).
y y
Note that we have used the fact that z + 2 > z − 2 to omit some cases (like when
z − 2 = 21 and z + 2 = 1). So, (x, y, z) = (1, 1, 5) is the only solution to the given
y x y
equation.
161
§16. Exercises Masum Billal, Amir Hossein
§16 Exercises
{a1 , a1 a2 , a1 a2 a3 , ⋯, a1 a2 ⋯an }
Problem 131. Let f (x) = 5x + 13x + 9ax. Find the least positive integer a such
13 5
162
§16. Exercises Masum Billal, Amir Hossein
Problem 135 (ELMO 2000). Let a be a positive integer and let p be a prime. Prove
that there exists an integer m such that
m
m
m ≡ a (mod p)
Problem 136. Find all pairs of prime numbers (p, q) for which
2 3 3
7pq + p = q + 43p + 1
Problem 137 (IMO 1996). The positive integers a and b are such that the numbers
15a + 16b and 16a − 15b are both squares of positive integers. What is the least possible
value that can be taken on by the smaller of these two squares?
Problem 138. 2017 prime numbers p1 , . . . , p2017 are given. Prove that
pj p
∏(pi − pj i )
i<j
is divisible by 5777.
Problem 139 (Ukraine 2014). Find all pairs of prime numbers (p, q) that satisfy the
equation
q p−1
3p − 2q = 19
th
Problem 140. Let p be an odd prime and let ω be the p root of unity (that is, ω is
p
some complex number such that ω = 1). Let
i
X = ∑ω
j
Y = ∑ω
where i in the first sum runs through quadratic residues and j in the second sum runs
over quadratic non-residues modulo p and 0 < i, j < p. Prove that XY is an integer.
Problem 141. Let p > 2 be a prime number. Prove that in the set
√
1, 2, ⋯, ⌊ p⌋ + 1
Problem 142 (APMO 2014). Find all positive integers n such that for any integer k
3
there exists an integer a for which a + a − k is divisible by n.
Problem 143. Let b, n > 1 be integers. Suppose that for each k > 1 there exists an
n n
integer ak such that b − ak is divisible by k. Prove that b = A for some integer A.
Problem 145. Let m and n be integers greater than 1 with n odd. Suppose that n is a
quadratic residue modulo p for any sufficiently large prime number p ≡ −1 (mod 2 ).
m
163
§16. Exercises Masum Billal, Amir Hossein
Problem 146. Form the infinite graph A by taking the set of primes p congruent to 1
(mod 4), and connecting p and q if they are quadratic residues modulo each other. Do
the same for a graph B with the primes 1 (mod 8). Show A and B are isomorphic to
each other.
Problem 147. Find all positive integers n that are quadratic residues modulo all
primes greater than n.
Problem 149. Let n and k be given positive integers. Then prove that
• there are infinitely many prime numbers p such that ±1, ±2, ±3, . . . , ±n are quadratic
residue of p, and
th
• there infinitely many prime numbers p > n such that ±i/j are k -power residue
of p, where i and j are integers between 1 and n (inclusive).
A = {b1 , b2 , ⋯, b p−1 }
2
be the set of all quadratic residues modulo p, excluding zero. Prove that there doesn’t
exist positive integers a and c satisfying (ac, p) = 1 such that set
Problem 152. Find all primes p such that 5, 7, and −7 are quadratic residues modulo
p.
Problem 153. Prove that there are no positive integers k such that for the first k odd
prime numbers p1 , p2 , ⋯, pk , there are a, n ∈ Z (n > 1) satisfying
+
n
p1 p2 ⋯pk = a + 1
Problem 154. Find all the pairs of positive integers (x, p) such that p is a prime,
is a divisor of (p − 1) + 1.
p−1 x
x ≤ 2p, and x
n 2
Problem 155. Determine all positive integers n such that 3 + 1 is divisible by n .
164
§16. Exercises Masum Billal, Amir Hossein
Problem 156. Find a condition for a ∈ N such that there are infinitely many natural x
such that a ≡ a (mod p) implies a ≡ −a (mod p), where p is any positive integer.
2x 2a x a
n
Problem 157. Show that n does not divide 2 − 1 for n > 1.
Problem 158 (China 2006). Find all positive integer pairs (a, n) such that
(a + 1) − a
n n
n
is an integer.
Problem 160 (China 2009). Find all the pairs of prime numbers (p, q) such that
p q
pq ∣ 5 + 5
Problem 161. Prove that any two different Fermat numbers are relatively prime with
each other.
n
th 2
Note. The n Fermat number is Fn = 2 + 1.
Problem 162. Prove that for all positive integers n, gcd(n, Fn ) = 1, where Fn is the
th
n Fermat number.
Problem 163. Let a and b be relatively prime integers and let d be an odd prime that
k k
2 2 k+1
divides a + b . Prove that d − 1 is divisible by 2 .
p
Problem 164. Prove that if p is a prime, then p − 1 has a prime factor greater than
p.
Problem 165.
2 2
2
j
(∑ a ) ≡ −3 (mod p)
j=0
3 2
2
j
(∑ a ) ≡ 8a (mod p)
j=0
165
§16. Exercises Masum Billal, Amir Hossein
Problem 166 (Poland 2016). Let k and n be odd positive integers greater than 1.
Prove that if there a exists positive integer a such that k ∣ 2 + 1 and n ∣ 2 − 1, then
a a
Problem 167. Let n > 9 be a positive integer such that gcd(n, 2014) = 1. Show that
if n ∣ 2 + 1, then 27 ∣ n.
n
Problem 169. Prove that there do not exist non-negative integers a, b, and c such that
c
a b 2
(2 − 1)(2 − 1) = 2 + 1
Problem 170. Find all triples (x, y, z) of positive integers which satisfy the equation
x y
2 + 1 = z(2 − 1)
2 2
Problem 171. Let p be a prime number of the form 3k + 2 that divides a + ab + b
for two positive integers a and b. Prove that p divides both a and b.
Problem 173. If p is a prime, show that the product of the primitive roots of p is
congruent to to (−1)
φ(p−1)
modulo p.
Problem 174. Let g be a primitive root modulo a prime p. Find ordpr (g).
Problem 175. Prove that if r is a primitive root modulo m, then so is the multiplicative
inverse of r modulo m.
Problem 176. Prove that 3 is a primitive root modulo p for any prime p of the form
n
2 + 1.
Problem 178. Find all Fermat primes Fn such that 7 is a primitive root modulo Fn .
m
2
Problem 179. Prove that if Fm = 2 + 1 is a prime with m ≥ 1, then 3 is a primitive
root of Fm .
166
§16. Exercises Masum Billal, Amir Hossein
Problem 180. For a given prime p > 2 and a positive integer k, let
k k k
Sk = 1 + 2 + ⋯ + (p − 1)
Problem 187 (APMO 2006). Let p ≥ 5 be a prime and let r be the number of ways
of placing p checkers on a p × p checkerboard so that not all checkers are in the same
5
row (but they may all be in the same column). Show that r is divisible by p . Here,
we assume that all the checkers are identical.
Problem 188 (Putnam 1996). Let p be a prime greater than 3. Prove that
2p
⌊ 3
⌋
2 p
p ∣ ∑ (i)
i=1
Problem 189. Let a and b be two positive integers satisfying 0 < b ≤ a. Let p be any
prime number. Show that
pa a 3
( ) ≡ ( b ) (mod p )
pb
(4n + 2).n
3
3n + 1
an+1 = an +
(n + 1) 4
(n + 1)4
for n ≥ 1. Prove that there are infinitely many positive integers n such that an is an
integer.
167
§16. Exercises Masum Billal, Amir Hossein
Hint. Find an explicit formula for an and then try Wolstenholme’s theorem.
Problem 191. Let p be an odd prime. Define
1 1
Hn = 1 + + ... + n
2
th
to be the n harmonic number for any positive integer n. Prove that p divides the
numerator of both Hp(p−1) and Hp2 −1 .
3p−5
Problem 192. Let p be an odd prime number. Define q = 2
and
1 1 1
Sq = + +⋯+
2⋅3⋅4 5⋅6⋅7 q(q + 1)(q + 2)
If we write p1 −2Sq as an irreducible fraction, prove that p divides the difference between
numerator and denominator of this fraction.
Problem 193. Find the largest power of a prime p which divides
n+1 n
p p
Sp = ( n ) − ( n−1 )
p p
n
Problem 196. Prove that (2k−1
−k
) is even for all positive integers n and k such that
n−1
2≤k≤2 .
Problem 197. How many of the following numbers are divisible by 3?
Problem 198. Find all pairs (p, q) prime numbers such that
3 3
7p − q = 64
Problem 199 (BMO 2009). Solve the equation
x y 2
3 −5 =z
in positive integers.
168
§16. Exercises Masum Billal, Amir Hossein
x y
Problem 200. Solve the equation 7 = 3 + 4 in integers.
x y
Problem 201. Solve the equation 2 + 3 = 11 in positive integers.
in positive integers.
Problem 203 (Putnam 2001). Prove that there are unique positive integers a and n
such that
n+1 n
a − (a + 1) = 2001
169
CHAPTER III.
ARITHMETIC FUNCTIONS
§1 Definitions
Remark . The original definition of arithmetic functions states that the output of an
arithmetic function can be any complex number. For example, consider the function
f ∶ N → C with
e −n
ne
f (n) = n
e + n + 1 + ln n
With the above definition, f (n) is an arithmetic function even though it does not
represent any specific property of n. In this chapter, we want to study functions that
present some number theoric properties. One example of such a function would be
φ(n). As you already know, the Euler’s totient function takes a positive integer n as
its input and gives the number of positive integers less than n and relatively prime to
n as its output.
§1. Definitions Masum Billal, Amir Hossein
ε(n)
n
1 2 3 4 5
1
ε(n) = ⌊ n ⌋
1 if n = 1
={
0 if n > 1
Note. Here, we call ε(n) the unit function because it acts like 1 when multiplying
arithmetic functions. That is, ε is the multiplicative identity of arithmetic functions.
In section §3, we will discuss the process of finding the result of multiplication of
two arithmetic functions (called the Dirichlet product) and explain why ε(n) has this
property.
Identity Function. The identity function, id, maps every positive integer to itself
so id(n) = n for all positive integers n.
172
§1. Definitions Masum Billal, Amir Hossein
id(n)
n
1 2 3 4 5
f (n)
n
1 2 3 4 5
173
§2. Common Arithmetic Functions Masum Billal, Amir Hossein
for all m, n ∈ N such that m ⊥ n. In the case where equation 2 is true for all m, n ∈ N,
f is called a completely multiplicative function.
Example. The identity function and the constant 1 function g(n) = 1 are completely
multiplicative because for any two positive integers m and n,
id(mn) = mn
=m⋅n
= id(m)id(n)
g(mn) = 1
=1⋅1
= g(m)g(n)
τ (n) = ∑ 1
d∣n
What if the number is so huge that we can not compute all the divisors by hand? Or
1
what if we need to tell a computer how to compute the number of divisors in general?
1
Well, you can use a brute force method if you are familiar with programming. But certainly
iterating through integers from 1 to n or a solution of that complexity is not a good idea.
174
§2. Common Arithmetic Functions Masum Billal, Amir Hossein
If you need more motivation to find a way to compute number of divisors easily, consider
the following nice problem!
Problem 204 (Bangladesh National Mathematical Olympiad, 2010). You have a reg-
ular 2016-gon. You have to choose some points from that polygon so that the resulting
polygon you get from those points is a regular polygon. How many distinct regular
polygons can you construct this way? Order of vertex is not important. And the poly-
gon will be constructed joining a point with the next one in an order that does not
result in a self intersecting polygon or a polygon which has an angle larger than 180
(convex simple polygon in other words).
Solution. First, try to make sense of what this problem is asking. This is one of those
problems that make you think in a nice way while also teaching that theorems are not
everything to solve problems. A very important point to keep in mind here is that, the
order in which we pick the points does not matter.
The next step should be finding out how we should pick those points if we want to
make a regular polygon and how many points are necessary to make such a polygon.
Let us label the points of the 2016-gon as P1 , P2 , . . . , P2016 . So, the regular polygon
would be P1 P2 . . . P2016 . Here, P1 is connected to P2 , P2 to P3 , and so on. However,
P2016 would be connected to P1 to complete the cycle of the polygon.
An important observation: we can always let P1 be the first vertex of the regular
polygon we want to construct. Because no matter where we start from, if we rotate, it
would be identical to the one that can be created starting from P1 . So, P1 is the first
vertex of our regular polygon. Also, we fix the number of points in the new regular
polygon we want to create. If it has k points, all k sides must be equal.
Assume that we want to construct a regular quadrilateral P1 Pi Pj Pk . What can we
say about i, j or k? The length P1 Pi must be equal to Pi Pj , and Pj Pk . This implies
that j must be i + i. Because if j < i then Pi Pj would be less than P1 Pi (if you are
confused about it, just rotate Pi Pj back to P1 Pi ). Then we also must have k = 3i. This
in turn implies that if there are m points we must have 2016 = mq for some integer q.
That is, m must be a divisor of 2016. Therefore, the number of distinct polygons is
the number of distinct divisors of 2016. But we must consider divisors greater than 2
only. Because we can not create a polygon with one or two points. We have found the
solution, but it would be a lot nicer if we actually knew the value of that.
We will see how to compute number of divisors for a positive integer n. Take n = 12.
If d is a divisor of n, then it is evident that d can not have any prime factor that is not
in n. But the opposite might be true. n might have some prime factor that is not in d.
In this case, a divisor of 12 must have prime factor of 2 and 3 only. Second observation
2 1
is: we have n = 2 ⋅ 3 . Thus, d can not have the exponent of 2 greater than 2 or the
a b
exponent of 3 greater than 1. If d = 2 3 then a ≤ 2 and b ≤ 1. The most interesting part
is that, we can actually generate all the divisors this way. Set a = 0, 1, 2 and b = 0, 1.
Consider the sets A = {2 , 2 , 2 } and B = {3 , 3 }. If we multiply an element of A with
0 1 2 0 1
an element of B, we get a divisor of 12. And for each multiplication, we get a distinct
divisor each time. And certainly, this can be generalized. If the prime factorization
e e e
of n is p11 p22 ⋯pkk , then the divisors can be generated multiplying elements from sets
e e e
A1 = {p1 , . . . , p11 }, A2 = {p2 , . . . , p22 }, Ak = {pk , . . . , pkk }. Ai has ei +1 elements because
0 0 0
175
§2. Common Arithmetic Functions Masum Billal, Amir Hossein
the exponent ranges from 0 to e1 . Then clearly, the number of divisors of n would be
the product of number of elements in all Ai , that is, (e1 + 1)⋯(ek + 1). However, we
will have to prove something even though it is clear from the example. That is, we
will not get a duplicate divisor in this process. This will be left as an exercise for the
readers.
e e e
Theorem 100. Let n be a positive integer with prime factorization n = p11 p22 ⋯pkk .
Then,
k
(3) τ (n) = ∏(1 + ei )
i=1
176
§2. Common Arithmetic Functions Masum Billal, Amir Hossein
σ(n) = ∑ d
d∣n
Note. One might rephrase this definition as: the sum-of-divisors is the summatory
function of id.
Example.
σ(n) 1
n =∑d
d∣n
Proof. Beginning from σ(n) = ∑ d, you can simply realize that the equation can be
d∣n
written in the form
n
σ(n) = ∑
d
d∣n
because when for every divisor d of n, the number n/d also divides n. We can now take
n out of the sum in the right side of above equation and finish the proof.
Note. The idea of employing n/d instead of d, where d is a divisor of n, is a good trick
for solving such problems.
As for the case of τ (n), one can express σ(n) explicitly as well.
e e e
Theorem 104. Let n be a positive integer with prime factorization n = p11 p22 ⋯pkk .
Then,
k e +1
p i −1
σ(n) = ∏ i
p−1
i=1
2
Read “sigma of n”.
177
§2. Common Arithmetic Functions Masum Billal, Amir Hossein
Proof. Later in proposition 50, we will show that σ is multiplicative. Just accept it for
now. So, it suffices to prove the assertion for the case when n is a power of a prime. Let
α
n = p , where p is a prime and α is a positive integer. In this case, the only divisors of
2 α
n are 1, p, p , ⋯, p . Therefore, their sum, σ(n), is
α 2 α
σ(p ) = 1 + p + p + ⋯ + p
Example. The smallest pair of amicable numbers is (220, 284). One can easily check
this:
220 = 1 + 2 + 4 + 71 + 142
284 = 1 + 2 + 4 + 5 + 10 + 11 + 20 + 22 + 4 + 55 + 110
Amicable numbers have been studied since a very long time ago, and there is evi-
dence that they were known to Pythagoreans (followers of Pythagoras) which originated
4
in the sixth century BC. According to Dickson Thābit ibn Qurra (826–901) found a
formula that generates amicable numbers (which we will state in the following). The
Iranian mathematician Muhammad Baqir Yazdi, who lived in 16th century, found the
pair (9363584, 9437056) of amicable numbers. You can imagine how difficult it is to
find such numbers without using computers. Over a billion pairs of amicable numbers
have been found so far (July 2018).
3
Amicable: having a spirit of friendliness.
4
Leonard E. Dickson
1952 History of the theory of numbers, Chelsea Pub. Co., Chapter I, Page 39.
178
§2. Common Arithmetic Functions Masum Billal, Amir Hossein
Theorem 105 (Thābit ibn Qurra’s Rule). Let n ≥ 2 be a positive integer such that
n−1
p=3⋅2 −1
n
q =3⋅2 −1
2n−1
r =9⋅2 −1
n n
Proof. Let a = 2 ⋅ p ⋅ q and b = 2 ⋅ r. Since p, q, and r are all odd primes, the
α β γ
divisors of a are of the form 2 ⋅ p ⋅ q , where α, β, γ are integers with 0 ≤ α ≤ n
and β, γ ∈ {0, 1}. Similarly, the divisors of b are of the form 2 ⋅ r , where δ and ϵ are
δ ϵ
and so,
2n−1 n+1 n n−1 n
σ(a) − a = 9 ⋅ 2 (2 − 1) − 2 (3 ⋅ 2 − 1)(3 ⋅ 2 − 1)
n 2n−1
= 2 (9 ⋅ 2 − 1) = b
We expect the reader to be able to prove σ(b) − b = a in a similar way on their own.
This shows that (a, b) is a pair of amicable numbers.
The above theorem is pretty interesting, but you might wonder if it gives us all the
amicable numbers. The answer is negative. You can compute the values of p, q, r, and
a, b to see how large they get even when n is as small as 10. For the above theorem
to work, we require p, q, r to be primes, and determining whether those numbers are
prime is a difficult task for large n.
179
§2. Common Arithmetic Functions Masum Billal, Amir Hossein
5
The mighty Euler (see Dickson ) found a more general formula for amicable num-
bers and discovered 61 pairs of amicable numbers at his time. We state Euler’s gen-
eralization of Thābit ibn Qurra’s rule below, usually called Euler’s rule, and leave the
proof to the interested reader.
Theorem 106 (Euler’s Rule). Let m and n be positive integers with m < n such that
m n−m
p = 2 ⋅ (2 + 1) − 1
n n−m
q = 2 ⋅ (2 + 1) − 1
n+m n−m 2
r=2 ⋅ (2 + 1) − 1
In order to find φ(n), we will first find the number of positive integers less than or equal
to n which are not co-prime to n. Then, φ(n) would be the difference of this number
and n. Let us consider the simple case n = pq, where p and q are primes. A positive
integer less than or equal to n is not co-prime to n if it is divisible by either p or q.
Let ψ(n) be the number of such positive integers. There are n/p and n/q numbers less
than or equal to n which are divisible by p and q, respectively. So, we might guess that
ψ(n) = n/p + n/q. However, notice that we are counting the number pq in both the
numbers divisible by p and divisible by q. So, the true value for ψ(n) is n/p + n/q − 1.
Thus,
φ(n) = n − k(n)
= n − n/p − n/q + 1
= pq − q − p + 1
= (p − 1)(q − 1)
5
Ibid., Chapter I, Page 42.
180
§2. Common Arithmetic Functions Masum Billal, Amir Hossein
But this is still not true. For instance, the number p1 p2 p3 is counted in the first sum
and we remove it by subtracting the second sum. So, we would have to add another
sum
n
∑ ppp
i j t
1≤i<j<t≤k
6
to include all products such as p1 p2 p3 . This process of adding and subtracting sums
is called the inclusion–exclusion principle. We will continue the process until we count
every number less than or equal to n which is not co-prime to n exactly once. Then,
the totient function may be calculated from φ(n) = n − ψ(n). The reader is encouraged
to calculate φ(n) = (p1 − 1)(p2 − 1)⋯(pk − 1) using the given approach and check that
it is compatible with the formula 4. The very same approach may be applied to the
α α α
general case n = p1 1 p2 2 ⋯pk k to finally prove formula 4. We strongly recommend the
2 3 4 5
reader try this method for several examples (e.g., n = p q or n = p q r ) and then prove
the whole thing.
Using the same method, we can prove a stronger result.
Theorem 107 (Generalization of φ). Let m and n be positive integers and let n =
α α α
p1 1 p2 2 ⋯pk k be the prime factorization of n. The number of positive integers less than
or equal to m which are co-prime to n is m − Ψ(m), where
m m m
Ψ(m) = ∑ ⌊ p ⌋ − ⌊ p p ⌋ + ⋯ + (−1) ⌊ p p ⋯p ⌋
k+1
∑
i1 i1 i2 1 2 k
1≤i1 ≤k 1≤i1 <i2 ≤k
We already stated (but did not prove) some properties of Euler’s totient function in
proposition 41. Here, we are going to prove them beside a few more.
Theorem 108 (Properties of φ). Let m and n be positive integers. Then,
(a) φ is a multiplicative function. That is, if m⊥n, then
1 1
φ(n) = n(1 − p )⋯(1 − p )
1 k
α −1 α −1 α −1
= p1 1 p2 2 ⋯pk k (p1 − 1)⋯(pk − 1)
Proof.
(a) Write the numbers 1, 2, ⋯, mn in a table with m rows and n columns as below:
6
Notice the indices under the summation notation
181
§2. Common Arithmetic Functions Masum Billal, Amir Hossein
1 m + 1 2m + 1 . . . (n − 1)m + 1
2 m + 2 2m + 2 . . . (n − 1)m + 2
.. .. .. .. ..
. . . . .
m 2m 3m ... nm
The numbers in the rth row of the table are of the form km + r, where k =
0, 1, 2, ⋯, m − 1. Since (km + r, m) = (r, m), one of these two cases happen: either
all numbers in a row are co-prime to m or all of them are not co-prime to m. As
we are looking for numbers co-prime to mn, which are obviously those co-prime to
both m and n, we consider the rows with all numbers co-prime to m. There are
φ(m) such rows. Consider one such row in th table:
(b) φ(n) is the number of positive integers k such that k ≤ n and k⊥n. The point is
that if k is co-prime to n, then so is n − k. Therefore, for n ≥ 3, one can match all
numbers co-prime to n in pairs of (k, n − k), which means that φ(n) must be even.
(c) Take φ(5) > φ(6), φ(n) = φ(2n) for all odd n ≥ 1, and φ(n) ≡ 1 (mod 2) as
counterexamples.
(d) We have already provided the sketch of a proof in the beginning of this section.
Here is another proof using multiplicativity of φ. Since φ(n) is multiplicative, it
suffices to prove the result when n is a power of a prime. Let p be a prime and α ≥ 1
α α
be an integer. The only numbers which are not co-prime to p between 1, 2, ⋯, p
are multiples of p. How many multiples of p are there among these numbers? The
answer is p /p = p
α α−1
(why?). Therefore,
α α α−1
φ(p ) = p − p
α−1
=p (p − 1)
α α α
Now, if we factorize n as p1 1 p2 2 ⋯pk k , we can write
α α α
φ(n) = φ(p1 1 p2 2 ⋯pk k )
α α α
= φ(p1 1 )φ(p2 2 )⋯φ(pk k )
α −1 α −1 α −1
= p1 1 p2 2 ⋯pk k (p1 − 1) ⋯ (pk − 1)
182
§2. Common Arithmetic Functions Masum Billal, Amir Hossein
∑ φ(d) = n
d∣n
a1 , a2 , ⋯, ak
of positive integers less than or equal to n such that (a1 , a2 , ⋯, ak , n) = 1 is called the
k Jordan’s totient function and is denoted by Jk (n).
th
Note. Here, (a1 , a2 , ⋯, ak , n) is the notation for greatest common divisor of all numbers
a1 , a2 , ⋯, ak , and n.
183
§3. Dirichlet Product and Möbius Inversion Masum Billal, Amir Hossein
Example.
• Obviously, J1 (n) = φ(n). That is, the first Jordan totient function is Euler’s
totient function.
• Let us write all pairs (a, b) of positive integers less than 6 such that (a, b, 6) = 1.
(1, 1), (1, 2), (1, 3), (1, 4), (1, 5), (1, 6),
(2, 1), (2, 3), (2, 5),
(3, 1), (3, 2), (3, 4), (3, 5),
(4, 1), (4, 3), (4, 5),
(5, 1), (5, 2), (5, 3), (5, 4), (5, 5), (5, 6),
(6, 1), (6, 5)
We will state and prove the properties of Jordan’s totient function later in section
§4.3.
When working with arithmetic functions, we are mostly interested in the Dirichlet
product of two functions rather than their normal product. As you keep reading this
section, you find out why Dirichlet products are important when studying arithmetic
functions.
Dirichlet Product or Dirichlet Convolution. For two arithmetic functions f
and g, we define their Dirichlet product as
n
h(n) = ∑ f (d)g( )
d
d∣n
where the sum extends over all positive divisors d of n. We denote this by h = f ∗ g.
In other words,
(f ∗ g)(n) = ∑ f (a)g(b)
ab=n
184
§3. Dirichlet Product and Möbius Inversion Masum Billal, Amir Hossein
= ∑1
d∣n
= 1+1+⋯+1
Í ÎÌ Ï
repeated τ (n) times
= τ (n)
where τ (n) is the number of divisors of n. More details about this function will be
explained in section §4.1.
Example. This time, we aim to find the convolution of constant 1 function f with the
identity function. Again, by definition,
n
(id ∗ f )(n) = ∑ id(d)f ( )
d
d∣n
= ∑d
d∣n
= σ(n)
where σ(n) is the sum of divisors of n. If we show the constant 1 function by 1(n), we
can write (id ∗ 1)(n) = σ(n) or simply id ∗ 1 = σ.
Proposition 47 (Properties of Dirichlet Convolution). Let f, g, and h be any arith-
metic functions. The Dirichlet product is
1. commutative, that is, f ∗ g = g ∗ f ,
2. associative. This means that (f ∗ g) ∗ h = f ∗ (g ∗ h),
3. distributive, which means that f ∗ (g + h) = f ∗ g + f ∗ h.
Furthermore, the unit function ε(n) acts as a unit element for Dirichlet product. That
is, ε ∗ f = f ∗ ε = f for all arithmetic functions f .
Proof. The proof for commutativity of Dirichlet convolution is pretty straightforward
using the definition (f ∗ g)(n) = ∑ f (a)g(b). Obviously, since there is no difference
ab=n
between a and b in the latter formula, we can write it as
(f ∗ g)(n) = ∑ f (a)g(b)
ab=n
= ∑ f (b)g(a)
ab=n
= ∑ g(a)f (b)
ab=n
= (g ∗ f )(n)
185
§3. Dirichlet Product and Möbius Inversion Masum Billal, Amir Hossein
= ∑ ( ∑ f (a)g(b))h(c)
cd=n ab=d
= ∑ ( ∑ f (a)g(b)h(c))
cd=n ab=d
= ∑ f (a)g(b)h(c)
abc=n
Again, since there is a symmetry between a, b, and c, we find that the order of f, g, and
h in the expression (f ∗ g) ∗ h does not change the result. Hence, the Dirichlet product
is associative. The proof for distributivity is similar and is left for the reader. It is also
trivial by definition that ε is the unit element of Dirichlet convolution.
We are going define the Möbius function µ(n), which doesn’t seem very natural
at first sight. As we go deeper in this chapter and in Chapter IV on primes, we
will find out why this is in fact very important. It will help us a lot when solving
problems concerning inclusion and exclusion. In other words, the definition of the
Möbius function is natural in the way that it’s trying to alternate positive and negative
signs in an inclusion-exclusion argument.
Möbius Function. The Möbius function µ(n) is defined as
⎧
⎪ 1 if n = 1
⎪
⎪
⎪
µ(n) = ⎨ 0
2
if n is divisible by p for some prime p
⎪
⎪
⎪
⎪
⎩(−1)
k
if n = p1 p2 ⋯pk
Note. Why do we care about Möbius? We can express long, ugly-looking, tedious
sums into a very brief expression including sums over µ(n). If you feel comfortable with
arithmetic functions so far, you might like to see an application of the Möbius function
µ(n) in Theorem 152. You would be able to make sense of a beautiful application of
this function.
186
§3. Dirichlet Product and Möbius Inversion Masum Billal, Amir Hossein
Table 3.1: The Möbius function values for the first 100 positive integers.
187
§3. Dirichlet Product and Möbius Inversion Masum Billal, Amir Hossein
You may be wonder why would someone define such a not-very-nice-looking func-
tion? What is the motivation behind Möbius function? In fact, this function is the
inverse of a specific arithmetic function. Before going further, we must define the
Dirichlet inverse of an arithmetic function.
Dirichlet Inverse Function. Let f be an arithmetic function. The arithmetic
function g for which
f ∗g =ε
−1
is called the Dirichlet inverse of f . The function g is often denoted by f . You now
see why we call ε the unit function. Back to our discussion: let f be an arithmetic
function. Compute the Dirichlet product of f and constant 1 function and let the result
be F , which is also an arithmetic function. By definition of convolution, we have
F (n) = (f ∗ 1)(n)
= ∑ f (d)
d∣n
This function F is called the summatory function of f . In number theory, there are
times when we know what F = f ∗ 1 is and we want to know what f is. This is where
Möbius function comes in. Suppose that you do not know Möbius function, and you
just define µ(n) as the Dirichlet inverse of 1(n). That is, you define µ(n) be a function
such that µ ∗ 1 = ε. Then, multiply F by µ and use proposition 47 to get
F ∗ µ = (f ∗ 1) ∗ µ
= f ∗ (1 ∗ µ)
=f ∗ε
=f
In other words, you just need to multiply F by µ to find f . So, we just need to find
out what our defined function µ is. A few computations help us find µ, the Dirichlet
inverse of 1. First, (µ ∗ 1)(1) = ε(1) = 1, which gives µ(1) = 1. Let p be a prime and
α be a positive integer. Then,
α α
(µ ∗ 1)(p ) = ε(p )
=0
On the other hand, by definition of Dirichlet product and using the fact that the only
α α
divisors of p are 1, p, ⋯, p ,
α
(µ ∗ 1)(p ) = ∑ µ(d)
d∣pα
α
= µ(1) + µ(p) + ⋯ + µ(p )
=0
188
§3. Dirichlet Product and Möbius Inversion Masum Billal, Amir Hossein
Since we chose α arbitrarily, the equation µ(1) + µ(p) + ⋯ + µ(p ) = 0 must be true
α
for all values of α. For α = 1, we find 1 + µ(p) = 0, hence µ(p) = −1. Similarly, for
α ≥ 2, we find that µ(p ) = 0. Finally,
α
⎧
⎪ 1 if α = 0
⎪
⎪
α ⎪
µ(p ) = ⎨ if α = 1
⎪
⎪
−1
⎪
⎪
⎩0 if α ≥ 2
The general definition of µ, as stated in definition §3, can be inferred from the above
result using the fact that µ is a multiplicative function.
As you can observe, the µ function is defined to help us find an arithmetic function
f given its summatory function F . In fact, f = F ∗ µ. This was first introduced by
th
Möbius in 19 century and is known as the Möbius Inversion Formula.
Theorem 110 (Möbius Inversion Formula). If the summatory function of an arithmetic
function f is F (n) = ∑ f (d), then
d∣n
n
f (n) = ∑ µ(d)F ( )
d
d∣n
In other words, f = µ ∗ F .
When we first discussed Dirichlet inverse of a function, you might have wondered if
this inverse always exists. The following theorem sheds light on this issue.
Theorem 111. For an arithmetic function f with f (1) ≠ 0, the Dirichlet inverse f
−1
−1
exists and is unique. In fact, f can be defined recursively as
⎧
⎪ 1
⎪
⎪ if n = 1
⎪
⎪ f (1)
⎪
f (n) = ⎪ ⎨
−1
⎪
⎪
⎪
⎪ −1 n
⎪
⎪ ∑ d∣n f (d)f ( ) if n > 1
−1
⎪
⎩ f (1) d<n d
As discussed above, µ(n) is the Dirichlet inverse of the simplest arithmetic function,
1(n). The next theorem follows.
Theorem 112. The Dirichlet inverse of the Möbius function is the constant 1 function.
−1
In other words, 1 = µ or
∑ µ(n) = ε(n)
d∣n
Theorem 113. Let f be an arithmetic function and denote by F its summatory func-
tion. That is, for all positive integers n,
F (n) = ∑ f (d)
d∣n
Then,
n n
n
∑ F (k) = ∑ f (k)⌊ ⌋
k=1 k=1
k
189
§4. More on Multiplicative Functions Masum Billal, Amir Hossein
In the last formula, f (1) is repeated n times because 1 divides all integers. Also,
f (2) is repeated ⌊n/2⌋ times because there are exactly ⌊n/2⌋ numbers between 1 and
n (inclusive) which are even. Analogously, there are exactly ⌊n/k⌋ multiples of k
(1 ≤ k ≤ n) in this interval and thus f (k) is repeated ⌊n/k⌋ times. The proof is
complete.
Example. According to Theorem 112, the summatory function of µ is ε. Therefore,
n n
n
∑ ε(k) = ∑ µ(k)⌊ ⌋
k=1 k=1
k
Since ε(k) equals one when k = 1 and zero otherwise, the sum on the left side equals
one. Consequently,
n
n
∑ µ(k)⌊ ⌋ = 1
k=1
k
You can check the correctness of this formula by trying some small values for n.
e e
(5) F (n) = (1 + f (p1 ) + . . . + (p11 ))⋯(1 + f (pk ) + . . . + f (pkk ))
k ei
j
= ∏ ∑ f (pi )
i=1 j=0
k
e
= ∏ F (pi i )
i=1
190
§4. More on Multiplicative Functions Masum Billal, Amir Hossein
Proof. The proof somewhat follows from the unique prime factorization. Assume T is
w w w
the expansion of the right side of equation 5. If d is a divisor of n, then d = p1 1 p2 2 ⋯pk k ,
where 0 ≤ wi ≤ ei for i = 1, 2, ⋯, k. Therefore,
w w w
f (d) = f (p1 1 p2 2 ⋯pk k )
w w w
= f (p1 1 )(p2 2 )⋯f (pk k )
which is a term that is present in T . Thus, we conclude that each term in the sum
F (n) = ∑ f (d) appears in T . We can easily find that the converse is also true. After
d∣n
expanding the right side of equation 5, we see that every term in T is of the form
w w
f (p1 1 )⋯f (pk k )
where wi are integers with 0 ≤ wi ≤ ei for all i. Since f is multiplicative, we can write
this as
w w w
f (p1 1 p2 2 ⋯pk k )
which equals f (d). Therefore, every term in T is also in F (n). Combining these two,
T = F (n).
e e e
Corollary 30. If f is a non-zero multiplicative arithmetic function and n = p11 p22 ⋯pkk
is the prime factorization of a positive integer n,
k
∑ µ(d)f (d) = ∏(1 − f (pi ))
d∣n i=1
Proof.
191
§4. More on Multiplicative Functions Masum Billal, Amir Hossein
a b
= ∑ f (d1 )f (d2 )g( )g( )
d1 d2
d1 ∣a,d2 ∣b
ab
= ∑ f (d1 d2 )g( )
d1 d2
d1 ∣a,d2 ∣b
ab
= ∑ f (d)g( )
d
d∣ab
= (f ∗ g)(ab)
= h(ab)
2. f is multiplicative, hence f (mn) = f (m)f (n) for all co-prime positive integers m
and n. Put m = n = 1 in this equation to get f (1) = f (1) , which immediately
2
gives f (1) = 1 because f only accepts positive integer values. Let g be the
Dirichlet inverse of f . By Theorem 111, g(1) = 1. We will prove by induction
that g is multiplicative. The base case n = 1 is true. Suppose that n > 1 and
whenever ab < n with (a, b) = 1, then g(ab) = g(a)g(b). Also, suppose that
xy = n with (x, y) = 1. We will show that g(xy) = g(x)g(y). Since g is the
inverse of f , we have (f ∗ g)(n) = ε(n). Also, ε(n) = 0 for n > 1. Therefore,
n
0 = ∑ f (d)g( )
d
d∣n
xy
= ∑ f (d)g( )
d
d∣xy
xy
(6) = g(xy) + ∑ f (d)g( )
d
d∣xy
d>1
192
§4. More on Multiplicative Functions Masum Billal, Amir Hossein
So, g(xy) = −(f ∗ g)(x) ⋅ (f ∗ g)(y) + g(x)g(y). Note that since xy > 1, at least
one of x or y is larger than 1. Therefore, since g is the Dirichlet inverse of f , at
least one of (f ∗ g)(x) or (f ∗ g)(y) is equal to zero. Finally, g(xy) = g(x)g(y)
and we are done.
−1
3. Let f ∗ g = h. Multiply both sides by f , the Dirichlet inverse of f , to get
−1 −1
g = h ∗ f (why?). Multiplicativity of f implies the multiplicativity of f by
−1
part 2. Now, from part 1, since both h and f are multiplicative, their product,
g must also be multiplicative.
Note. If two functions f and g are completely multiplicative, their Dirichlet product
is multiplicative, but not necessarily completely multiplicative. An example would be
(1 ∗ 1)(n) = τ (n). Although the constant 1 function is completely multiplicative, the
number of divisors function d is not.
−1
The same is true for part 2: if f is completely multiplicative, then f is multiplica-
tive, but not in general completely multiplicative.
In proposition 41, we stated that Euler’s totient function φ is multiplicative. We
can now prove this result.
Proposition 49. Prove that φ is multiplicative.
Proof. As proved in Theorem 109, we know that φ ∗ 1 = id. Obviously, both 1(n) and
id(n) are multiplicative. The conclusion follows from part 3 of Theorem 115.
193
§4. More on Multiplicative Functions Masum Billal, Amir Hossein
Although it is not always easy to find the Dirichlet inverse of an arithmetic function,
there is an exception for completely multiplicative functions.
Theorem 116 (Inverse of Completely Multiplicative Functions). Let f be a multiplica-
tive function. Then f is completely multiplicative if and only if
f (n) = µ(n)f (n)
−1
for all n ∈ N.
Note. Here, µ(n)f (n) is the point-wise multiplication of µ and f at point n. It is not
to be confused with Dirichlet product (µ ∗ f )(n).
Proof. First, if f is completely multiplicative, define g(n) = µ(n)f (n). Then, by
definition of Dirichlet product,
n
(g ∗ f )(n) = ∑ g(d)f ( )
d
d∣n
n
= ∑ µ(d)f (d)f ( )
d
d∣n
n
= ∑ µ(d)f (d ⋅ )
d
d∣n
= f (n) ∑ µ(d)
d∣n
= f (n)ε(n)
= ε(n)
The last equality holds because f (1) = ε(1) = 1 (why?) and ε(n) = 0 for all n ≥ 2.
This means that g is the Dirichlet inverse of f .
For the converse, suppose that f (n) = µ(n)f (n) and we want to prove that f
−1
p and any positive integer α (why?). We will proceed by induction. The base case
α = 1 is obvious. Suppose that we know f (p ) = f (p)
α−1 α−1
and we want to show that
f (p ) = f (p) . For any n ≥ 2, (f ∗ f )(n) = ε(n) = 0. Therefore,
α α −1
n
∑ µ(d)f (d)f ( ) = 0
d
d∣n
α
Put n = p in the above equation to obtain
n α α−1 α α
∑ µ(d)f (d)f ( ) = µ(1)f (1)f (p ) + µ(p)f (p)f (p ) + ⋯ + µ(p )f (p )f (1)
α
d
d∣p
α α−1
= µ(1)f (1)f (p ) + µ(p)f (p)f (p )
α α−1
= f (p ) − f (p)f (p )
=0
result.
194
§4. More on Multiplicative Functions Masum Billal, Amir Hossein
Example.
• τ (100) = τ (2 ⋅ 5 ) = (2 + 1)(2 + 1) = 9.
2 2
τ ∗µ=1∗1∗µ
=1∗ε
=ε
Theorem 117. Let n be a positive integer. The number of pairs (a, b) of positive
integers which satisfy ab = n is τ (n).
Proof. First, if for some positive integers a and b the equation ab = n holds, then a is
a divisor of n. Second, for any divisor a of n, the number b = n/a is an integer that
satisfies ab = n. Therefore, τ (n) counts exactly all the solutions of ab = n.
Here is a more interesting question:
Question. Let x ≥ 1 be a real number. Find the number of pairs (a, b) of positive
integers which satisfy
(7) ab ≤ x
195
§4. More on Multiplicative Functions Masum Billal, Amir Hossein
n τ (n)
1 1
2 2
3 2
4 3
5 2
6 4
7 2
8 4
9 3
10 4
One way to answer this question is to break the condition ab ≤ x into smaller
conditions. Obviously, the equation ab = y does not have any solutions in integers if y
is not an integer. So, in order to find the number of solutions to the inequality 7, we
only need to find the number of solutions to each of ab = 1, ab = 2, ⋯, ab = ⌊x⌋ and the
answer would be the sum of these numbers. According to Theorem 117, the answer is
Example. Let us find T (10.2). We need to compute τ (1), τ (2), ⋯, τ (10). According to
table 3.2 and equation 8, T (10.2) is equal to the sum of numbers in the second column,
which is 27.
As you observe in the above example, it would be a tedious job to calculate T (x)
by summing up the τ values. There is another way to compute T (x). Let a be a fixed
positive integer. The inequality ab ≤ x is equivalent to
x
b≤ a
Since b is a positive integer, it can take the values 1, 2, ⋯, ⌊ xa ⌋. These are ⌊ xa ⌋ numbers.
Since a can take all the values 1, 2, ⋯, ⌊x⌋, we have
x x x
T (x) = ⌊ ⌋ + ⌊ ⌋ + ⋯ + ⌊ ⌋
1 2 ⌊x⌋
196
§4. More on Multiplicative Functions Masum Billal, Amir Hossein
is more convenient than 8. That is, we can find T (x) using equation 9 with less
number of calculations. In fact, to compute T (x) from 8, we need to calculate the
number of divisors of ⌊x⌋ numbers, which obviously needs more computations than ⌊x⌋
computations needed in formula 9. However, this can be refined even more.
We will divide the solutions to ab ≤ x into two classes. The first class includes
√ √
solutions in which a ≤ x and the second one includes all solutions such that a > x.
Let T1 (x) be the number of solutions in the first class and let T2 (x) be that of the
second class. Therefore,
For the second class, we must find how many pairs (a, b) of integers satisfy the following
inequalities:
ab ≤ x
√
a> x
197
§4. More on Multiplicative Functions Masum Billal, Amir Hossein
√
These are ⌊ xb ⌋ − ⌊x⌋ numbers. So, since b can take all values 1, 2, ⋯, ⌊ x⌋, we have
√
⌊ x⌋
x √
(10) T2 (x) = ∑ (⌊ ⌋ − ⌊ x⌋)
b=1
b
In order to add T1 (x) and T2 (x) to obtain T (x), we have to make their summation
parameter the same. We already know that changing the summation parameter does
not change the value of the sum. Therefore, we can change b to a in equation 10 and
write T2 (x) as
⌊x⌋
x √
T2 (x) = ∑ (⌊ a ⌋ − ⌊ x⌋)
a=1
198
§4. More on Multiplicative Functions Masum Billal, Amir Hossein
We already know that 0 ≤ {n/k} < 1. Therefore, the second sum in the right hand side
of equation 12 is between zero and n. Therefore,
∑ {n/k}
n
0 < k=1 n <1
(it is never equal to zero, can you see why?). The proof is complete.
Note. This theorem states that the average value of number-of-divisors function (i.e.,
[τ (1) + ˚τ (2) + ⋯ + τ (n)]/n) is approximately equal to sum of reciprocals of positive
integers up to n. We represent this as
τ (1) + τ (2) + ⋯ + τ (n) 1 1 1
n ∼ + + ⋯ + n
1 2
= (id ∗ 1)(n)
Now, since both id and constant 1 function are multiplicative, part 1 of Theorem 115
implies that σ is also multiplicative.
199
§4. More on Multiplicative Functions Masum Billal, Amir Hossein
Problem 207. Prove that for two positive integers a and b, if a ∣ b, then
σ(a) σ(b)
a ≤ b
Solution. Let b = ∏ p be the prime factorization of b. Then, since a ∣ b, the fac-
e
p∣b
f
torization of a would be a = ∏ p with 0 ≤ f ≤ e for each prime p dividing b. From
p∣b
Theorem 104,
e+1
p −1
σ(b) = ∏
p−1
p∣b
f +1
p −1
σ(a) = ∏
p−1
p∣b
e+f +1 f e+f +1 e
⟺ p (p − 1) − p (p − 1) ≥ p (p − 1) − p (p − 1)
e f
⟺ p (p − 1) ≥ p (p − 1)
Theorem 119. Let k > 1 be a given positive integer. Show that the equation
σ(n) = n + k
200
§4. More on Multiplicative Functions Masum Billal, Amir Hossein
Proof. Suppose that σ(n) = n + k holds for some positive integer n. Since k > 1, n
√
must be composite (otherwise σ(n) = n + 1). According to theorem 51, σ(n) > n + n.
√ 2 2 2
As a result, we find n < k or n < k . Obviously, there are at most k values 1, 2, ⋯, k
possible for n. This finishes the proof.
Theorem 120. Let k be an arbitrary positive integer. Show that there exists a positive
integer n0 such that for any n > n0 ,
σ(n!)
>k
n!
In other words, prove that
σ(n!)
lim =∞
n→∞ n!
Proof. According to Theorem 103,
σ(n!) 1
=∑
n! d
d∣n!
σ(n!) 1
=∑
n! d
d∣n!
1 1 1
> + +⋯+ n
1 2
It suffices to find an n such that
1 1 1
+ +⋯+ n >k
1 2
2k
Take n = 2 . Then,
1 1 1 1 1 1 1 1 1 1
+ + ⋯ + 2k > 1 + + ( + ) + ( + + + )
1 2 2 2 4 4 8 8 8 8
⎛ ⎞
⎜
⎜ ⎟
⎜
⎜ 1 1 1 ⎟⎟
⎟
+⋯+⎜ ⎜
⎜ + + ⋯ + ⎟
2k ⎟
⎜2
⎜
2k
2 2k
2 ⎟ ⎟
⎟
⎜Í ÎÌ Ï⎟
⎝ 22k−1 times
⎠
1
> 1 + 2k( )
2
=1+k
>k
as desired.
201
§4. More on Multiplicative Functions Masum Billal, Amir Hossein
2 2
Theorem 121. σ(n) is odd if and only if n = k or n = 2k for some integer k.
e e e
Proof. Let n = p11 p22 ⋯pkk be the factorization of n and suppose that σ(n) is odd. We
will prove that n is either a perfect square or twice a perfect square. According to
k e +1
pi i −1
Theorem 104, since σ(n) is odd, all the terms in the product ∏ p−1
must be odd.
i=1
That is,
2 e
(14) 1 + p i + pi + ⋯ + pi i
must be odd for i = 1, 2, ⋯, k. There are two cases: if pi ≠ 2 for all i, then the number
of terms in the expression 14 must be odd so that their sum is also odd (they are all
odd). That is, ei must be even for i = 1, 2, ⋯, k. Hence, n is a perfect square.
The other case is when some pi , say p1 is equal to 2. The expression 14 is odd for
p1 = 2. Now, in order for expression 14 to be odd, all ei must be even for 2 ≤ i ≤ k
(exactly like the previous case). Now, if the power of 2 that divides n is even, n is of
2 2
the form k and if it is odd, n is of the form 2k .
The proof of the converse is now obvious.
Corollary 31. If n is an odd positive integer, then n is a square if and only if σ(n) is
odd.
Proposition 52. Let n be a positive integer. The number of positive integers less than
or equal to n with even sum of divisors is
√
√ n
n − ⌊ n⌋ − ⌊ ⌋
2
Proof. There are n positive integers less than or equal to n. We know from Theorem 121
that numbers that are a perfect square or twice a perfect square have an even σ. The
√
number of perfect squares less than or equal to n is ⌊ n⌋ (why?). Similarly,
√ the number
of integers less than or equal to n that is twice a perfect square is ⌊ n/2⌋. The
conclusion follows.
A family of numbers that are related to the sum of divisors function are perfect
numbers.
Definition. A positive integer n is a perfect number if σ(n) = 2n.
4
Example. The only perfect numbers less than 10 are 6, 28, 496, and 8128.
k
Theorem 122. Let k > 1 be a positive integer. If 2 − 1 is a prime number, then
2 (2 − 1) is a perfect number. Also, every even perfect number has this form.
k−1 k
(2 − 1)
k k−1 k
Proof. First, suppose that p = 2 − 1 is a prime. We will prove that n = 2
k
is perfect. Notice that σ(p) = p + 1 = 2 and since σ is multiplicative,
k−1 k
σ(n) = σ(2 (2 − 1))
k−1
= σ(2 )σ(p)
2 k−1 k
= (1 + 2 + 2 + ⋯ + 2 ) (2 )
k k
= (2 − 1) 2
= 2n
202
§4. More on Multiplicative Functions Masum Billal, Amir Hossein
Now, suppose that n is an even perfect number. We want to show that it is of the form
2 (2 − 1). We will use the trick stated in Theorem 13. One can write n as 2 s for a
k−1 k k
Therefore, σ(s) = s + t. It means that s must be a prime and its only divisors are itself
(s) and one (t) (why?). Hence n = 2 (2
k k+1 k+1
− 1), 2 − 1 is a prime, and n has the
desired form.
Remark . We do not know whether there exist infinitely many perfect numbers. In
fact, even perfect numbers are formed by Mersenne primes (see Theorem 28 and its
remark), and it has not yet been proved that there are infinitely many Mersenne primes.
Furthermore, it is not known whether there are any odd perfect numbers. Mathemati-
1500
cians have tested the first 10 natural numbers but did not find any odd perfect
number among them, so they guess there probably does not exist any.
Theorem 123. Let n be a positive integer. Then, σ(n) is a power of 2 if and only if
n is a product of some Mersenne primes.
Proof. It is obvious that sum of divisors of the product of some Mersenne primes is a
k
power of 2 (prove it yourself). We will now show that if σ(n) = 2 for some natural k,
α α α
then n is a product of Mersenne primes. Let n = p1 1 p2 2 ⋯pmm be the prime factorization
αi
of n. Since σ is multiplicative, σ(pi ) must be a power of 2 for i = 1, 2, ⋯, m. Therefore,
it suffices to prove that if for a prime p and a positive integer α, σ(p ) = 2 , then p is
α k
α 2 α
a Mersenne prime and α = 1. The only divisors of p are 1, p, p , ⋯, p , so,
k 2 α
2 =1+p+p +⋯+p
This means that α is odd. Take α = 2β + 1. Then we can factorize the right hand side
as
k 2 4 2β
(16) 2 = (1 + p) (1 + p + p + ⋯ + p )
203
§4. More on Multiplicative Functions Masum Billal, Amir Hossein
∣ ∣
µ(d)σ(d) 1
∑ ≥n
d
d∣n
Solution. Let f (n) = µ(n)σ(n)/n. Sine all three functions µ, σ, and id are mul-
tiplicative, so is f . Theorem 114 implies that the summatory function of f is also
α
multiplicative. Therefore, it suffices to prove the given inequality only when n = p ,
where p is a prime and α is a positive integer. Since µ(p ) is zero for x ≥ 2, µ(1) = 1,
x
∣ ∣ ∣ ∣
µ(p )σ(p )
α a
µ(d)σ(d) µ(1)σ(1) µ(p)σ(p)
∑ = + + ⋯ +
d 1 p pa
d∣pα
= ∣ µ(1)σ(1)
1
+
µ(p)σ(p)
p ∣
= ∣ 11 − p +p 1 ∣
1
=p
1
≥ α
p
The reader is supposed to draw the conclusion and finish the proof.
We can generalize the concept of number-of-divisors and sum-of-divisors functions
to define divisor functions.
7 th
Definition. Let n be a positive integer and α ≥ 0 be an integer . The sum of α
powers of positive divisors of n is denoted by σα (n). In other words,
α
σα (n) = ∑ d
d∣n
7
More generally, one can assume that α is any non-negative real number.
204
§4. More on Multiplicative Functions Masum Billal, Amir Hossein
The functions σα are called divisor functions. According to this definition, the number-
of-divisors function τ is equal to σ0 and the sum-of-divisors function σ is equal to σ1 .
Theorem 124 (Properties of Divisor Functions). For every non-negative integer α and
positive integer n,
2. Notice that
α α
(1 ∗ id )(n) = (id ∗ 1)(n)
α n
= ∑ id (d) ⋅ 1( )
d
d∣n
α
= ∑d
d∣n
= σα (n)
α
4. From Theorem 116, sine the function id is completely multiplicative, its Dirichlet
α
inverse is µ id . Hence, from part 2 of this theorem,
α −1
(σα )(n) = (1 ∗ id ) (n)
−1
α −1
= (1 ∗ (id ) ) (n)
−1
α
= (µ ∗ µ id ) (n)
α n
= ∑ d µ(d)µ( )
d
d∣n
205
§4. More on Multiplicative Functions Masum Billal, Amir Hossein
µ(d)
φ(n) = n ∑
d
d∣n
Proof. Let f (n) = φ(n). By Theorem 109, we know that F (n) = ∑ φ(d) = n. There-
d∣n
fore, by Möbius inversion formula,
n
φ(n) = f (n) = ∑ µ(d)F ( )
d
d∣n
n
= ∑ µ(d)F ( )
d
d∣n
µ(d)
= n∑
d
d∣n
as desired.
In Theorem 109, we proved that ∑ φ(d) = n. We will now prove that the converse of
d∣n
this theorem is also true. That is, φ is the only arithmetic function with this property.
∑ f (d) = n
d∣n
Proof. By Möbius inversion formula, f = µ ∗ F , where F (n) = ∑ f (d). So, in this case
d∣n
f = µ ∗ id. On the other hand, we already know from corollary 32 that φ = µ ∗ id.
Thus, f = φ.
∑ µ(d)φ(d) = ∏(2 − p)
d∣n p∣n
2 2 2
∑ µ(d) φ(d) = ∏(1 + (p − 1) )
d∣n p∣n
µ(d) 1
∑ = ∏ (1 − )
φ(d) p − 1
d∣n p∣n
206
§4. More on Multiplicative Functions Masum Billal, Amir Hossein
Proof. We will only prove 1 here. The other two parts are similar. Let f (n) =
µ(n)φ(n). Since µ and φ are both multiplicative, their product f is also multiplicative.
By Theorem 114, the summatory function of f is multiplicative as well. Therefore, it
suffices to find the sum F (n) = ∑ µ(d)φ(d) only when n is a power of a prime. Let
d∣n
n = p . Then, since µ(p ) = 0 for integer β > 1,
α β
α α
∑ µ(d)φ(d) = µ(1)φ(1) + µ(p)φ(p) + ⋯ + µ(p )φ(p )
d∣pα
= µ(1)φ(1) + µ(p)φ(p)
= 1 − (p − 1)
=2−p
e e e
Suppose that n = p11 p22 ⋯pkk is the prime factorization of n. Then, again by Theo-
rem 114,
k ei
∑ µ(d)φ(d) = ∏ ∑ µ(d)φ(d)
d∣n i=1 j=0
k
= ∏(2 − pi )
i=1
1
≤ n(1 − p )
1
1
≤ n(1 − √ )
n
√
=n− n
Theorem 129. Let k be an arbitrary positive integer. Show that there exists a positive
integer n0 such that for any n > n0 ,
φ(n) > k
207
§4. More on Multiplicative Functions Masum Billal, Amir Hossein
√
Proof. We will prove that φ(n) ≥ 2n and the result immediately follows. First, suppose
α α α
that n is odd. Let n = p1 1 p2 2 ⋯pk k be the prime factorization of n. Then, because of the
1/2
fact that pi are primes larger than 2, 1 ≤ i ≤ k, we can use the inequality pi − 1 ≥ pi
(prove it yourself) to write
α −1 α −1 α −1
φ(n) = p1 1 p2 2 ⋯pk k (p1 − 1) ⋯ (pk − 1)
α −1 α −1 α −1 1/2 1/2 1/2
≥ p1 1 p2 2 ⋯pk k ⋅ p1 p2 ⋯pk
α −1/2 α2 −1/2 α −1/2
≥ p1 1 p2 ⋯pk k
Now, since αi is a positive integer for all i, the inequality αi − 1/2 ≥ αi /2 holds true.
Hence,
α −1/2 α2 −1/2 α −1/2
φ(n) ≥ p1 1 p2 ⋯pk k
α /2 α /2 α /2
≥ p1 1 p2 2 ⋯pk k
√
= n
Corollary 33. Let k be an arbitrary integer. The number of positive integers n for
which φ(n) = k is finite.
Theorem 130. Let n be a positive integer. Then,
n n
1 1 n 2
∑ φ(k) = + ∑ µ(k)⌊ ⌋
2 2 k
k=1 k=1
208
§4. More on Multiplicative Functions Masum Billal, Amir Hossein
Proof. Define
n
1 n 2
f (n) = ∑ µ(k)⌊ ⌋
2 k
k=1
µ(k) 1
= (n + 1) ∑ − ∑ µ(k)
k 2
k∣(n+1) k∣(n+1)
By Theorem 125, the first term in the last line of above equations equals φ(n + 1), and
by Theorem 112, the second term is 12 ε(n + 1). Therefore,
1
f (n + 1) − f (n) = φ(n + 1) − ε(n + 1)
2
Now, from Sum of Differences,
n
1 n 2
∑ µ(k)⌊ ⌋ = f (n)
2 k
k=1
n−1
= f (1) + ∑ (f (k + 1) − f (k))
k=1
n−1
1 1
= + ∑ (φ(k + 1) − ε(k + 1))
2 2
k=1
n−1 n−1
1 1
= + ∑ φ(k + 1) − ∑ ε(k + 1)
2 2
k=1 k=1
Í ÎÌ Ï
=0
n−1
1
= + ∑ φ(k + 1)
2
k=1
n
1
= + ∑ φ(k) − φ(1)
2
k=1
n
1
= ∑ φ(k) −
2
k=1
209
§4. More on Multiplicative Functions Masum Billal, Amir Hossein
First Proof. In an analogous way to the proof of previous theorem, we use Theorem 6.
n
Define f (n) = ∑ ⌊ k ⌋.
µ(k) n
k
In this case,
k=1
n+1 n
µ(k) n + 1 µ(k) n
f (n + 1) − f (n) = ∑ ⌊ ⌋−∑ ⌊ ⌋
k=1
k k k=1
k k
n+1
µ(k) n + 1 n
=∑ (⌊ ⌋ − ⌊ ⌋)
k=1
k k k
µ(k)
= ∑
k
k∣(n+1)
φ(n + 1)
=
n+1
by Theorem 125. Consequently,
n
µ(k) n
∑ ⌊ ⌋ = f (n)
k=1
k k
n−1
= f (1) + ∑ (f (k + 1) − f (k))
k=1
n−1
φ(k + 1)
=1+∑
k=1
k+1
n
φ(k) φ(1)
=1+∑ −
k 1
k=1
n
φ(k)
=∑
k=1
k
as desired.
µ(n)
Second Proof. Take f (n) = n . Then, F (n), the summatory function of f , would
be
µ(d)
F (n) = ∑
d
d∣n
1⎛ µ(d) ⎞
= n ⎜n ∑ ⎟
⎝ d∣n d ⎠
210
§4. More on Multiplicative Functions Masum Billal, Amir Hossein
According to Theorem 125, the expression in the parenthesis equals φ(n). Therefore,
φ(n)
F (n) = n
The conclusion follows from Theorem 113.
Theorem 132 (Properties of Jordan’s Totient Function). Let n and k be positive in-
tegers. Then,
1
1. Jk (n) = n ∏ (1 − )
k
p∣n
pk
2. Jk is multiplicative
k
3. ∑ Jk (d) = n
d∣n
k
4. Jk = id ∗ µ
5. Jk is even if and only if n ≥ 3
Proof.
1. Let p1 , p2 , ⋯, pm be the prime factors of n. Consider all k−tuples (x1 , x2 , ⋯, xk )
of positive integers so that xi ≤ n for i = 1, 2, ⋯, n. The number of such k−tuples
is n (why?). In order to find Jk (n), we must find out how many of these n
k k
k 1
n1 = n (1 − )
pk1
Among these n1 k−tuples, there are n2 = n1 (1 − p1k ) ones in which not all xi are
2
divisible by p2 . Continuing this way, assuming nj (1 ≤ j ≤ m) to be the number of
k−tuples (x1 , x2 , ⋯, xk ) in which not all xi (1 ≤ i ≤ k) are divisible by p1 , p2 , ⋯,
or pj ,
1
n3 = n2 (1 − )
pk3
1
n4 = n3 (1 − )
pk4
..
.
1
nm = nm−1 (1 − )
pkm
211
§4. More on Multiplicative Functions Masum Billal, Amir Hossein
1 1 1
)⋯ (1 − )
k
Jk (n) = n (1 − ) (1 −
pk1 pk2 pkm
1
= n ∏ (1 − )
k
p∣n
pk
2. Let m and n be co-prime positive integers. We will show that Jk (mn) = Jk (m)Jk (n).
Suppose that
α α α
m = p1 1 p2 2 ⋯pt t
β β β
n = q1 1 q2 2 ⋯qs s
p∣mn
pk
⎛ k 1 ⎞⎛ k 1 ⎞
= ⎜m ∏ (1 − k )⎟ ⎜n ∏ (1 − k )⎟
⎝ p∣m
p ⎠ ⎝ p∣n p ⎠
= Jk (m)Jk (n)
Therefore,
α
∑ Jk (d) = Jk (1) + Jk (p) + ⋯ + Jk (p )
d∣pα
α
ki k(i−1)
= 1 + ∑ (p − p )
i=1
212
§5. Menon’s Identity Masum Billal, Amir Hossein
k
4. The equation ∑ Jk (d) = n can be represented as 1 ∗ Jk = id . Then, since the
k
d∣n
inverse of function 1 is µ (Theorem 112),
∗ (1 ∗ Jk )
−1
Jk = 1
−1 k
=1 ∗ id
k
= µ ∗ id
α α α
5. Let n = p1 1 p2 2 ⋯pmm be the prime factorization of n. One can write the formula
in part 1 of this theorem as
1 1 1
)⋯ (1 − )
k
Jk (n) = n (1 − ) (1 −
pk1 pk2 pkm
α −1 α −1 α −1 k k k k
= (p1 1 p2 2 ⋯pmm ) (p1 − 1) (p2 − 1)⋯ (pm − 1)
§5 Menon’s Identity
Menon’s Identity is a very nice theorem in number theory, though not popular. Here,
we prove it using a powerful theorem. First, we need the following lemma.
Lemma 9. Let m and n be positive integers such that (m, n) = d. Prove that
d
φ(mn) = φ(m)φ(n) ⋅
φ(d)
Proof. Using part (d) of Theorem 108, we know that φ(x) = x ∏ (1 − p1 ), where x is
p∣x
213
§5. Menon’s Identity Masum Billal, Amir Hossein
∏ (1 − p1 ) ⋅ ∏ (1 − p1 )
p∣m p∣n
= mn ⋅
∏ (1 − p1 )
p∣d
m ∏ (1 − p1 ) ⋅ n ∏ (1 − p1 ) ⋅ d
p∣m p∣n
=
d ∏ (1 − p1 )
p∣d
d
= φ(m)φ(n) ⋅
φ(d)
214
§5. Menon’s Identity Masum Billal, Amir Hossein
We want to prove that the number of integers among these numbers which are co-prime
φ(k)
to k is s . Let us prove the case when s = 1 first. In this case, k ⊥ d, k = k1 , and
φ(s)
d = d1 . Therefore, the numbers in the first row are r + d, r + 2d, ⋯, r + kd, which are
all different modulo k (why?). This means that they form a complete residue system
modulo k. Obviously, there are
φ(k)
φ(k) =
φ(s)
numbers co-prime to k among these integers. So, the theorem is proved for the case
s = 1. Now assume that s > 1. There are s rows of numbers. So, if we prove that
φ(k)
there are numbers co-prime to k in each row, we are done. Similar to the above,
φ(s)
for any i, we have (r + id1 s, k) = 1 if and only if (r + id1 s, k1 ) = 1. Moreover, the
numbers in each column are congruent modulo k1 . We know that if a ≡ b (mod k1 ),
then (a, k1 ) = (b, k1 ). This means that the number of integers co-prime to k1 (and thus
k) in all the rows are equal.
φ(k)
So, it suffices to prove that there are exactly numbers co-prime to k1 in the
φ(s)
first row of numbers, namely, r + is for i = d1 , 2d1 , ⋯, k1 d1 . If you look closely, this
is exactly the same thing as the original theorem when we replace n by k, k by k1 ,
and d by s (the only difference is that here, the possible values for i are k1 numbers
d1 , 2d1 , ⋯, k1 d1 , while possible values for i in the original theorem are 1, 2, ⋯, k).
In the new version of the theorem, which we want to prove, there are k1 numbers of
the form r+is, while this number is k = k1 s in the original theorem. Since s > 1, we have
k1 < k. Take s1 = (s, k1 ) and let k2 and d2 be integers such that k1 = k2 s1 and s = d2 s1 .
With the same method as above, classify the numbers r + d1 s, r + 2d1 s, ⋯, r + k1 d1 s as:
r + d1 d2 s 1 r + 2d1 d2 s1 ⋯ r + k2 d1 d2 s1
r + (k2 + 1)d1 d2 s1 r + (k2 + 2)d1 d2 s1 ⋯ r + 2k2 d1 d2 s1
.. .. .. ..
. . . .
r + [(s − 1)k2 + 1]d1 d2 s1 r + [(s − 1)k2 + 2]d1 d2 s1 ⋯ r + s1 k2 d1 d2 s1
With the exact same reasoning as above, we can reduce the problem to showing that
φ(k2 )
there are integers co-prime to k2 in the first row of above numbers. If s1 = 1,
φ(s1 )
we are done. Otherwise, we have k2 < k1 and we can take s2 = (s1 , k2 ), k2 = k3 s2 ,
and s1 = d3 s2 . If we continue this process, we will finally reach a point where the gcd
becomes one. That is, the sequence s, s1 , s2 , ⋯ will eventually reach 1. The reason is
that the sequence k, k1 , k2 , ⋯ is strictly decreasing and contains only positive integers.
This means that for some m, we will have km = 1 and then the sequence stops. In
that point, km−1 = km , which in turn means sm−1 , the gcd of km and sm−1 , equals one.
We have already showed that when this gcd is one, the theorem is true. The proof is
complete.
215
§6. Liouville Function Masum Billal, Amir Hossein
According to Theorem 133, the second sum in the last line equals φ(n)/φ(d). Therefore,
n
φ(n)
∑ (i − 1, n) = ∑ φ(d)
i=1 d∣n
φ(d)
(i,n)=1
= ∑ φ(n)
d∣n
= τ (n)φ(n)
§6 Liouville Function
Small Omega Function. Let n be a positive integer. The number of distinct prime
factors of n is denoted by ω(n).
216
§6. Liouville Function Masum Billal, Amir Hossein
Liouville Function. For a natural number n, the Liouville function λ(n) is defined
as
Ω(n)
λ(n) = (−1)
α α α
Proposition 53. Let n = p1 1 p2 2 ⋯pk k be the prime factorization of a positive integer
n. Then, ω(n) = k and Ω(n) = α1 + α2 + ⋯ + αk . In other words,
k
ω(n) = ∑ 1
i=1
k
Ω(n) = ∑ αi
i=1
α
p
(λ ∗ ∣µ∣)(p ) = ∑ ∣µ(d)∣ λ( )
α
α
d
d∣p
α α−1 α
= ∣µ(1)∣λ(p ) + ∣µ(p)∣λ(p ) + ⋯ + ∣µ(p )∣λ(1)
α−1 α−2
= ∣µ(1)∣λ(p ) + ∣µ(p)∣λ(p )
α α−1
= (−1) + (−1)
=0
as desired.
217
§6. Liouville Function Masum Billal, Amir Hossein
8
The following theorem is due to Sierpiński and Schinzel.
Theorem 136. Let s be an arbitrary integer. Then, for all integers n > 1 with prime
α α α
factorization n = p1 1 p2 2 ⋯pk k ,
(α +1)s
(−1) i pi i
k α
s +1
∑ λ(d)d = ∏
d∣n i=1
psi + 1
s
Proof. Since both λ(d) and d are completely multiplicative functions, their product is a
s
multiplicative function. We find from Theorem 114 that ∑ λ(d)d is also multiplicative.
d∣n
Therefore, it suffices to prove the theorem for the case when n is a power of a prime.
α
Take n = p for some prime p and positive integer α. Then,
s s s 2 2 s 3 3 s α α s
∑ λ(d)d = λ(1)1 + λ(p)p + λ(p ) (p ) + λ(p ) (p ) + ⋯ + λ(p ) (p )
d∣pα
s s 2s 3s α αs
= 1 − p + p − p + ⋯ + (−1) p
s
This is a geometric progression with initial term 1 and common ratio −p . Therefore,
by the formula for geometric series,
α
s si si
∑ λ(d)d = ∑(−1) p
d∣pα i=0
(−p )
s α+1
−1
= s
−p − 1
α (α+1)s
(−1) p +1
= s
p +1
α α α
Applying this result to n = p1 1 p2 2 ⋯pk k , using multiplicativity of the functions as
discussed,
k
s s
∑ λ(d)d = ∏ ∑ λ(d)d
d∣n i=1 d∣pαi
i
(α +1)s
(−1) i pi i
α
+1
=
psi + 1
as desired.
The previous theorem is pretty strong. The following theorem, which is an example
case of the preceding theorem, is useful and important.
Theorem 137. Let κ be the summatory function of λ. That is, let κ be an arithmetic
function such that
κ(n) = ∑ λ(d)
d∣n
8
Sierpiński and Schinzel, Elementary theory of numbers cit., Chapter §IV, Section 11, Page
196 − 197.
218
§6. Liouville Function Masum Billal, Amir Hossein
Then,
1 if n is a perfect square,
κ(n) = {
0 otherwise.
α α α
Proof. Take s = 0 in Theorem 136. Then, assuming n = p1 1 p2 2 ⋯pk k as the prime
factorization of n,
1 + (−1)
k αi
∑ λ(d) = ∏
2
d∣n i=1
If n is a perfect square, that is, if all the αi (for 1 ≤ i ≤ k) are even, the above product
equals one. Otherwise, at least one of αi is odd and thus 1 + (−1) i = 0, making the
α
n
λ(n) = ∑ µ( )
k2 ∣n
k2
Proof. Assume that κ(n) = ∑ λ(d). Then, by Möbius inversion formula (Theo-
d∣n
rem 110),
n
λ(n) = ∑ µ(d) κ( )
d
d∣n
n
= ∑ κ(d) µ( )
d
d∣n
n
= ∑ µ( )
k2 ∣n
k2
2
because κ(d) is 1 whenever d is a perfect square (i.e., d = k for some k), and zero
otherwise.
9
Laurenţiu Panaitopol
2001 “Some properties of Liouville’s function”, Bulletin mathématique de la Société des Sciences
Mathématiques de Roumanie, Societatea de S, tiint, e Matematice din România, vol. xliv, no. 92, pp. 365-
370, Proposition 2.2.
219
§6. Liouville Function Masum Billal, Amir Hossein
We know by Theorem 137 that κ(k) is 1 if k is a perfect square and 0 otherwise. So,
n √
∑ κ(k) is exactly ⌊ n⌋.
k=1
220
§7. Exercises Masum Billal, Amir Hossein
§7 Exercises
Problem 209. How many integers between a and b are divisible by n? Note that a
and b are not necessarily positive.
Problem 210. Let n be a positive integer. Prove that for any prime p,
∞
n n−1
vp (n) = ∑ (⌊ k
⌋ − ⌊ k ⌋)
k=1
p p
Problem 211. Let n be a positive integer. Show for every prime p that
n ln(n + 1) n−1
− ≤ vp (n!) ≤
p−1 ln p p−1
Problem 212. Let n > 1 be an integer. Prove that (∣µ∣ ∗ 1)(n) = 2 . Here, ∣ ⋅ ∣
n
∑ µ(d)φ(d) = 0
d∣n
Problem 217. Let s be an arbitrary integer. Prove for all integers n > 1 with prime
α α α
factorization n = p1 1 p2 2 ⋯pk k that
k
s s
∑ µ(d)d = ∏(1 − pi )
d∣n i=1
221
§7. Exercises Masum Billal, Amir Hossein
Problem 219. Let m and n be positive integers such that n ≥ 2. Prove that
∑ µ(d)
d∣n
ω(d)≤m
σ(n) = ∑ d
d∣n
n
=∑
d
d∣n
d∣(m,n)
d2
Problem 226. Let p be a prime that generates the even perfect number Ep = 2 (2 −
p−1 p
1). Then Ep is expressible as the sum of the cubes of the first n consecutive positive
(p−1)/2
integers, where n = 2 .
Problem 227. Prove that if existing, an odd perfect number would be of the form
12n + 1.
Problem 228 (Putnam 1976). A positive integer n is called quasi-perfect if σ(n) =
2n + 1. Prove that any quasi-perfect number is the square of an odd integer.
Problem 229 (Romania TST 2014). Show that a positive integer n, which has at
most two distinct prime factors, satisfies the condition σ(n) = 2n − 2 if and only if
n = 2 (2 + 1), where k is a non-negative integer and 2 + 1 is prime.
k k+1 k+1
222
§7. Exercises Masum Billal, Amir Hossein
Problem 230 (IMO Longlist 1979). If n has at most 5 distinct prime divisors, prove
that σ(n) < 77
16
76
n. Also prove that there exists a positive integer n for which σ(n) < 16 n
holds.
Problem 232. For a positive integer n, find the value of the following sum
n/d
∑(−1) φ(d)
d∣n
1 6
∏ (1 − 2
)= 2
p∈P
p π
Problem 237. Let a be an arbitrary integer. Prove that for every positive integer n,
n d
∑ φ( )a ≡ 0 (mod n)
d
d∣n
n(n − 1)
φ(2) + φ(3) + φ(4) + ⋯ + φ(n) ≥ +1
4
223
§7. Exercises Masum Billal, Amir Hossein
φ(n) + σ(n) = 2n
Problem 241. Prove that if σ(n) = 5n than n has more than 5 distinct prime divisors.
Problem 242 (Belarus 2010). Find the greatest real number a such that for all n > 1
the following inequality is true
σ(n) √
≥a n
τ (n)
Problem 243. Show that a positive integer n is prime if and only if σ(n) + φ(n) =
n ⋅ τ (n).
Problem 245 (Cono Sur Shortlist 2012). Find all integers 1 < n < 2012 for which
(p(n)) = σ(n) + 423, where p(n) is the product of all prime divisors of n.
2
Problem 246. Prove that for every positive integer n the following inequality holds
n n
ln k
∑ τ (k) ln k ≤ 2n ⋅ ∑
k=1 k=1
k
Problem 247 (Russia 2011). Show that if σ(n) = 5n/3, then σ(5n) = 10n.
Problem 251. Prove that a positive integer n is prime if and only if φ(n) ∣ n − 1 and
n + 1 ∣ σ(n).
224
§7. Exercises Masum Billal, Amir Hossein
Problem 253 (China TST 2014). Prove that there exist finitely many positive integers
n satisfying the following two conditions:
1. τ (n) = a
2. n ∣ ϕ(n) + σ(n)
Problem 254 (Serbia Additional TST 2012). For every n ∈ N define f (n) as number
of natural numbers m, m ≤ n, for which σ(m) is odd number. Prove that there are
infinitely many natural numbers n, such that f (n) ∣ n.
Problem 255 (Iran Third Round 2009). We call a permutation π on the set An =
{1, 2, ⋯, n} steply constant if the set {π(k)−k∣k = 1, 2, ⋯, n} has exactly two elements.
Prove that the number of steply constant permutations of An is σ(n) − τ (n).
Problem 257 (All Russian Olympiads 2000). A perfect number greater than 28 is
divisible by 7. Prove that it is also divisible by 49.
τ (n)φ(n)σ(n) + 2ω(n)
= φ(n) + ω(n)
φ(n) + σ(n)
Problem 259 (IMS 2008). Find all natural numbers such that
225
CHAPTER IV.
PRIMES
§1 Introduction
Prime numbers just might be the most mysterious topic in mathematics. There are
already countless books on the topic. We have already defined prime numbers in au-
torefch:divisibility. Recall that a positive integer p is a prime if and only if it has exactly
two positive divisors: only 1 and p itself (recall how this lets us deal with the case of 1
automatically). In this chapter, we are going to explore the properties of primes. This PDF was created
for Amazon.
We will start with the infinitude of primes. Besides providing Euclid’s proof of the
theorem, we will show some other proofs. Many of them are not very common these
days. We try to provide precise history such as who the proof should be accredited to
and when etc. As we go on, we will encounter the famous ingenious proof by Erdős,
an elementary proof of Bertrand’s postulate. We will also discuss primality testing and
some relevant theorems. Most of them will be interconnected. But you may be surprised
when you see that we have discussed some things at the end of this chapter which are
not quite Olympiad style topics. We do not give the elementary proof of Prime Number
Theorem by Erdős and Selberg. There was a dispute over the prime number theorem
1
whether Erdős and Selberg would write a joint paper or not. Goldfeld and Baas
2
and Skau are great reads in this regard.
In section (§8), we will discuss how to list primes efficiently or decide whether an
integer is prime or not, and how to factorize an integer quickly. Now, there are a few
points to clear out in the last statement.
is the number of positive divisors of n. Riemann’s Zeta function, also simply called the
Zeta function, is a very important subject of interest and has a long interesting history
behind it. The usage and applications of Zeta function is beyond the scope of this book,
but as it is a very useful tool in inspecting number theory problems, we will introduce
a very simple definition of it. This definition needs precision, otherwise it may lead
to confusing conclusions. Therefore, we will only assume the following definition solely
3
We used this number because long time ago the first author used to think this is a prime.
4
meaning it is turned into a code so others don’t recognize this if they ever see this data containing
your password, so you should understand why it is so important.
5
we are not going to discuss anything in deep since this is not a computer science or cryptography
book, rather just a short note on why you should care about fast prime factorization
6 e e
Sometimes we may denote the canonical prime factorization as p11 ⋯pkk . It’s important to distin-
guish between them.
228
§2. Infinitude Of Primes Masum Billal, Amir Hossein
for the use of this book, and not go into any complex details about the validity of the
definition or similar stuff. And in this text, we do not need any such discussion either.
Riemann’s Zeta Function. Let s be a a real number larger than 1. The Zeta
function of s is defined as
1 1
ζ(s) = s + s +⋯
1 2
1
=∑ s
i≥1
i
It is one of the most well known functions in number theory. Euler defined it first in
1737 but Riemann is known for his works on this function.
§2 Infinitude Of Primes
Euclid first proved that the number of primes is infinite. Here we provide some proofs
of this theorem, including a number theoretic version of Euclid. The idea is pretty
interesting and the same thought works for similar types of problems.
Theorem 140. The number of primes is infinite.
Euclid’s proof. Consider the converse: assume that number of primes is finite. Let
P = {p1 , p2 , . . . , pk } be the set of all primes. Euclid’s idea was to construct a number
which has a prime divisor not in P . Consider the number:
N = p1 p2 ⋯pk + 1
N is not a prime, because it is clearly bigger than all elements of P . So, N is composite
and it has a divisor p in P (because P is the set of all primes). However,
229
§2. Infinitude Of Primes Masum Billal, Amir Hossein
Goldbach’s proof. We are done if we can show that there is a strictly increasing infinite
sequence of positive integers a1 , a2 , a3 . . . so that they are pair-wisely relatively prime.
Since no prime can divide two terms of the sequence, each time a new term appears it
will produce a new prime factor. So, all we have to do is find such a sequence. Onenway
th 2
to do it is using Fermat numbers. The n Fermat number, Fn , is defined as Fn = 2 +1.
In the following lemma, we will show that any two Fermat numbers are relatively prime
to each other.
There are other proofs that use the same idea of relatively prime integers.
(j(n!) + 1, i(n!) + 1) = 1
We also know from proposition (23) that if (a, b) = 1, then (a, bc) = (a, c). Clearly
(n!, i(n!) + 1) = 1 since i(n!) + 1 leaves a remainder of 1 when divided by n!. Therefore,
Since k < n, we also have that k divides n!, so i(n!) + 1 leaves a remainder of 1 when
divided by k too. Finally, we have
From this we can say, the integers i(n!) + 1 for 1 ≤ i ≤ n are relatively prime. And so,
we are done.
230
§2. Infinitude Of Primes Masum Billal, Amir Hossein
Proof by Braun. Assume that primes are finite, and p1 , p2 . . . , pk are all of them. Let
P = p1 p2 ⋯pk and set
1 1 a
(1) p1 + ⋯ + =
pk P
Note that
a 1 1 1
> + +
P 2 3 5
31
= >1
30
So a > P . Obviously, a has a prime divisor p. Since P is the product of all primes, p
must divide P . Let p = pi for some 1 ≤ i ≤ k and rewrite equation (1) to obtain
P P P
(2) a= p +⋯+ p +⋯+ p
1 i k
Obviously, pi ∣ P
pj
for all j ≠ i. On the other hand, p divides a. Equation (2) now forces
pi ∣ P
pi
, which is a contradiction.
Here is a combinatorial proof by Perott, which dates back to almost 1801 − 1900.
1
Perott’s proof. We will use the fact that if a > b then a
< 1b , specially, 1
n+1
< 1
n
for
n ≥ 1. Now
1 1
∑ = 1 + ∑
i≥1
i2 i≥2
i2
1
<1+∑
i≥2
i(i − 1)
1 1
=1+∑ ( − )
i≥2
i−1 i
1 1 1 1 1
= 1 + (1 − ) + ( − ) + ( − ) + ⋯
2 2 3 3 4
=1+1
=2
Therefore,
1
(3) ∑ =2−m
i≥1
i2
for some positive real m. Let’s get to the proof. Like before, we assume there are only
k primes p1 , p2 . . . , pk . Take n = p1 p2 ⋯pk and any integer N > n. Since there are no
primes besides these k, any square-free number must be a divisor of n. Therefore, there
k
are 2 square-free numbers. Let p be a prime. The number of positive integers less than
231
§2. Infinitude Of Primes Masum Billal, Amir Hossein
2 2 2 8
less than or equal to N which are divisible by any of p1 , p2 , . . ., or pk is less than
k
N N N N
⌊ 2
⌋ + ⌊ 2⌋ + ⋯ + ⌊ 2⌋ = ∑⌊ 2⌋
p1 p2 pk i=1 pi
i=1 p2i
k
k N
<2 +∑
i=1 p2i
k
k 1
(4) =2 +N∑
i=1 p2i
Theorem 141.
1 1 p
ζ(1) = 1 + + +⋯=∏
2 3 p−1
p∈P
8
These are actually non-square-free integers up to N .
232
§2. Infinitude Of Primes Masum Billal, Amir Hossein
Proof. Euler investigated the sum (which is known as the Harmonic Series):
1 1 1
S = + +⋯+ n +⋯
1 2
1 1
Consider the sum in terms of prime factorization. Obviously, 1, , 2 , . . . are part of
2 2
1 1 1 1
the series. So are , 2 , . . . and , 2 , . . . and so on. If you understood the fact we
3 3 5 5
1 1 1 1 1 1 1 1 1
showed above, note that ⋅ gives . Similarly, 2 ⋅ = and ⋅ = and so on.
2 3 6 2 3 12 3 5 15
We know that any number can be written as a product of primes in a unique
way. Therefore, when we are multiplying some powers of primes, we will get a unique
number. In other words, the same number won’t appear twice. As an example, notice
the following sum:
1 1 1 1
S1 = (1 + + 2 + ⋯) ⋅ (1 + + 2 + ⋯)
2 2 3 3
1 1 1 1 1 1 1 1
=1+ + 2 + + + 2 + 2+ + 2 2 +⋯
2 2 3 2⋅3 2 ⋅3 3 2⋅3 2
2 ⋅3
1 1 1 1 1 1 1 1
=1+ + + + + + + + + ...
2 4 3 6 12 9 18 36
Unique prime factorization guarantees that none of 2, 4, 6 or 18 will appear anywhere
i j
in the series again. That is, any number of the form 2 3 will appear exactly in this
i j k
series. Similarly, if we considered all the numbers generated by 2 3 5 , we would have
numbers like 30, 60 or 90 exactly once in the series. So, going this way, we can see that
1 1
the sum S is nothing but the product of sums 1 + p + 2 + ⋯ for all primes p. So
p
1 1 1
S =1+ + + +⋯
2 3 4
1 1 1 1
= (1 + + 2 + ⋯) ⋅ (1 + + 2 + ⋯)⋯
2 2 3 3
1 1
(5) = ∏ (1 + p + 2 + ⋯)
p∈P
p
where P is the set of all primes. Back in high school, we learnt that the infinite geometric
2
series 1 + r + r + ⋯ where the ratio r has absolute value less than 1, has a finite sum
1 1
. Here, r = p < 1, and hence
1−r
1 1 1
1+ p + 2 +⋯=
p 1 − p1
p
=
p−1
Replacing this in equation (5), we get the desired result
1 1
S =1+ + +⋯
2 3
p
=∏
p−1
p∈P
233
§2. Infinitude Of Primes Masum Billal, Amir Hossein
Euler found a general result for ζ(s) for any positive integer s. We have stated this
result in the following theorem. The proof is analogous to the proof of the previous
theorem.
1 1
ζ(s) = 1 + s + s +⋯
2 3
s
p
=∏ s
p −1
p∈P
1 1
Theorem 143. The series S = 1 + + + ⋯ diverges, i.e., it does not have a finite
2 3
sum.
1 1 1 1 1 1 1 1
S= + + ( + )+ ( + + + )+⋯
1 2 3 4 5 6 7 8
1 1 1 1 1 1 1 1
> + + ( + )+ ( + + + )+⋯
1 2 4 4 8 8 8 8
1 1 1 1
=1+ + + + +⋯
2 2 2 2
=1+1+⋯
You may think that ζ(2), ζ(3), . . . all diverge too. Wrong! Using calculus Euler also
proved the following theorem:
2
π
Theorem 144 (Euler). ζ(2) = 6
. In other words,
2
1 1 π
1+ 2 + 2 +⋯=
2 3 6
We are now ready to prove the infinitude of primes using Zeta function.
Proof using Zeta Function. In Theorem 143, it is already proved that S is infinite. A
series diverges if it has an infinite sum. If the number of primes is finite, then the
p
product of all would be finite too. But it gives us a contradiction. Thus, the
p−1
number of primes must be infinite.
We provide yet another proof due to Euler. The proof was published after his death.
The proof uses multiplicative property of Euler’s Totient function.
234
§2. Infinitude Of Primes Masum Billal, Amir Hossein
Proof using Euler function. Let P be the product of all primes (since they are finite,
P is finite too). Assume that the primes are p1 , p2 , . . . , pk and they are sorted, i.e.,
2 = p1 < 3 = p1 < ⋯. Then P = p1 ⋅ p2 ⋯pk and P is square-free as well. Using the
formula of Euler function,
φ(P ) = (p1 − 1) ⋅ (p2 − 1)⋯(pk − 1)
≥ 1 ⋅ 2⋯2
k−1
≥2
≥2
if k > 1. Since 2, 3 are primes, evidently, k ≥ 2. So the last line holds true. This implies
that φ(P ) is at least 2, and there are at least two positive integers less than or equal to
P which are relatively prime to P . If we discard 1, there is at least one other positive
integer which is relatively prime to P . That positive integer must have another prime
divisor which does not divide P . Now the claim follows.
In the previous discussion, we have shown that there are infinitely many primes in
several different ways.
Theorem 145. There are infinitely many primes of the form 4m + 3.
Proof. We proceed the same way as Euclid did. Let p1 , p2 , . . . , pk be all the primes of
the form 4m + 3. Consider the number N = 4p1 p2 ⋯pk − 1. Clearly, N ≡ 3 (mod 4).
According to Theorem 21 in autorefch:divisibility, N has at least one prime factor p
which is of the form 4m + 3. This prime p divides N , so it is relatively prime to
N − 1 = 4p1 p2 ⋯pk , which means that p is none of those p1 , p2 , . . . , pk . Therefore,
another prime p of the form 4m + 3 exists. This is a contradiction. So, the number of
such primes is infinite.
Theorem 146. There are infinitely many primes of the form 4n + 1.
Proof. Let’s say the number of primes of this form is finite. Call these primes p1 , p2 , . . . , pk .
2 2
Consider the number N = 4p1 ⋯pk + 1. Using corollary (17), we get that every divisor
of N is of the form 4t + 1. Thus, a prime divisor p of N must be of the same form. The
contradiction follows.
Theorem 147. Let p be a prime. There are infinitely many primes of the form pn + 1.
Proof. The theorem is obvious for p = 2 since all primes are odd. Assume that p is
odd. Let us rephrase the theorem: for each prime p, there are infinitely many primes q
such that q ≡ 1 mod p. pLet X ≥ 2 be an integer. We know from Theorem 75 that any
prime divisor q ≠ p of XX−1
−1
is either p or 1 (mod p).
For the sake of argument, suppose that q1 , q2 , . . . , qn are the only primes which are
1 mod p. Set X = pq1 q2 ⋯qn and consider the number
p
X −1
N=
X −1
(pq1 q2 ⋯qn ) − 1
p
=
pq1 q2 ⋯qn − 1
N is an integer which is not divisible by any of the qi or p and is greater than 1. So N
has a prime divisor, say r. This r must be congruent to 1 modulo p. Contradiction!
235
§3. Number of Primes Masum Billal, Amir Hossein
Theorem 148. let p > 2 is a prime, then there are infinitely many primes q such that
q is a quadratic residue modulo p.
Proof. According to previous theorem, there are infinitely many primes q such that
q ≡ 1 (mod p). So, all these primes are quadratic residues modulo p and we are
done.
You might have already conjectured that there are infinitely many primes of the
form an + 1. Even more generally an + b, where a and b are relatively prime positive
integers. And luckily, this is true and Dirichlet was the first one to prove it. Though
the proof of this theorem is way beyond the scope of this book. It is even accepted
in many mathematics competitions. You should still try to avoid using it. Use it only
if you find no other way. For most of the problems, there is a solution to that does
not require a high level theorem like this. Readers are highly encouraged to try for a
different solution even if it makes their lives a lot harder.
Theorem 149 (Dirichlet’s Theorem on Arithmetic Progressions). If a and b are two
relatively prime positive integers, then there are infinitely many primes the arithmetic
progression
a + b, 2a + b, 3a + b, ⋯
In other words, there are infinitely many primes of the form an + b.
§3 Number of Primes
Mathematicians have been trying to find a closed form for primes for a long time. But
this was such a mystery that many mathematicians thought it is not possible to find
a formula for primes. You may have thought so too! Whenever someone tries to find
a formula for primes, they tend to go for polynomials first. Our sympathies for them.
Because the following theorem tells us that we can not find a non-constant polynomial
which will always output a prime (for positive integer inputs of course).
Theorem 150. There is no non-constant polynomial P (x) with integer coefficients
such that P (n) is a prime for all integers n.
Proof. Let P be a polynomial that generates only primes. Then P (0) = p for some
prime p. That is, P (x) looks like
n n−1
P (x) = an x + an−1 x + ⋯ + a1 x + p
Put x = kp in the above equation. We find that p ∣ P (kp) for all integers k. However,
since P (kp) is a prime, we must have P (kp) = p for all integers k. Now consider the
polynomial Q(x) = P (px) − p. All integers are roots of Q(x), which is impossible
unless Q(x) is the zero polynomial. So P (px) = p for all real numbers x. Hence, P (x)
is constant.
236
§3. Number of Primes Masum Billal, Amir Hossein
Theorem 151. The number of primes less than or equal to n can be obtained as
⎢
⎢ ⎥
⎥
⎢
⎢ ⎥
⎥
n⎢
⎢ ⎥
⎥
⎢
⎢ 2 ⎥
⎥
π(n) = ∑ ⎢ ⎢ ⎥
⎥
⎢
⎢
i=2 ⎢ ∑
i i − 1 ⎥
⎥
⎢
i
⌊ ⌋ ⌊ ⌋ ⎥
⎥
⎢
⎣
j=1 j −
j ⎥
⎦
Don’t frown just because it looks ugly! It is actually very simple. Let us slowly
proceed how we can get to this expression.
Proof. First idea: assume f (i) = 1 if i is prime, otherwise 0. Then we will have
n
π(n) = ∑ f (i)
i=2
This is pretty obvious. Each time we get a prime we are just adding 1 to the sum.
All we have to do is find a good expression for f (i) that is computable in terms of i.
Remember that a prime has exactly 2 divisors. And any positive integer greater than
1 has at least two divisors. Therefore, if τ (i) is the number of divisors of i, τ (i) ≥ 2 for
i > 1. This gives us ⌊2/τ (i)⌋ = 0 if i is composite, otherwise 1. Since for composite i,
τ (i) > 2. Now, the formula for f (i) becomes
2
f (i) = ⌊ ⌋
τ (i)
But this is still not computable in terms of i. We employ the same idea again, we add
1 to τ (n) each time we get a divisor of n. How do we do that? Assume that if i is a
divisor of n then tn (i) = 1, otherwise 0. Then,
n
τ (n) = ∑ tn (i)
i=1
Finding tn (i) can be easy. For i < n, we need to add 0 when i doesn’t divide n,
otherwise 1. Assume that n = ik + r with r < i and n − 1 = il + s with s < i. If i divides
n then r = 0 and we would have that n − 1 = il + s = ik − 1. Thus, ik − il = s + 1
with s + 1 ≤ i. But i(k − l) = s + 1 gives us s + 1 ≥ i since i ∣ s + 1 and s + 1 is a
positive integer, k > l (why?). This forces s + 1 = i and k − l = 1. The nicer news is
that k − l = 1. And if i didn’t divide n, we would have k = l (prove it) or k − l = 0.
Okay, that’s good news. We have found our characteristic function tn (i). What is the
meaning of k and l in terms of i and n? k = ⌊n/i⌋ and l = ⌊(n − 1)/i⌋, so we get
n n−1
tn (i) = ⌊ ⌋ − ⌊ ⌋
i i
237
§3. Number of Primes Masum Billal, Amir Hossein
Have you ever thought about finding the number of primes not exceeding n yourself?
This is actually a very intriguing question for most of the people interested in number
theory, even for curious school students. At first it seems impossible to find a closed
form in such a case. However, as you think more, you can find different ways to proceed.
The above one is an example. This should enable you to find one as well. Here is another
example, and you may be surprised at this approach. In fact, we have used it before
when we tried to find the number of relatively prime integers less than or equal to n.
The idea is similar, in a sense that it is recursive in a way. Since it is troublesome to
directly find the number of primes, we will do exactly the opposite. We will find the
number of non-primes not exceeding n. Then we can just subtract it from n. Now,
we intend to find the number of positive integers m such that m = ab with a, b > 1.
√
More specifically, we can say that the smallest prime divisor does not exceed n (recall
√
this from autorefch:divisibility). Let p1 , p2 , . . . , pk be the primes not exceeding n in
√
increasing order. That is, pk is the largest prime less than or equal to n (this is why
we said this approach is recursive). Any composite positive integer not exceeding n
must have a prime divisor from this set {p1 , p2 , . . . , pk }.
Again, this is a repetitive problem we encountered before. How many positive
integers not exceeding n are divisible by p1 ? The number is ⌊n/p1 ⌋. The same goes for
p2 , . . . , pk . So, the total number of non-prime positive integers should be
n n
⌊p ⌋ + ⌊p ⌋ + ⋯
1 2
However, the positive integers that are multiple of both p1 and p2 were counted twice
in this sum. So, we need to subtract them. Now it becomes
n n n n
⌊ p ⌋ + ⌊ p ⌋ + ⋯ − ⌊ p p ⌋ − ⌊ p p ⌋ − ⋯ all possible pairs
1 2 1 2 1 3
Again, when we subtracted them all, the multiples of p1 p2 p3 or p3 p4 pk all vanished from
the calculation. To rectify that mistake, we need to add the number of multiples of
three primes (all possible combinations of course). Now it looks like
n n n n n n
⌊p ⌋ + ⌊p ⌋ + ⋯ − ⌊p p ⌋ − ⌊p p ⌋ − ⋯ + ⌊p p p ⌋ + ⌊p p p ⌋ + ⋯
1 2 1 2 1 3 1 2 3 1 3 4
Going this way, we see that, if the number of primes taken into account is even, we add
it, subtract otherwise. Hence, we get the following theorem.
Theorem 152. Let n be a positive integer and p1 , p2 , . . . , pk be the primes less than or
√ √
equal to n. If the number of primes not exceeding n is π(n), then π(n) − π( n) + 1 is
n n n n n k n
(6) n − ⌊ p ⌋ − ⌊ p ⌋ − ⌊ p ⌋ + ⋯ + ⌊ p p ⌋ + ⌊ p p ⌋ + ⋯ + (−1) ⌊ p p ⋯p ⌋
1 2 3 1 2 1 3 1 2 k
In other words, and more generally, if π(x) for any positive real x ≥ 2 is the number
of primes not exceeding x, then,
√ x x x
(7) π(x) − π( x) + 1 = ⌊x⌋ − ∑ ⌊ p ⌋ + ∑ ⌊ p p ⌋ − ∑ ⌊p p p ⌋ + ⋯
i i j i j k
pi pi <pj pi <pj <pk
√
where the sums are taken over all primes less than or equal to x.
238
§4. Bertrand’s Postulate and Erdős’s Proof Masum Billal, Amir Hossein
√
Notice that there is a π( n) here. Because when we used primes less than or equal
√ √
to n, we missed all the primes that are below n. So we should subtract the number
√ √
of primes less than n, which is π( n) − 1. Let us discuss this a bit further. We claim
that
√ P
n
(8) π(n) − π( n) + 1 = ∑ µ(i)⌊ ⌋
i=1
i
where P = p1 p2 ⋯pk . This is probably not obvious to you, so we explain how the above
9
fomula is obtained . It is now a very good time to mention a point the importance of
the Möbius µ function defined in defintion (§3). We stated in the previous chapter that
Möbius comes handy when dealing with inclusion–exclusion arguments. Here, we have
a nice one. We will investigate equation (8) term by term. The first term is n, obtained
from i = 1. For i = pj , the contribution is µ(pj )⌊n/pj ⌋ = −⌊n/pj ⌋ (here, 1 ≤ j ≤ k).
That’s exactly the first group of terms in equation (6). But what about the case when i
is not a prime? Well, if it’s a square-free number, i.e., if it is of the form i = pi1 pi2 ⋯pis ,
where {i1 , i2 , . . . , is } ⊆ {1, 2, . . . , k}, then, we get a contribution of
n n
µ(pi1 pi2 ⋯pis )⌊ p p ⋯p ⌋ = (−1) ⌊ p p ⋯p ⌋
s
i 1 i2 is i1 i2 is
Bertrand’s postulate is a very nice and influential theorem in number theory. Joseph
Bertrand first conjectured it, but he couldn’t prove it entirely. Later, Chebyshev proved
10
it, using analytic number theory tools. Ramanujan et al. proved it using properties
of Gamma function, which is beyond the scope of this book. The first elementary proof
11
of this theorem was given by Erdős. It was the first paper he published! We will
show that proof here.
There are many formulations of this theorem. All of them are equivalent.
9
Thanks to Amin Soofiani for reminding us to add some more explanation here.
10
Srinivasa Ramanujan et al.
2013 “Ramanujan’s Proof of Bertrand’s Postulate”, The American Mathematical Monthly, vol. cxx, no. 7,
p. 650, doi: 10.4169/amer.math.monthly.120.07.650.
11
Paul Erdős
1932 “Beweis eines Satzes von Tschebyschef”, Acta Litt. Sci. Szeged, vol. v, pp. 194-198.
239
§4. Bertrand’s Postulate and Erdős’s Proof Masum Billal, Amir Hossein
Theorem 153 (Bertrand’s Postulate). For all integers n > 1, there is a prime p so
that n < p < 2n. The following are equivalent formulation.
th
• Let pn denote the n prime number, starting from p1 = 2. Then
pn+1 < 2pn
2n 2n 2n 2n
(1 + 1) = 1 + ( 1 ) + ⋯ + ( n ) + ⋯ + (2n)
2n 2n
2 ≤ (2n + 1)( n )
=2−2⋅1
=0
240
§4. Bertrand’s Postulate and Erdős’s Proof Masum Billal, Amir Hossein
Lemma 13. Let n be a positive integer. Let p be any prime divisor of N = (2n
n
). Then
vp (N )
p ≤ 2n.
α α+1
Proof. Let α be the positive integer for which p ≤ 2n < p . Then using theorem
Theorem 9 of chapter (III),
α α
2n n
vp (N ) = vp ((2n)!) − 2vp (n!) = ∑ ⌊ ⌋ − 2 ∑ ⌊ ⌋
i=1
pi i=1
p i
α
2n n
= ∑ (⌊ i
⌋ − 2⌊ i ⌋)
i=1
p p
α
≤ ∑1
i=1
=α
vp (N )
The last line is true because for a rational x, ⌊2x⌋ − 2⌊x⌋ ∈ {0, 1}. Therefore, p ≤
α
p ≤ 2n.
Lemma 14. Let n be a positive integer. Any prime p with n + 2 ≤ p ≤ 2n + 1 divides
(2n+1
n
).
Proof. Since p > n + 1,
2n + 1 (2n + 1)!
νp (( n )) = vp ( (n!)(n + 1)! )
= vp ((2n + 1)!) − vp (n!) − vp ((n + 1)!)
=1
2n + 1 2n
( n )≤2
2n+1 2n + 1 2n + 1 2n + 1 2n + 1
(1 + 1) =1+( 1 ) + ⋯ + ( n ) + ( n+1 ) + ⋯ + ( 2n + 1)
2n + 1 2n + 1
≥( n )+(n+1)
2n + 1
= 2( n )
241
§4. Bertrand’s Postulate and Erdős’s Proof Masum Billal, Amir Hossein
The following lemma is really a nice one, and the proof requires a good insight.
Lemma 16. The product of all primes less than or equal to n is less than or equal to
n
4 .
Proof. We will use induction. The proof is trivial for n = 1 and n = 2. Assume it is
true for all positive integers up to n − 1. We will show that it is also true for n.
If n is even and greater than 2, n is definitely not a prime. Thus,
n−1 n
∏p = ∏ p ≤ 4 <4
p≤n p≤n−1
∏p = ∏ p
p≤n p≤2m+1
= ( ∏ p) ( ∏ p)
p≤m+1 m+2≤p≤2m+1
m+1
By induction hypothesis, the first product, ∏ p, is less than or equal to 4 . From
p≤m+1
lemma 14, we know that any prime p such that m + 2 ≤ p ≤ 2m + 1 divides (2m+1
m
).
Therefore, the second product, ∏ p, is less than or equal to (2m+1
m
). Combining
m+2≤p≤2m+1
these results with lemma 15, we get
m+1 2m + 1
∏p ≤ 4 ( m )
p≤n
m+1 2m
≤4 2
2m+1
=4
n
=4
242
§4. Bertrand’s Postulate and Erdős’s Proof Masum Billal, Amir Hossein
√
• Consider all prime divisors of N which are larger than 2n. Let q1 , q2 , . . . , qm be
vq (N )
such primes. Again,√by lemma 13, we must have qi i ≤ 2n (where 1 ≤ i ≤ m).
However, since qi > 2n, we find that vqi (N ) = 1 for all i.
Now, by our hypothesis, there are no primes p such that n < p ≤ 2n. On the other
hand, lemma 12 says that√there are no prime divisors of N such that 2n/3 < p ≤ n.
Altogether, we find that 2n < qi ≤ 2n/3 for 1 ≤ i ≤ m. Hence,
m m
vqi (N )
∏ qi = ∏ qi
i=1 i=1
= ∏ p
√
2n<p≤2n/3
p∣N
k m
vpi (N ) vqi (N )
We now use the fact that N = ∏ pi ⋅ ∏ qi , where pi and qi are as defined
i=1 i=1
above. According to what we have found,
k m
vp (N ) vqi (N )
N= ∏ pi i ⋅ ∏ qi
i=1 i=1
√
2n
≤ (2n) ⋅ ∏ p
√
2n<p≤2n/3
p∣N
√
2n
≤ (2n) ⋅ ∏ p
p≤2n/3
√
2n 2n/3
≤ (2n) ⋅4
Note that we have used lemma 16 for writing the last line.
Combining this with the result of lemma 11, we see that
n √
4 2n 2n/3
≤ (2n) ⋅4
2n + 1
However, this inequality can hold only for small values of n. Actually, one can check
that the inequality fails for n ≥ 468. For n < 468, one can check that
is a sequence of primes, each term of which is less than twice the term preceding it.
Therefore, any interval {n + 1, n + 2, . . . , 2n} with n < 468 contains one of the primes
in this sequence.
Hence, we have reached the contradiction we were looking for. This means that
there always exist a prime p such that n < p ≤ 2n for any positive integer n. The proof
is complete.
Theorem 154. For any positive integer n, the set S = {1, 2, . . . , 2n} can be partitioned
into n pairs (ai , bi ) so that ai + bi is a prime.
243
§4. Bertrand’s Postulate and Erdős’s Proof Masum Billal, Amir Hossein
Before we show the proof, readers are highly encouraged to prove it themselves.
This is the kind of theorem that shows how good human thinking can be.
Proof. We will proceed by induction. The theorem is clearly true for n = 1 since
1 + 2 = 3, a prime. Assume that the theorem is true for all k < n and we can split the
set {1, 2, . . . , 2k} into pairs with a prime sum. By Bertrand’s postulate, there is a prime
p with 2n < p < 4n. Let p = 2n + m, where m must be odd since p is odd. Consider the
set {m, m + 1, . . . , 2n}. It has an even number of elements. Also, we can make pairs of
(m, 2n), (m + 1, 2n − 1), . . . with sum p, which is a prime. Now we only have to prove
that the set {1, 2, . . . , m − 1} can be paired into elements with a prime sum. This is
true by induction hypothesis because m − 1 < 2n. The proof is complete.
Problem 260. Let n > 5 be an integer and let p1 , p2 , . . . , pk be all the primes smaller
than n. Show that p1 + p2 + ⋯ + pk > n.
k
Solution. We first show by induction that ∑i=1 pi > pk+1 for k ≥ 3. The base case,
k
k = 3 is true because 2 + 3 + 5 > 7. Assume that ∑i=1 pi > pk+1 , then by the first
alternative form of Bertrand’s postulate stated in theorem Theorem 153,
k+1 k
∑ pi = pk+1 + ∑ pi
i=1 i=1
> 2pk+1
> pk+2
k
∑ pi > pk+1 ≥ n
i=1
Problem 261 (China 2015). Determine all integers k such that there exists infinitely
many positive integers n satisfying
2n
n+k ∤(n)
Solution. We will show that the problem statement holds for all integers k ≠ 1. Note
that for k = 1, we have
2n 2n 1 2n
( n ) − (n + 1) = ( )
n+1 n
244
§4. Bertrand’s Postulate and Erdős’s Proof Masum Billal, Amir Hossein
2n
vp (( n )) = vp ((2n)!) − 2vp ((n!))
2n − sp (2n) n − sp (n)
= −2⋅
p−1 p−1
2sp (n) − sp (2n)
=
p−1
2sp (n) (try to write the base p representation of n and 2n to see why). Consequently,
vp ((2n
n
)) = 0. However, p ∣ n + k, so we have n + k ∤ (2n n
) for infinitely many n, as
desired.
For negative k, one can choose n = −k + p for an odd prime p > ∣2k∣ (which exists
m
by Bertrand’s postulate) and any positive integer m. In a similar manner as above, one
obtains vp ((2n
n
)) = 0, but p ∣ n + k. Consequently, n + k ∤ (2n
n
). The proof is complete.
After the theorem was proved, number theorists tried to tighten the interval. Also,
a question was raised regarding the general case.
Problem 262. Let c be a real number. What is the minimum value of c such that,
there is always a prime between n and n + cn for positive integers n > 1?
12
Nagura proved the case for c = 1/5.
Theorem 155 (Nagura). For x ≥ 25, there is always a prime number between x and
6x/5.
The proof uses a property of gamma function (a function involving the gamma
function turns out to be a prime counting function). We will not be proving the
improvements or generalizations, but they are worth mentioning. The general case of
this theorem would be like this:
Problem 263. Let k be a positive integer. Does there always exist a prime between
kn and (k + 1)n?
13
Bachraoui proved the case k = 2. The idea is an extension of Erdős’s proof.
Theorem 156 (Bachraoui). For a positive integer n > 1, there is always a prime in
the interval [2n, 3n].
12
Jitsuro Nagura
1952 “On the interval containing at least one prime number”, Proceedings of the Japan Academy,
vol. xxviii, no. 4, pp. 177-181, doi: 10.3792/pja/1195570997.
13
Mohamed El Bachraoui
2006 “Primes in the interval [2n, 3n]”, International Journal of Contemporary Mathematical Sciences,
pp. 617-621, doi: 10.12988/ijcms.2006.06065.
245
§5. Miscellaneous Masum Billal, Amir Hossein
14
Loo proved the case for k = 3 without using prime number theorem or any deep
analytical method.
Theorem 157 (Loo). For a positive integer n ≥ 2, there is always a prime in the
interval (3n, 4n).
15
C. et al. proves the following theorem.
Theorem 158. The list of integers k for which every interval (kn, (k + 1)n) contains
a prime for n > 1 is {1, 2, 3, 5, 9, 14} and no others, at least for k ≤ 10 .
9
Theorem 159 (Mitra’s conjecture). Assume the general Bertrand’s postulate. There
exists at least two primes in the interval [n , (n + 1) ].
2 2
Theorem 160 (Brocard’s conjecture). Assume the general Bertrand’s postulate. For
each n > 1, there are at least 4 primes in the interval [pn , pn+1 ].
2 2
Theorem 161 (Andrica’s conjecture). Assume the general Bertrand’s postulate holds
√ √
true. For any positive integer n, pn+1 − pn < 1.
There are still many open questions left regarding prime numbers. We will describe
some later. You don’t have to necessarily find an answer to them, just try them! You
may learn something new by yourself, or even find new theorems. In many cases,
mathematicians develop theories this way.
§5 Miscellaneous
Theorem 162. For any positive integer n, there are n consecutive integers none of
which are prime. In other words, there are arbitrarily large gaps in the sequence of
primes.
Proof. Let’s just look at the numbers (n + 1)! + 2, . . . , (n + 1)! + n + 1. These are
(n + 1) − (2) + 1 = n consecutive integers and none of them are prime since (n + 1)! + i
is divisible by i for 1 < i < n + 2.
14
Andy Loo
2011 “On the Primes in the Interval [3n, 4n]”, International Journal of Contemporary Mathematical
Sciences, vol. vi, no. 38, http://www.m- hikari.com/ijcms- 2011/37- 40- 2011/looIJCMS37- 40-
2011.pdf.
15
Peter Moses J. C. et al.
2013 “On Intervals (kn, (k + 1)n) Containing a Prime for All n ≥ 1”, Journal of Integer Sequences, 13.7.3,
vol. xvi, no. 7.
246
§5. Miscellaneous Masum Billal, Amir Hossein
Theorem 163. For any positive integer n, there are n consecutive integers so that none
of them are prime powers (not necessarily the power of same prime).
Proof. We will use Chinese Remainder Theorem to proceed. But how do we understand
we need CRT here? A basic idea is to show that n consecutive integers have at least two
different prime factors. That way, we can guarantee none of them is a prime power. So
we need x to be divisible by p1 p2 , x+1 to be divisible by p3 p4 and likewise, x+(n−1) to
be divisible by p2n−1 p2n . In other words, we need a solution to the system of congruences
x ≡ 0 (mod p1 p2 )
x ≡ −1 (mod p3 p4 )
..
.
x ≡ −(n − 1) (mod p2n−1 p2n )
−a ≡ −ade ≡ id (mod p)
Note that i < p < n. Thus p ∣ a + id for some i < n. This now gives p ∣ a + (p − i)d
and p ∣ a + (i − p)d. It is clear that either 0 < p − i < n or 0 < i − p < n. In either case,
p divides two terms of the sequence. Since all terms of the sequence are primes, those
two terms which are divisible by p must equal p. But this is a contradiction since the
sequence is strictly increasing. Hence, p must divide d.
Remark . The sequence a, a+d, a+2d, . . . is called an arithmetic sequence or arithmetic
th
progression (and briefly, AP) with initial term a and common difference d. The n term
of the sequence is a + (n − 1)d. The above theorem shows that if all terms of an AP
with n terms and common difference d are primes, then d is divisible by any prime less
than d.
16
We are going to explain and prove some inequalities about primes. Bonse found
and proved the following two theorems:
Theorem 165. For n ≥ 4,
2
p1 ⋯pn > pn+1
16
H. Bonse
1907 “Über eine bekannte Eigenschaft der Zahl 30 und ihre Verallgemeinerung”, Archiv der Mathematik
und Physik, vol. iii, no. 12, pp. 292-295.
247
§5. Miscellaneous Masum Billal, Amir Hossein
n−1
Lemma 18. For n ≥ 1, p1 ⋯pn > 2 n!.
Proof. Check the truth for n = 1, 2, 3, and 4. Note that p1 p2 p3 p4 = 2 ⋅ 3 ⋅ 5 ⋅ 7 = 210.
From lemma (17), pi > 2i for i ≥ 5. Thus
n n n
∏i=1 2i
∏ pi > ∏ 2i > 4
i=5 i=5 ∏i=1 2i
n
2 ⋅ n!
= 4
2 ⋅ 4!
n−7 n!
=2 ⋅
3
Now, we have
n
p1 ⋯pn = p1 p2 p3 p4 ⋅ ∏ pi
i=5
n−7 n!
> 210 ⋅ 2
3
n−6
= 35 ⋅ 2 n!
n−6
> 32 ⋅ 2 n!
n−1
=2 n!
17
Lajos Pósa
1960 “Über eine Eigenschaft der Primzahlen”, Mat. Lapok, vol. xi, pp. 124-129.
248
§5. Miscellaneous Masum Billal, Amir Hossein
√
n!
n
Lemma 19. The sequence un = , for n = 1, 2, . . ., is strictly increasing.
2
√ √
n n! n+1 (n + 1)!
Proof. We are done if we can prove < , which is equivalent to
2 2
n! n+1 (n + 1)! n
( ) < ( )
2 2
Simplifying, we find
n n n
(n!) n! < 2(n!) (n + 1)
n
or n! < 2(n + 1) , which is evident!
n
Lemma 20. For all positive integers n, pn ≤ 2 . Equality occurs if and only if n = 1,
n
otherwise pn < 2 .
1 2
Proof. If n = 1, p1 = 2 = 2 . We know that p2 = 3 < 2 . Thus we induct on n using
the first alternative of Bertrand’s postulate stated in Theorem 153. Let’s assume that
n n+1
pn < 2 . Since p is odd, we have pn+1 < 2pn < 2 .
We are ready to prove Pósa’s theorem.
Proof of Pósa’s Theorem. The case k ≤ 0 is trivially true. So we focus on k > 0.
k (n+1)k
Note that using lemma (20), we find pn+1 < 2 . So we need to show that
(n+1)k
p1 ⋯pn > 2
n−1
On the other hand, using lemma (18), we have p1 ⋯pn > 2 n!, we are done if we can
prove that there is a n0 so that
n−1 (n+1)k
2 n! > 2
249
§6. Miscellaneous Masum Billal, Amir Hossein
Theorem 168. The probability of two random positive integers being relatively prime
6
is 2 .
π
Proof. Two positive integers are relatively prime if they do not share any prime divisor.
So we can do just the opposite. We will find out the probability of them not being
relatively prime. Fix a prime p. What is the probability that both a and b are divisible
by p? Think on this for a bit.
Let us focus on what a and b leave as remainders when divided by p. There can be p
remainders (0, 1, . . . , p − 1). Both for a and b, there are p possibilities. The probability
that a leaves remainder 0 when divided by p is p1 . Similarly, the probability that b leaves
1 18
remainder 0 when divided by p is p
as well. Therefore , both a and b leave remainder
1
0 when divided by p is p
⋅ p1 . Thus, the probability of a and b not being divisible by p is
1 − p12 . Now, this is only for a fixed prime p. Since p can be any prime, the probability
should be multiplied for all primes. The probability is
1 1 1
(1 − 2
) ⋅ (1 − 2 )⋯ = ∏ (1 − 2 )
p1 p2 i≥1 pi
2
pi − 1
=∏ ( )
i≥1 p2i
1
=∏
p2i
i≥1
p2i −1
1
= 2
p
∏i≥1 ( 2 i )
pi − 1
1
=
ζ(2)
6
= 2
π
In the last line, we used Theorem 144.
19
An improvement on this result is given by Panaitopol.
250
§6. Distribution of Prime Numbers Masum Billal, Amir Hossein
Distribution of prime numbers is the topic which encouraged number theorist to start
a new branch called Analytic Number Theory. We have in fact discussed a little bit
about distribution of prime numbers already when we proved Bertrand’s theorem. Let
us focus on it a bit more.
There are 4 primes less than 10, 25 primes less than 100, 168 less than 1000 and so
on. And finding a formula for the number of primes less than n has always fascinated
mathematicians. Well, Gauss did not exactly provide a formula for the number of
n
primes, but he noticed that the value of and the number primes less than n, π(n),
ln n
gets closer as n tends to infinity. This gave birth to the Prime Number Theorem or PNT,
conjectured by Gauss. It was unproven for about 100 years. Then Chebyshev provided
a partial proof using his functions (which were later known as, Chebyshev function of
type 1 and 2), and that was only the start of analytical number theory. There is a huge
underlying significance here. Gauss did not conjecture any exact formula for π(n). But
since he was unable to provide one, he estimated instead. Analytical number theory
does not provide exact formulas like elementary number theory, rather it shows some
estimation, and mathematicians tend to prove the estimates or improve them. This is
because, most of the times providing exact formulas for the functions are either very
hard or not so pretty. For example, one can find an exact formula for finding the nth
prime number, but one will not like it.
We will start with some functions and analyzing their properties. The obvious
question is, why do mathematicians define such functions? In this case, why are these
functions and their properties important? The reason is simple. If you can not under-
stand primes directly, understand some functions that can characterize them or tell us
something about them, some function that we can analyze. At first, they can be intim-
idating. So, we will try to show examples in order to make sense why these functions
have something to do with primes.
ϑ(x) = ∑ ln p
p≤x
where the sum extends over all primes p less than or equal to x.
Example. Take x = 142.61. The primes less than x are 2, 3, 5, . . . , 137, 139. So
251
§6. Distribution of Prime Numbers Masum Billal, Amir Hossein
Lemma 21. Let k and n be positive integers such that k < n < 2k + 1. Then
n
(k ) ≥ ∏ p
k<p≤n
n − k < k + 1 ≤ pi ≤ n
n p1 p2 ⋯pm ⋅ s
(k ) =
(n − k)!
s
= p1 p2 ⋯pm ⋅
(n − k)!
≥ p1 p2 ⋯pm
= ∏ p
k<p≤n
as claimed.
(10) ϑ(x) ≤ 2x ln 2
Proof. We induct on ⌊x⌋. For our base cases, we note that for 0 ≤ x < 2, we have
ϑ(x) = 0 ≤ 2x ln 2.
252
§6. Distribution of Prime Numbers Masum Billal, Amir Hossein
Now suppose that x ≥ 2. Let n = ⌊x⌋ and suppose that the inequality holds for all
reals y such that ⌊y⌋ < n. Note that
x n
2 ≥2
n
= (1 + 1)
n n n n n
= ( 0 ) + ( 1 ) + ⋯ + ( n ) + ⋯ + (n − 1) + (n)
⌊2⌋
n
≥( )
⌊ n2 ⌋
≥ ∏ p
⌊n
2
⌋<p≤n
where we have used lemma (21) to write the last line. Taking logarithms from the
above inequality, we find
x ln 2 ≥ ∑ ln p
⌊n/2⌋<p≤n
x
= ϑ(x) − ϑ(⌊ ⌋)
2
n
≥ ϑ(x) − 2⌊ ⌋ ln 2
2
≥ ϑ(x) − x ln 2
2x ln 2 ≥ ϑ(x)
as desired.
ψ(x) = ∑ ln p
pa ≤x
a
where p ranges over all the powers of primes p1 , p2 , . . . , pk which do not exceed x. In
other words, ln p appears in the sum each time a power of p is less than or equal to x.
Example. Let’s find ψ(10.5). The primes which do not exceed 10.5 are 2, 3, 5, and
2 3 2
7. The powers of these primes which do not exceed 10.5 are 2, 2 , 2 , 3, 3 , 5, and 7.
Therefore
ψ(10.5) = ln 2 + ln 2 + ln 2 + ln 3 + ln 3 + ln 5 + ln 7
3 2
= ln(2 × 3 × 5 × 7)
= ln(2520)
≈ 7.83
253
§6. Distribution of Prime Numbers Masum Billal, Amir Hossein
Corollary 35. Let p1 , p2 , . . . , pk be primes not exceeding a positive real number x. Also,
a a a
assume that p11 , p22 , . . . , pkk are the largest powers of these primes which do not exceed
x. Then
a a a
ψ(x) = ln (p11 p22 ⋯pkk )
ln x
ψ(x) = ∑ ⌊ ⌋ ln p
p≤x
ln p
Proof. Let p be a prime not exceeding x. We just need to show that the power of p
appearing in ψ(x) equals ⌊ln x/ ln p⌋. This is rather obvious. Let a be the power of p
a a+1
we are searching for. Then p ≤ x < p . Taking logarithms and dividing by ln p, we
find the desired result.
Chebyshev attempted to prove the Prime Number Theorem, and he succeeded in
proving a slightly weaker version of the theorem. In fact, he proved that if the limit
π(x) ln(x)/x as x goes to infinity exists at all, then it is equal to one. He showed that
this ratio is bounded above and below by two explicitly given constants near 1, for
all sufficiently large x. Although Chebyshev was unable to prove PNT completely, his
estimates for π(x), ϑ(x), and ψ(x) were strong enough to prove Bertrand’s postulate
at his time. We will state these estimations but hesitate to provide the proofs as they
need some calculus background.
Theorem 170 (Chebyshev Estimates). If the following limits exist, they are all equal
to 1.
ϑ(x) ψ(x) π(x) ln(x)
(11) lim x , lim x , lim x
x→∞ x→∞ x→∞
The inequalities in the next theorem show that n/ ln(n) is the correct order of
magnitude for π(n). In fact, these inequalities are pretty weak and better inequalities
can be obtained with greater effort but the following theorem is of our interest because
of its elementary proof.
254
§6. Distribution of Prime Numbers Masum Billal, Amir Hossein
Proof. Let’s prove the leftmost inequality first. Assume that n ≥ 1 is an intger. One
can easily show by induction that
n 2n n
(13) 2 ≤(n)<4
Using the fact that (2n ) = (2n)!/(n!) , we can take logarithms from (13) to obtain
2
n
(14) n ln 2 ≤ ln(2n)! − 2 ln n!
(15) < n ln 4
We must now find a way to compute ln(2n)! and ln n!. Let k be a positive integer. By
theorem (9), we have
α
k
(16) vp (k!) = ∑ ⌊ i ⌋
i=1
p
where α is some positive integer. Here, we need to find α. See proof of theorem (9) to
realize that α + 1 is actually the number of digits of k in base p. On the other hand, we
know that the number of digits of a positive integer x in base y is ⌊logy x⌋ + 1 (prove
this as an exercise). So, in our case, α + 1 = ⌊logp k⌋ + 1, or simply α = ⌊logp k⌋. Since
we are working with natural logarithms (i.e., logarithms in base e), it would be better
to write a = ⌊ ln k
ln p
⌋. Finally, substituting n and 2n for k in equation (16), we get
⌊ ln n
ln p
⌋
n
vp (n!) = ∑ ⌊ i ⌋
i=1
p
⌊ lnln2n
p
⌋
2n
vp ((2n)!) = ∑ ⌊ ⌋
i=1
pi
vp (n!)
It is clear that n! = ∏ p , where the product is extended over all primes p less than
p≤n
or equal to n. After taking logarithms in the latter equation, the product turns into a
sum:
ln n! = ∑ vp (n!) ln p
p≤n
⌊ ln n
ln p
⌋
n
= ∑ ∑ ⌊ i ⌋ ln p
p≤n i=1
p
Similarly,
ln(2n)! = ∑ vp ((2n)!) ln
p≤n
⌊ lnln2n
p
⌋
2n
= ∑ ∑ ⌊ ⌋ ln p
p≤2n i=1
pi
255
§6. Distribution of Prime Numbers Masum Billal, Amir Hossein
⌊ lnln2n
p
⌋ ⌊ ln n
ln p
⌋
2n n
n ln 2 ≤ ln(2n)! − 2 ln n! = ∑ ∑ ⌊ i ⌋ ln p − 2 ∑ ∑ ⌊ i ⌋ ln p
p≤2n i=1
p p≤n i=1
p
⌊ lnln2n
p
⌋ ⌊ lnln2n
p
⌋
2n n
= ∑ ∑ ⌊ i ⌋ ln p − ∑ ∑ 2⌊ i ⌋ ln p
p≤2n i=1
p p≤2n i=1
p
⌊ lnln2n
p
⌋
2n n
(17) = ∑ ∑ (⌊ i
⌋ − 2⌊ i ⌋) ln p
p≤2n i=1
p p
⎛⌊ ln p ⌋ ⎞
ln 2n
n ln 2 ≤ ∑ ⎜ ⎜
⎜ ∑ 1⎟
⎜
⎟ ln p
⎟
⎟
p≤2n ⎝ i=1 ⎠
≤ ∑ ln 2n
p≤2n
= π(2n) ln 2n
The proof is almost finished. Note that ln 2 ≈ 0.6931 > 1/2 and therefore
n ln 2
π(2n) ≥
ln 2n
1 n
>
2 ln 2n
1 2n
=
4 ln 2n
1 2n
>
6 ln 2n
So the left side inequality of (12) is proved for even positive integers m = 2n. We now
prove it for m = 2n + 1. Since 2n/(2n + 1) ≥ 2/3, we get
π(2n + 1) ≥ π(2n)
1 2n
>
4 ln 2n
1 2n 2n + 1
>
4 2n + 1 ln(2n + 1)
1 2n + 1
≥
6 ln(2n + 1)
and this proves the left hand inequality of (12) for all m ≥ 2.
We will now prove the other inequality of (12). We shall make use of proposition
α
(56). Let α be an arbitrary real number such that 0 < α < 1. Then n > n and so
256
§6. Distribution of Prime Numbers Masum Billal, Amir Hossein
α α α
(π(n) − π(n )) ln n = (∑ 1 − ∑ 1) ln n
p≤n p≤nα
α
= ∑ ln n
nα ≤p≤n
≤ ∑ p
nα ≤p≤n
≤ ϑ(n)
< 2n ln 2
r = 0.r1 r2 . . . rn . . .
= 0.011010100010 . . .
257
§6. Distribution of Prime Numbers Masum Billal, Amir Hossein
Solution. We will prove a more general statement: such a number r in any base b > 1
is irrational. First, we define the average of digits of r in base b, denoted by Avb (r), as
r1 + r2 + ⋯ + rn
Avb (r) = lim n
n→∞
It is clear that Avb (r) is well-defined if the above limit exists. It is a good exercise for
you to prove that if Avb (r) = 0, then r is irrational. The latter result is true because
if r is rational, Avb (r) exists and is positive. Now, by the definition of r and Prime
Number Theorem,
π(n)
Avb (r) = lim n
n→∞
n/ log n
= lim n
n→∞
1
= lim =0
n→∞ log n
and so r is irrational!
Theorem 172 (Euler). The sum
1 1 1
S= + + + ...
2 3 5
1
=∑p
p∈P
We let A be the set of positive integers which has all prime factors less than or equal
to pk , and B be the set of positive integers with all prime factors greater than or equal
to pk+1 . From the fundamental theorem of arithmetic, each positive integer can be
uniquely expressed as a product ab where a ∈ A and b ∈ B. We have
∞ ∞
1 1
∑ a = ∑ ⋯ ∑ x1 xk
a∈A x1 =0 xk =0 p1 ⋯pk
∞ ∞
1 1
= (∑ x1 )⋯ ∑ xk
x1 =0 p1 xk =0 pk
<∞
22
Dustin G. Mixon
2013 “Another Simple Proof that the Sum of the Reciprocals of the Primes Diverges”, The American
Mathematical Monthly, vol. cxx, no. 9, p. 831, doi: 10.4169/amer.math.monthly.120.09.831.
258
§7. The Selberg Identity Masum Billal, Amir Hossein
Moreover, assume that Bi is the set of positive integers with exactly i distinct prime
factors. This yields,
∞
1 1
∑ =∑∑
b∈B
b i=0 b∈B b
i
∞ ∞ j
1
≤∑ ( ∑ p )
j
i=1 j=k+1
<∞
Since every positive integer greater than 1 belongs to exactly one of A or B, we have
∞
1 1 1
+⋯+ n +⋯= ∑n
2
n=2
1
=∑∑
a∈A b∈B
ab
1 1
=∑a∑
a∈A b∈B
b
<∞
Atle Selberg and Paul Erdős together first proved the Prime Number Theorem using
elementary means only. The starting point of the proof is known as what Selberg called
the Fundamental Identity.
We need some definitions before stating the Selberg identity. We will use functions
defined in Chapter III. The following theorem is almost trivial.
Theorem 173 (Invariance Theorem). Let f be an arithmetic function and I be the
identity function. Then
f ∗I =I ∗f =f
Theorem 174. Let f be an arithmetic function and F is its summation function. Then
f =µ∗F
Proof. This is immediately resulted from Möbius inversion theorem (theorem (110)).
259
§7. The Selberg Identity Masum Billal, Amir Hossein
f (n) = f (n) ln n
′
Example. I (n) = I(n) ln n = 0 for all positive integers n. Also, u (n) = ln n and
′ ′
u (n) = ln n ⋅ ln n = ln n.
′′ 2
We can easily check that some usual properties of differentiation hold true for Dirich-
let derivative as well. For instance:
23
Proposition 58. Let f and g be arithmetic functions. Then
(f + g) = f + g
′ ′ ′
(f ∗ g) = f ∗ g + f ∗ g
′ ′ ′
Proof. The first one is obvious. For the second one, we can write
⎛ n ⎞
(f ∗ g) (n) = ⎜∑ f (d) g( )⎟ ⋅ ln n
′
⎝ d∣n d ⎠
⎛ n ⎞ n
= ⎜∑ f (d) g( )⎟ ⋅ (ln d + ln )
⎝ d∣n d ⎠ d
⎛ n ⎞ ⎛ n ⎞ n
= ⎜∑ f (d) g( )⎟ ⋅ ln d + ⎜∑ f (d) g( )⎟ ⋅ ln
⎝ d∣n d ⎠ ⎝ d∣n d ⎠ d
n n n
= ∑ f (d) ⋅ ln d ⋅ g( ) + ∑ f (d) g( ) ⋅ ln
d d d
d∣n d∣n
n ′ n
= ∑ f (d) ⋅ g( ) + ∑ f (d) g ( )
′
d d
d∣n d∣n
= (f ∗ g)(n) + (f ∗ g )(n)
′ ′
Von Mangoldt Function. For any positive integer n, the von Mangoldt function,
24
denoted by Λ(n) is defined as
m
ln p if n = p for some prime p and positive integer m
Λ(n) = {
0 otherwise
23
You can see it follows some properties of the usual derivative (if you are familiar with calculus,
you should know what derivative is. However, for this purpose you do not need any calculus.)
24
Λ is the upper case of the symbol lambda (λ) in Greek.
260
§8. The Selberg Identity Masum Billal, Amir Hossein
Proof. We proved in theorem (175) that ln n = ∑d∣n Λ(d). We also found that u (n) =
′
−1
Now multiply both side by u = µ (as proved in theorem (112)) to get
Λ ∗ (u ∗ u ) + Λ ∗ (Λ ∗ (u ∗ u )) = u ∗ u
′ −1 −1 ′′ ′
−1
Now, since u ∗ u = I and f ∗ I = f for any arithmetic function f , we have
′ ′′
Λ +Λ∗Λ=u ∗µ
Replacing the functions with their definitions, one easily finds
n 2 n
Λ(n) log n + ∑ Λ(d) Λ( ) = ∑ µ(d) log
d d
d∣n d∣n
as desired.
261
§8. Primality Testing Masum Billal, Amir Hossein
§8 Primality Testing
Depending on the guarantee whether our algorithm can say for sure if a number is a
prime or not, we can divide the algorithms for prime testing in two:
1. Deterministic primality Test
2. Non-deterministic or Probabilistic or Randomized primality Test
First we will discuss some deterministic approach, then some probabilistic approach.
The first one is based on a theorem we have already established in autorefch:divisibility.
√
Theorem 177 (Trial Division until n ). If n is a composite number, it has at least
√
one prime factor q with q ≤ n.
This is the simplest way to check whether a positive integer n is a prime. That is,
√
given n, you check weather any prime 2 ≤ p ≤ n divides n. If n is not divisible by
any such p, it is a prime. We take this opportunity to introduce a notion of runtime,
which will roughly mean the number of operations someone or a computer will have to
do in order to determine whether n is prime or not using a particular algorithm. In
√
this algorithm, you can see that we are dividing n by primes less than n and so, if
the number of such primes is k then we could say, runtime is R(k). Here, assume that
R(k) denotes the runtime of the whole operation, though it is not rigorous at all. But
it will do for our purpose very nicely. Let’s look at the following theorem now.
Theorem 178 (Lucas Test). Let n > 1 be a positive integer. Then n is a prime if and
only if there is an integer 1 < a < n for which
n−1
a ≡ 1 (mod n)
and for every prime factor p of n − 1,
(n−1)/p
a / 1 (mod n)
≡
Proof. We will show the if part first. If n is a prime, then by Theorem 81, it has a
≡ 1 (mod n)
φ(n) n−1
primitive root. That is, there exists some integer a such that a =a
/ 1 (mod n) for all d < n.
d
and a ≡
On the other hand, assume that given conditions hold for a positive integer n. The
first condition asserts that (a, n) = 1. Let d be the order of a modulo n. That is, d is
the smallest positive integer less than n such that a ≡ 1 (mod n). By Theorem 70,
d
262
§8. Primality Testing Masum Billal, Amir Hossein
which is in contradiction with the second condition since q is a prime such that q ∣ x ∣
n − 1. Thus the order of a modulo n is n − 1. So φ(n) = n − 1 which implies that n is
a prime.
25
The next theorem appears in Koblitz.
Theorem 179 (Pocklington’s Theorem). Let n > 1 be an integer and suppose that
there exist an integer a and a prime q such that the following conditions hold:
√
1. q ∣ n − 1 and q > n − 1,
Then n is a prime.
√
Proof. Assume n is not prime. Then n has a prime divisor p such that p ≤ n. By first
condition, q > p − 1 and so (q, p − 1) = 1. We can deduce by Theorem 38 that there
exists an integer x such that qx ≡ 1 (mod p − 1). This means that qx − 1 = (p − 1)k or
qx = (p − 1)k + 1 for some k. Since p ∣ n, the second condition gives a ≡ 1 (mod p)
n−1
and so
n−1
1≡a
n−1 x
≡ (a )
n−1 qx
≡ (a q
)
n−1 (p−1)k+1
≡ (a q
)
n−1 k p−1 n−1
≡ ( (a q
) ) ⋅ (a q
)
Í ÎÌ Ï
≡1
(n−1)/q
≡a (mod p)
(n−1)/q
This gives p ∣ a − 1. Combining the latter result with p ∣ n, we have
n−1
p ∣ (a q
− 1, n)
=1
263
§8. Primality Testing Masum Billal, Amir Hossein
a
where ( n ) is the Jacobi symbol defined in (§8.3). Then a is called an Euler witness for
compositeness of n, or simply an Euler witness for n.
Theorem 180 (Solovay–Strassen Primality Test). Let n > 1 be an odd integer. Then
n is composite if it has an Euler witness.
Proof. By Euler’s criterion, we know that if n is a prime, then for every integer a
relatively prime to n,
(n−1)/2 a
(18) a ≡ (n) (mod n)
So, if for some a relatively prime to n, the above congruence equation does not hold, n
cannot be a prime. Thus it is composite.
264
§8. Primality Testing Masum Billal, Amir Hossein
28
used in the definition of strong pseudoprimes. Rabin later modified Miller’s pri-
mality test and obtained Miller–Rabin test which we will now explain. To formulate
Miller-Rabin primality test, it would be convenient to use the terminology introduced
by Rabin as below:
s
Definition. Let n = 2 d + 1 where s and d are positive integers and d is odd. Let a > 1
be an integer relatively prime to n. Then a is said to be a witness for compositeness of
n, or simply a witness for n when
d
/ 1 (mod n)
a ≡
r
2 d
a / −1 (mod n)
≡
for 0 ≤ r < s.
Theorem 181 (Miller–Rabin Primality Test). Let n > 1 be an odd integer. Then n is
composite if it has a witness.
Proof. Assume that n has a witness a. Then by definition (a, n) = 1 and
d
/ 1 (mod n)
a ≡
d
/ −1 (mod n)
a ≡
2d
a / −1 (mod n)
≡
4d
a / −1 (mod n)
≡
..
.
s−1
2 d
a / −1 (mod n)
≡
It follows that the following product is not divisible by n:
s−1 s
d d 2 d 2 d
(a − 1) (a + 1)⋯ (a + 1) = a − 1.
s
− 1 and so n ∤ a
2 d n−1 n−1
But a − 1 = a − 1. We know by Fermat’s little theorem that
if p is a prime, then p ∣ a − 1 for any a such that (a, p) = 1. So, n cannot be a prime
p−1
265
§8. Primality Testing Masum Billal, Amir Hossein
Theorem 182. Let a be an integer and n be a positive integer such that (a, n) = 1.
Then n is prime if and only if
n n
(x + a) ≡ x + a (mod n)
n n
P (x) = (x + a) − (x + a)
n
n i n−i n
= ∑ ( i )x a − (x + a)
i=0
n−1
n i n−i n
= ∑ ( i )x a − (a − a )
i=1
If n is prime, then n divides (ni) for all 0 < i < n by Theorem 32 and also a ≡ a
n
(mod n) by Fermat’s little theorem. So P (x) ≡ 0 (mod n) and the condition holds.
If n is composite, take a prime divisor p of n. Let v be the greatest power of p
that divides n. That is, p ∣ n but p ∤ n. Then q does not divide (ni) (why?) and
v v+1 i
therefore n does not divide the term (np)x a in P (x). This means that P (x) ≡
/ 0
q n−p
to (log2 n) by mathematicians such as C. Pomerance. But it still is not very good for
6
100
running as a program. This runtime means, if n = 2 , we would have to do around
6 12
100 = 10 operations, which is really costly. If we assume the best case scenario, an
9
average computer may perform 10 operations per second (in fact it is far less effectively
when it’s down to computing because there are many related calculations as well), so
it would require around 1000 seconds to test primality of a number of that magnitude.
1023
But in practice, numbers around 1024 bits are used which are as large as 2 − 1.
This makes this test obsolete. In turn, this gives rise to probabilistic primality test. In
a probabilistic test, one can not guarantee that the input n is definitely a prime. But
it can say if it is a probable prime or not. And if we use a good enough algorithm the
−k
probability of having a false prime is really small, of the magnitude 2 where k is some
iteration number or something else depending on the algorithm. But if k is around
100, you can see how small this gets. This means the chances of getting a false result
is really really slim. Let’s first use Fermat’s little theorem as a probabilistic test. We
≡ 1 (mod p).
p−1
already know that for a prime and a positive integer x, we must have x
Using this, we can make the test for input n this way.
266
§8. Primality Testing Masum Billal, Amir Hossein
iv. Otherwise n is probably a prime. Probably, because the reverse of Fermat’s little
theorem is not true, as we discussed on autorefch:congruence before.
But this doesn’t make a very reliable test. To make it a bit more reliable, we can iterate
this process for k times. And each time we have to choose another random x. The more
we iterate, the more the accuracy is.
The most popular and used method for probabilistic testing is Rabin-Miller primal-
ity test. This makes clever use of Fermat’s little theorem.
F5 = 641 ⋅ 6700417.
Since Fn increases too rapidly with n, it is too difficult to check its primality. In
1877, Pepin developed a test for checking the primality of Fermat numbers:
Theorem 183 (Pepin’s Primality Test for Fermat Numbers). Let n ≥ 2 be an integer
th
and assume Fn denotes the n Fermat number. Also, let k ≥ 2 be any integer. Then
the following conditions are equivalent:
1. Fn is prime and ( Fk ) = −1.
n
(Fn −1)/2
2. k ≡ −1 (mod Fn ).
Proof. Assume that condition 1 holds. Then by Euler’s criterion (Theorem 51),
(Fn −1)/2 k
k ≡ ( ) ≡ −1 (mod Fn )
Fn
(F −1)/2
To prove the other side of the theorem, assume that k n ≡ −1 (mod Fn ). Choose
an integer m such that 1 ≤ m < Fn and m ≡ k (mod Fn ). Then
(Fn −1)/2 (Fn −1)/2
m ≡k ≡ −1 (mod Fn )
267
§8. Primality Testing Masum Billal, Amir Hossein
n
2
Note that the only prime divisor of Fn − 1 = 2 is 2. Hence we can use Lucas test
(with a = m and p = 2, using notation of Theorem 178) and deduce that Fn is a prime.
Furthermore, we have by Euler’s criterion that
k (F −1)/2
( )≡k n ≡ −1 (mod Fn )
Fn
The proof is complete.
Pepin’s test is usually done with k = 3, 5, or 10. In practice, mathematicians have
not been able to show that any Fermat number Fn for n > 4 is a prime using Pepin’s
test. On the other hand, nobody has yet proved that all Fermat numbers larger than
F4 are composite.
Another type of numbers are Mersenne numbers, named after Marin Mersenne who
th
studies them back in 17 century.
n
Definition. Let n be an integer. The numbers of the form Mn = 2 − 1 are called
Mersenne numbers. If Mn is prime for some n, it is called a Mersenne prime.
Proposition 60. If Mn is a prime for an integer n > 1, then n is a prime.
Proof. See Theorem 28.
Mersenne stated that
M2 , M3 , M5 , M7 , M13 , M17 , M19 , M31 , M67 , M127 , M257
30
are the only Mersenne primes less than M258 . Although he was wrong about M67
31
and M257 and he missed M61 , M89 , and M107 in the list, his work is considered aston-
ishing because these numbers are astronomically large. Interested readers may study
32
Ribenboim for more details about Mersenne primes.
Theorem 184. Let q > 2 be a prime. For every divisor n of Mq , we have
n ≡ ±1 (mod 8)
n ≡ 1 (mod q)
Proof. It suffices to prove the theorem for prime n (why?). Let p be a prime divisor of
Mq = 2 − 1. Then 2 ≡ 1 (mod p) and so ordp (2) ∣ q, which means that ordp (2) = q
q q
since q is a prime. By corollary (22), q = ordp (2) ∣ φ(p) = p − 1. Thus p ≡ 1 (mod q).
Since p and q are both odd, we can write the latter relation as p − 1 = 2kq. By Euler’s
criterion,
2 (p−1)/2
(p) ≡ 2
kq
≡2
q k
≡ (2 )
≡ 1 (mod p)
30
M67 = 193707721 × 761838257287.
31
Lehmer and Kraı̈tchik showed that M257 is composite.
32
Paulo Ribenboim
1991 “The Little Book of Big Primes”, doi: 10.1007/978-1-4757-4330-2.
268
§8. Primality Testing Masum Billal, Amir Hossein
The above theorem can be used to factorize Mersenne numbers. It will be tough to
use this theorem for large Mersenne number though. To realize whether a Mersenne
number is prime or composite, one may use the so-called Lucas–Lehmer primality test,
introduced by Édouard Lucas in 1856 and improved by Derrick Henry Lehmer later
in 1930s. The proof is a bit difficult and we refuse to write it. The reader may see
33
Bruce for a proof if interested.
Theorem 185 (Lucas–Lehmer Primality Test for Mersenne Numbers). Define the re-
2
cursive sequence S(n) by S(1) = 4 and S(n + 1) = S(n) − 2 for any integer n ≥ 1.
Also, let p > 2 be a prime. Then Mp is prime if and only if it divides S(p − 1).
11
Example. We will apply Lucas–Lehmer test to factorize M11 = 2 − 1 = 2047. We
must check whether S(10) is divisible by 2047. Table 4.1 shows values of S(n) for
n = 1, 2, . . . , 10. As seen in the table, S(10) is not zero modulo 2047 which means that
M11 is not a prime. In fact, 2047 = 23 ⋅ 89.
As the last class of primes, we will mention Proth numbers.
h
Definition. Let k and h be positive integers such that k is odd and k < 2 . A number
h
of the form n = k ⋅ 2 + 1 is called Proth number and if it is a prime, it is said to be a
Proth prime.
The following primality test for Proth numbers was published by François Proth
around 1878 and is known as Proth’s theorem.
Theorem 186 (Proth’s Primality Test for Proth Numbers). Let n be a Proth number.
Then n is prime if an integer a for which
(n−1)/2
a ≡ −1 (mod n)
33
James William Bruce
1993 “A Really Trivial Proof of the Lucas-Lehmer Test”, The American Mathematical Monthly, vol. c,
no. 4, p. 370, doi: 10.2307/2324959.
269
§9. Primality Testing Masum Billal, Amir Hossein
We will prove a stronger result in the following lemma which was proposed by
Pocklington.
Lemma 22. Let a, b and n be positive integers such that 0 < a ≤ b + 1 and n = ab + 1.
Assume that for every prime divisor p of b there exists an integer x for which
n−1
x ≡ 1 (mod n)
(n−1)/p
x / 1 (mod n)
≡
Then n is prime.
Proof. Assume on the contrary that n is composite and take the smallest prime factor
√ k
q of n. Theorem 177 implies that q ≤ n. Let p be a prime factor of b. Write b = p s,
where k ≥ 1 and s are positive integer such that (s, p) = 1. Let x be an integer which
satisfies the given conditions. Then
n−1
(19) x ≡ 1 (mod q)
(n−1)/p
(20) x / 1 (mod q)
≡
because q ∣ n. We claim that ordq (x ) = b. To prove the claim, we notice that
a
a b ab
(x ) = x
n−1
=x
≡ 1 (mod q)
We must now show that (x ) ≡ / 1 (mod q) for any integer 0 < m < b. Assume on
a m
the contrary that there exists a positive integer m < b such that x ≡ 1 (mod q). If
ma
d = ordq (x), then d ∣ ma. On the other hand, the congruence relation (19) shows that
d ∣ n − 1 = p sa. This implies d ∣ (ma, p sa). Suppose that m = p t. Then
k k l
k l k
(ma, p sa) = (p ta, p sa)
l k
= a (p t, p s)
min(l,k)
= ap (t, s)
(We have used propositions (21) and (24) in writing second and third lines.) Now,
the congruence equation (20) implies that d ∤ n−1
k−1
p
= p as, which is in contradiction
with d ∣ ap (t, s). We have thus shown that ordq (x ) = b. It follows that b ≤
min(l,k) a
270
§9. Prime Factorization Masum Billal, Amir Hossein
§9 Prime Factorization
Finding prime numbers has been a challenge for mathematicians since very long time
ago. Consider the following question:
The very first answer to this question dates back to 200 B.C., when Eratosthenes
developed the Sieve method. This method is very simple but it is still used, after 2000
years of its birth! To apply sieve method of finding primes to an integer n, we write
down all the positive integers less than or equal to n. Put aside 1. The first number in
the list is 2, which we know is a prime. We start by erasing the multiples of 2 from the
list. Let’s simulate the process for X = 40:
2 3 4 5 6 7 8 9
10
11 12
13
14 15
16 17
18 19
20
21 22
23
24
25 26
27 28
29 30
31 32
33
34 35
36 37
38 39
40
Now, choose the first number after 2 in the list. It is 3, a prime. Erase all multiples
of 3 from the list and choose the next number. The point is that the next number we
choose is always a prime because it is not divisible by any integer less than it in the
list (otherwise it would have been erased). We continue this method until we find the
largest prime less than or equal to n. The final list for n = 40 would look like this:
2 3 4 5 6 7 8 9 10
11 12
13 14
15
16
17
18
19 20
21
22
23 24
25
26
27
28
29 30
31 32
33
34
35
36
37
38
39
40
The remaining numbers are primes less than or equal to n. In fact, we have sieved all
the primes in the list, hence the name sieve method. The sieve method is not time
efficient specially when n is large (can you find the reason?).
271
§9. Prime Factorization Masum Billal, Amir Hossein
′ ′
5. If n > 1 then this n itself is a prime factor of the original n (which we used for
factoring at the first step, and it will be decreasing since we keep dividing by a prime
if n is composite). And in this case, the exponent will be 1 (why?).
The last statement needs a bit clarification. In the steps before that, we divided n by
all prime factors of n less than or equal to m. Therefore, if all prime factors of n are less
than or equal to m, the n we will have after all these divisions is 1, since it is all divided
′ ′ ′
up by p ≤ m. But if n > 1 then we have this n > m, so n can not have two such n .
2
Because the product of two integer greater than m is greater than m , so greater than
2 ′ ′
m = n. That would be impossible. Therefore, for the case n > 1, n must be a prime
′
and it would be the largest prime factor of n. And if n = 1 then the largest i ≤ k for
which pi ∣ n, pi would be the largest prime factor of n.
c+d 2 c−d 2
n= ( ) − ( )
2 2
This means that Fermat’s method of factorization always works when n is composite.
Fermat’s factorization is generally more time efficient than trial division. However, it
might be even slower than trial division in some cases.
2
2. While x is not a perfect square, set a ⟵ a + 1 and compute x = a − n for the new
a.
√ √
3. If x is a perfect square, n = (a − x)(a + x) is a factorization for x.
272
§9. Prime Factorization Masum Billal, Amir Hossein
Step 1 2 3 4 5 6 7 8
a 60 61 62 63 64 65 66 67
x 11 132 255 380 507 636 767 900
√
x 3.31 11.48 15.96 19.49 22.51 25.21 27.69 30
a by 1 at each step. When a = 67, we find x = 900, which is a perfect square. The
algorithm stops here and we have
√ √
n = (a − x)(a + x)
= (67 − 30)(67 + 30)
= 37 ⋅ 67
• Finding a non-trivial factor of n (that is, a factor other than 1 and n).
• Using a time efficient primality test in order to check if the non-trivial factor d
n
is prime or not. If d is prime, we can just factorize only. Otherwise, we can
d
n
repeat the same process for d and . Mostly Rabin-Miller test is used widely
d
these days.
Randomized tests vary mainly on the first step. Finding the non-trivial factor is the
crucial step here. Here we discuss Pollard’s method to find such a factor.
Let n > 1 be the composite integer which we want to factorize. Consider the
following sequence:
x0 = c
xi+1 ≡ g(xi ) (mod n)
Here, g(x) is a polynomial with integer coefficients. Notice that this sequence will
eventually become periodic. That is, there exists a positive integer T such that xi ≡ xi+T
34
John M. Pollard
1975 “A monte carlo method for factorization”, Bit, vol. xv, no. 3, pp. 331-334, doi: 10.1007/bf01933
667.
35
Richard Peirce Brent
1980 “An improved Monte Carlo factorization algorithm”, Bit, vol. xx, no. 2, pp. 176-184, doi: 10.1007/
bf01933190.
273
§9. Prime Factorization Masum Billal, Amir Hossein
(mod n) for all i ≥ i0 ≥ 0, where i0 is some integer. The reason is that there are exactly
n residues modulo n and the sequence is infinite, so by pigeonhole principle, there are
two terms xi and xj (with j > i) of the sequence for which xi ≡ xj (mod n). Suppose
n n−1
that g(x) = an x + an−1 x + ⋯ + a1 x + a0 , where a0 , a1 , . . . , an are integers. Then
xi+1 ≡ g(xi )
n n−1
= an xi + an−1 xi + ⋯ + a1 x i + a0
n n−1
≡ an x j
+ an−1 xj
+ ⋯ + a1 x j + a0
= g(xj )
≡ xj+1 (mod n)
therefore xi+k ≡ xj+k (mod n) for any k. Thus T = j − i is the period of the sequence.
It is clear now that T ≤ n.
The only thing that needs clarification is how to choose g(x) and x0 . It has been
2
practically shown that taking g(x) = x + a (for some integer a) is a good choice
for finding a non-trivial factor quickly. In 1975, John Pollard developed Pollard’s rho
2 36
method of factorization which takes g(x) = x − 1 and x0 = 2.
Here is how Pollard’s rho method of factorization work: assume that n = st, where
s and t are unknown factors of n such that t > s > 1. Suppose that we have found
integers j > i ≥ 0 such that xi ≡ xj (mod s) but xi ≡ / xj (mod n). Since s divides
both n and xi − xj , it must also divide (xi − xj , n). So (xi − xj , n) ≥ s > 1. On the
other hand, (xi − xj , n) is a factor of n and since it is larger than 1, it is a proper factor
of n (it is not equal to 1 or n). This means that we have found (xi − xj , n) to be a
factor of n.
So the problem now reduces to find indices j > i ≥ 0 such that xi ≡ xj (mod s) but
xi ≡/ xj (mod n). Pollard suggested that we take i = k and j = 2k for k = 1, 2, . . . , n.
You will see why in the following lines.
When we first discussed the periodicity of the sequence, we showed that the sequence
is periodic modulo n. However, one can show using Chinese Remainder Theorem that
the sequence is also periodic modulo s (why?). Assume that the sequence will be
periodic modulo s after xi0 with period T . Select an index k ≥ i0 such that T ∣ k.
Then obviously T ∣ 2k and because of the periodicity, xk ≡ x2k (mod s). But now
how do we know that xk ≡ / x2k (mod n). We don’t know that for sure. There is just a
likelihood that it will happen. The reason for this is that the sequence {xi (mod s)}i=0
∞
is periodic modulo T , and as proved above, we have T ≤ s. Similarly, the sequence {xi
(mod n)}i=0 is periodic with a period T ≤ n. Now, since s is a divisor of n, we have
∞ ′
s ≤ n so that the maximum value of period of the first sequence is smaller than that
′
of the second sequence. Because of this, it is likely that T < T . If this latter condition
holds and we have xk ≡ x2k (mod s), then we can deduce that xk ≡ / x2k (mod n),
which is what we were searching for.
′
You might ask now what happens if the given condition, T < T , does not hold?
Well, in that case, you cannot factorize n using Pollard’s method. In such cases, it is
usual to change the polynomial g(x) or the initial value x0 and then apply the method.
36 2
It was later found out that g(x) = x + 1 usually work for almost all the cases.
274
§9. Prime Factorization Masum Billal, Amir Hossein
Example. Let us factorize n = 391 using Pollard’s Rho algorithm. The process is shown
in table 4.3. In 10 step, where (∣ x2i − xi ∣, 391) is 23, we find that 23 is a factor
th
of n (and indeed it is: 391 = 23 × 17). We just stopped the algorithm after that step
because we have factorized 391. However, we have written the value of xi for 11th step
so that you can observe the periodicity of xi modulo 391. As illustrated in the table,
x7 ≡ x11 ≡ 46 (mod 391). Now, if you look at the computed values of xk modulo 23,
you will see that for j ≥ 7, xj ≡ xj+2 (mod 23). In terms of our previous definitions,
T = 2, i0 = 7, and k = 10. Observe that we cannot choose k = 8 because then x2k − xk
is zero, which is divisible by both 23 and 391. Therefore we choose k = 10 so that
xk − x2k ≡ 0 (mod 23) but xk − x2k ≡ 69 ≡/ 0 (mod 391).
The next example, taken from Patrick Stein’s website, takes a different polynomial
g(x) and initial value x0 in Pollard’s rho method.
Example. We will factorize a much larger integer n = 16843009. This time, we take
2
g(x) = 1024x + 32767 and x0 = 1. Table 4.4 shows the steps. As you see in the table,
th
at 9 step we find 257 to be a factor of n and the factorization is done:
275
§9. Prime Factorization Masum Billal, Amir Hossein
4 n
2 2
65537 is a prime number and it equals 2 + 1. Primes of the form 2 + 1 are called
Fermat primes, and the largest known such prime is 65537.
276
§11. Exercises Masum Billal, Amir Hossein
§10 Exercises
Problem 266. Find a formula for the number of square-free numbers less than x for
a real number x. Recall that, a natural number n is square-free if n does not have any
factor that is perfect square other than 1. Can you represent this formula using Möbius
function as well?
Problem 267. Show that 8081, 31627, and 65537 are all primes.
Hint. Take a = 2 or 3 and use Pocklington’s theorem.
Problem 268.
1. Let m, n, and k be non-negative integers such that m > 1. Prove that at least
one of the numbers
n n+1 n+k
(k ), ( k ), . . . , ( k )
is not divisible by m.
2. Let k and m be positive integers such that m > 1. Show that there are infinitely
many positive integers n such that
n n+1 n+k−1
(k ), ( k ), . . . , ( k )
277
§11. Open Questions In Primes Masum Billal, Amir Hossein
Conjecture 2 (Twin Prime Conjecture). There exists infinitely many primes p so that
p + 2 is a prime too.
Adway Mitra conjectured an improvement over this, which is known as the improved
version of Legendre’s conjecture.
Conjecture 6 (Oppermann’s Conjecture). For all integer x > 1, there exists at least
2 2
one prime between x(x − 1) and x and another prime between x and x(x + 1).
Conjecture 10 (Polignac Conjecture). For every even integer 2n are there infinitely
many pairs of consecutive primes which differ by 2n.
Conjecture 13 (Rassias Conjecture). For a prime p > 2, there exists two primes p1 , p2
such that,
p 1 + p2 + 1
p= p1
278
CHAPTER V.
SPECIAL TOPICS
When you have a hammer in your hand, it’s hard refraining yourself
from treating everything as a nail.
The objective of this chapter is to provide with some very powerful tools and some
special topics, which are incredibly helpful. Some topics may not be very useful for
solving problems, but they are quite good for making someone think and thus they
encourage us to study more on them. Let’s start with a really nice lemma. This PDF was created
for Amazon.
§1 Thue’s Lemma
1
Thue’s Lemma (see Thue ) is a wonderful theorem in modular arithmetic. It should
have been quite popular, but unfortunately, it is not as well-known as it should be.
Here we will see what a powerful tool it is.
Theorem 187 (Thue’s Lemma). Let n > 1 be an integer and a be an integer relatively
prime to n. Then, there are integers x and y so that
√
0 < ∣x∣, ∣y∣ ≤ n
x ≡ ay (mod n)
We call such a solution (x, y) to the above congruence equation a small solution.
√
Proof. Let r = ⌊ n⌋. That means r is the unique integer for which r ≤ n < (r + 1) .
2 2
is greater than n. Therefore, by pigeonhole principle, there must be two different pairs
(x1 , y1 ) and (x2 , y2 ) among these (r + 1) pairs so that
2
280
§1. Thue’s Lemma Masum Billal, Amir Hossein
2 2
The last congruence means that p∣a + b , so
2 2
p≤a +b
2 2
a + b < p + p = 2p
2 2
Therefore, a + b = p must occur.
Remark . We can prove a stronger result than that of Theorem Theorem 190 us-
ing Fibonacci-Brahmagupta Identity (see Fibonacci-Brahmagupta Identity). Since we
know that the product of any two numbers of the form 4k + 1 is again of the form 4k + 1
(see the proof of Theorem 21), the special case when n = 1 of the above identity along
with Theorem 190 shows that all numbers which are comprised only of prime divisors
of the form 4k + 1 are representable as the sum of two squares.
In fact, we can use the same technique for generalizing theorem Theorem 190.
Theorem 191. Let n ∈ {−1, −2, −3}. If n is a quadratic residue modulo a prime p,
2 2
then there are integers a and b so that a − nb = p.
Proof. We have already proven the case n = −1. If n is a quadratic residue modulo p,
2
x ≡ n (mod p)
has a solution. Fix the integer x and take a and b as in Thue’s lemma so that
a ≡ xb (mod p)
2 2 2
⟹ a ≡x b
2
≡ nb (mod p)
2 2
⟹ p ∣ a − nb
2 2 2 2
1. If n = −2, then p ≤ a + 2b < p + 2p = 3p. This means either a + 2b = p or
2 2 2 2
a + 2b = 2p occurs. If the first equation holds, we are done. If a + 2b = 2p, we
′ 2 ′2
see that a must be even. Replace a = 2a in the latter equation to get p = b +2a ,
as desired.
2 2 2 2
2. If n = −3, we find p ≤ a + 3b < p + 3p = 4p. If a + 3b = 2p, then a and b are
both odd or both even. If both are even, then 2p is divisible by 4, a contradiction
since p is odd. Otherwise, a and b are both odd:
2 2
a + 3b ≡ 1 + 3 ⋅ 1 (mod 4)
⟹ 2p ≡ 0 (mod 4)
2 2
This is, again, a contradiction. We are left with the case a + 3b = 3p. This
′ 2 ′2
shows a is divisible by 3. If we take a = 3a , we easily observe that p = b + 3a .
281
§1. Thue’s Lemma Masum Billal, Amir Hossein
Question. Can you prove a similar result to that of the remark after Theorem The-
orem 190, but for the above theorem? Try using Fibonacci-Brahmagupta’s identity
before reading the next corollary.
Corollary 38. For a prime p and an integer n with p ∤ n the following two statements
are equivalent:
2 2
• There exist relatively prime integers x and y so that p divides x + ny .
• −n is a quadratic residue modulo p.
Proof. First, assume that p ∣ x +ny . Then, y must be relatively prime to p. Therefore,
2 2
y has an inverse modulo p, say a. So, ay ≡ 1 (mod p). Then, a y ≡ 1 (mod p), and
2 2
2 2
p ∣ x + ny
2 2 2 2
⟹ p ∣ a x + na y
2 2
⟹ p∣a x +n
2
⟹ (ax) ≡ −n (mod p)
Now, suppose that −n is a quadratic residue modulo p. Let k ≡ −n (mod p). Clearly,
2
(k, p) = 1, otherwise p will divide n. From Thue’s lemma, there are integers x and y
such that
x ≡ ky (mod p)
2 2 2
⟹ x ≡k y
2
≡ −ny (mod p)
2 2
⟹ p ∣ x + ny
282
§1. Thue’s Lemma Masum Billal, Amir Hossein
2 2
where 0 ≤ fi ≤ ei . For any 1 ≤ i ≤ k, pi divides n = x + Dy . Therefore, according
to corollary 38, −D is a quadratic residue modulo pi . Now, by theorem Theorem 191,
2 2 f
each pi is of the form x + Dy . From our previous discussion, we find that pi i is of the
f f
same form for all i. As a consequence, the product p11 ⋯pkk = d is of the same form
and we are done.
Now we prove another theorem that demonstrates the power of Thue’s lemma. We
will use a theorem which we proved in section Section §8. For convenience, we state
the theorem here again.
Theorem 193. −3 is a quadratic residue modulo p if and only if p is of the form 3k +1.
Theorem 194. If p is a prime of the form 3k + 1, there are integers a and b such that
2 2
p = a + ab + b .
Such an y exists since p is odd. Then, the congruence equation y ≡ 2x + 1 (mod p) has
an integer solution for x. For that x, we get
2
(2x + 1) ≡ −3 (mod p)
2
4x + 4x + 1 ≡ −3 (mod p)
2
4(x + x + 1) ≡ 0 (mod p)
2
x +x+1≡0 (mod p)
The latter congruence equation holds because p is odd. From Thue’s lemma, there are
√
integers a and b with 0 < ∣a∣, ∣b∣ < p such that
a ≡ xb (mod p).
Then,
2 2 2 2
a + ab + b ≡ (xb) + (xb) ⋅ b + b
2 2
≡ b (x + x + 1)
≡ 0 (mod p)
283
§2. Thue’s Lemma Masum Billal, Amir Hossein
2 2
p ≤ a + ab + b
<p+p+p
= 3p
2 2 2 2
Consequently, either a + ab + b = p or a + ab + b = 2p happens. We can easily check
2 2 2 2
that a + ab + b = 2p can not happen (try it yourself). Thus, a + ab + b = p, which
is what we wanted.
You have probably figured out by now that our focus should be on the small
solutions so that we can bound the necessary expressions like the problem asks for.
Let’s see more examples on this.
2
Theorem 195. Let p > 5 be a prime which divides k + 5 for some integer k. Show
2 2 2
that there are integers x and y such that p = x + 5y .
Hint. Try to find x such that x ≡ −5 (mod p ). Then from Thue’s lemma, there exist
2 2
Problem 271. Let p be a prime for which there exists a positive integer a such that
2 2 2
p divides 2a − 1. Prove that there exist integers b and c so that p = 2b − c .
Solution. Let’s look for small solutions again for the purpose of bounding! We have
2a − 1 ≡ 0 (mod p). Since we want to bound 2b − c , it is obvious that we must find
2 2 2
2 2
b and c so that p divides 2b − c and then bound it. Fix the integer a, which is clearly
relatively prime to p. Then from Thue’s lemma, we there are integers b and c with
√
0 < ∣b∣, ∣c∣ < p so that
b ≡ ac (mod p)
2 2
Thus, p divides 2b − c , and now we get to use the fact that
2 2
p ≤ 2b − c
2
< 2b
< 2p
2 2
We immediately get that p = 2b − c .
284
§2. Chicken McNugget Theorem Masum Billal, Amir Hossein
You are probably wondering how come this can be the name of a theorem if you have
encountered it for the first time. The name just might be the weirdest of all names
a theorem can possibly assume! Here is the reason behind such a name: The story
goes that the Chicken McNugget Theorem got its name because in McDonalds, people
bought Chicken McNuggets in 9 and 20 piece packages. Somebody wondered what
the largest amount you could never buy was, assuming that you did not eat or take
away any McNuggets. They found the answer to be 151 McNuggets, thus creating the
Chicken McNugget Theorem. Actually it is Sylvester’s Theorem, now known as the
Chicken McNugget Theorem. The problem is known as Frobenius Coin Problem, which
is a generalization of this one. Have you ever wondered about the coin system of your
own country? It is designed in a way so that you should never face a situation where
you can not exchange a certain amount of money. But have you thought how it is
possible? In this section, we will deal with problems like this. First think for yourself
on the following two problems:
Problem 272. You are in a strange country where only two units are available for
exchange: 4 and 6. Can you pay any amount you want?
Problem 273. In another country, you see that only two units are available for ex-
change: 3 and 10. Can you pay any amount you want?
If you have come to the right conclusions, you will see that you can not pay any
amount you want in the first case. But you can pay whatever you want with the second
one. Let’s say two units available value a and b. So if you use a unit x times and b unit
y times, the total amount of money you can pay is ax + by. Here, x, y can be negative
or non-negative integers. If x > 0, it will mean you are paying, or if x < 0 it will mean
you are being paid (or getting the exchange). Therefore, if you need to pay exactly n
amount, you need integers x and y with
ax + by = n
Play with some more values of a and b. You will understand that you can pay n amount
with units a and b if and only (a, b) divides n. Here is another intuitive fact: If we can
pay just 1, we can pay any amount we want with as many 1s needed. So we should
focus on when we can pay 1 by a and b. This tells us, a and b must be co-prime. And
from Bézout’s Identity, for any co-prime a and b, we will get integers x, y so that
ax + by = 1
In the problems above, we can’t pay any amount with 4 and 6 because they are not
co-prime. But we can pay any amount that is a multiple of (4, 6) = 2. But we can pay
any amount with 3 and 10 because they are co-prime. This leads us to the following
theorem.
285
§2. Chicken McNugget Theorem Masum Billal, Amir Hossein
Theorem 196. Any integer can be written as a linear combination of a and b if and
only if a ⊥ b.
By linear combination, we mean using only a and b as many times as we want. Now
we see the same problem from another perspective. Consider the following problem. If n
can be written as ax+by for non-negative x, y, we will call n a good number. Otherwise,
n is bad. But to do that, we can’t change the values of a and b simultaneously. Therefore,
we fix two co-prime integers a and b. Next, let’s see why we are only considering a ⊥ b.
If (a, b) = g and g > 1, then we already know that only multiples of g can be good.
But we want as many integers to be good as possible, and not skipping some integers
is better.
Problem 274. A shop sells nuggets in packages of two sizes, 3 nuggets and 10 nuggets.
What is the maximum number of nuggets that cannot be expressed as a nonnegative
combination of these package sizes?
Frobenius Number. For two integers a and b, the largest bad integer is the Frobenius
number. In fact, it can be generalized for n natural numbers. If a1 , . . . , an are natural
numbers so that (a1 , . . . , an ) = 1, the largest natural number that can not be written
as a1 x1 + . . . an xn for nonnegative x1 , . . . , xn is the Frobenius number. It is denoted
as Fn (a1 , . . . , an ). Here, we will deal with the case n = 2, F2 (a, b). The following
theorem answers this question.
Theorem 197 (Sylvester’s Theorem, 1882). Let a and b be two co-prime positive in-
tegers greater than 1. Then the maximum integer that can not be expressed as ax + by
for non-negative integer x, y is ab − a − b.
If we can prove that for all N > ab − a − b, there are non-negative integers x, y such
that
N = ax + by
and that for N ≤ ab − a − b, there are no such x and y, we are done. First, let’s prove
the next lemma.
Lemma 23. ab − a − b is a bad number.
Proof. On the contrary, let’s assume that
ab − a − b = ax + by
a(x − b + 1) = −b(y + 1)
From this equation, a ∣ b(y + 1) but a ⊥ b. So, a∣y + 1. Again, b ∣ a(x − b + 1) but
b ⊥ a so b ∣ x − b + 1 or b ∣ x + 1. We get x + 1 ≥ b and y + 1 ≥ a, and so
x≥b−1
y ≥a−1
286
§2. Chicken McNugget Theorem Masum Billal, Amir Hossein
ax + by ≥ a(b − 1) + b(a − 1)
= ab − a + ab − b
⟹ ab − a − b ≥ 2ab − a − b
which is a contradiction.
The above lemma shows that F2 (a, b) ≥ ab − a − b. It only remains to prove the
following lemma:
Proof. Since (a, b) = 1, by Bézout’s identity, there are integers u and v so that
(1) au + bv = 1
⟹ anu + bnv = n
(2) ⟹ ax0 + by0 = n
We need to show that such x0 , y0 ≥ 0 exist. If (x0 , y0 ) is a solution of equation (2), then
so is (x0 − bt, y0 + at) for any integer t. Here, one can choose t such that 0 ≤ x0 − bt < b.
In case you don’t understand how we can choose such t, just divide x0 by b. Then
x0 = bq + r, where 0 ≤ r < b. This means that 0 ≤ x0 − bq < b, so one choice for t is
q. So we know that there exists some x0 such that 0 ≤ x0 < b. We will show that y0 is
also positive. Note that
ax0 + by0 = n
> ab − a − b
⟹ b(y0 + 1) > a(b − x0 − 1)
Since we know that x0 < b, we get b − x0 − 1 ≥ 0. This means that b(y0 + 1) > 0,
so y0 + 1 > 0, i.e., y ≥ 0. Therefore, there is a valid solution (x0 , y0 ) and the proof is
complete.
Now, the proof is complete. The same proof can be used for generalizing the case
where (a, b) > 1.
(a − g)(b − g)
n≥ g
(a − g)(b − g)
F2 (a, b) = g −g
287
§3. Chicken McNugget Theorem Masum Billal, Amir Hossein
We see some problems related to this theorem. A classical example would be the
following problem that appeared at the IMO 1983.
Problem 275 (IMO 1983). Let a, b, c ∈ N with (a, b) = (b, c) = (c, a) = 1. Prove that,
2abc − ab − bc − ca is the largest integer that can not be expressed as xbc + yca + zab
for non-negative x, y, z.
Solution. Clearly, we need to invoke Sylvester’s theorem here. But the expression
tells us, it can not be done in one step. Note that
Therefore, we should first focus only on bx + ay first. From McNugget theorem, any
integer greater than ab − a − b is good. So we substitute ab − a − b + 1 + t for some
non-negative t into the equation and get
This again calls for using the theorem for c and ab. Again, every integer greater than
abc−ab−c is good. So we substitute ct+zab = abc−ab−c+1+w for some non-negative
w. Then
This shows that all integers greater than 2abc − ab − bc − ca are good. Finally, in
order to prove the claim, we just have to show that 2abc − ab − bc − ca is bad. To the
contrary, assume that 2abc − ab − bc − ca = xbc + yca + zab for some non-negative x, y, z.
We have
Clearly, a ∣ x+1 because a∣bc(x+1) but gcd(a, bc) = 1. Similarly, b ∣ y +1 and c ∣ z +1.
This gives us bc(x + 1) + ca(y + 1) + ab(z + 1) ≥ bca + cab + abc or 2abc ≥ 3abc which
is obviously wrong.
So, the problem is solved. As you can see, the theorem is fairly easy to understand
and use in problems. There will be some related problems in the problem column. See
if you can get how to solve those using this (first you have to understand that this
theorem will come to the rescue though).
§3 Vietta Jumping
288
§3. Vietta Jumping Masum Billal, Amir Hossein
By now, Vietta jumping has become a standard technique for solving some particular
type of olympiad number theory problems. It is also known as Root Jumping or Root
Flipping. Though it involves Diophantine equations and for now, it is out of our scope,
many divisibility or congruence problems can be turned into one that can be solved
using this tactic. Hence, this section. To understand just how popular it has been, let’s
just mention that there are at least two IMO problems that have standard solutions
using this particular technique. And surely, there are many other olympiad problems
that fall into the same category. Now, let’s see what it is and what it actually does.
Consider the following quadratic equation
2
ax + bx + c = 0
Vietta jumping relies on these two equations. It is in fact, a descent method in which
we usually prefer using one of the following two methods:
(i) Standard Descent: It is usually used to show that the equation doesn’t have
any solution or some sort of contradiction to prove a claim, like we do in Infinite
Descent. For a solution (x, y) of the equation, we define a function dependent on
x, y (x + y is such a common function, as we will see later). Then we consider
the solution that minimizes that function over all solutions possible. If there are
multiple solutions that can achieve this, we are free to choose any one depending
on the problem. But then, using Vietta’s formulas, we try to find another solution
that makes the function’s value smaller, which gives us the necessary contradiction.
So, this is a modified version of infinite descent.
(iii) Sometimes, there can be even geometric interpretations. For example, Arthur
Engel showed one in his book Problem Solving Strategies chapter 6, problem 15.
We will now demonstrate this using some example problems. Let’s start with the
classical problem from IMO 1988. Here is what Engel said about this problem in his
book:
Nobody of the six members of the Australian problem committee could solve
it. Two of the members were George Szekeres and his wife Esther Klein,
289
§3. Vietta Jumping Masum Billal, Amir Hossein
both famous problem solvers and problem creators. Since it was a number
theoretic problem it was sent to the four most renowned Australian number
theorists. They were asked to work on it for six hours. None of them could
solve it in this time. The problem committee submitted it to the jury of
the XXIX IMO marked with a double asterisk, which meant a superhard
problem, possibly too hard to pose. After a long discussion, the jury finally
had the courage to choose it as the last problem of the competition. Eleven
students gave perfect solutions.
Problem 276 (IMO 1988, Problem 6). Let a and b be two positive integers such that
2 2
2 2 a +b
ab + 1 divides a + b . Show that is a perfect square.
ab + 1
Solution. Let k be an integer so that
2 2
a +b
=k
ab + 1
2 2
⟹ a + b = kab + k
2 2
⟹ a − kab + b − k = 0
As we said in the process, we will fix k and consider all pairs of integers (a, b) that
gives us k as the quotient. And take a solution (a, b) in nonnegative integers so that
the sum a + b is minimum (and if there are multiple such (a, b), we take an arbitrary
one). Without loss of generality, we can assume a ≥ b > 0. Now, fix b and set a = x
which will be the variable. We get an equation which is quadratic in x with a root a:
2 2
x − kbx + b − k = 0
Using Vietta, we get that x + a = kb or x = kb − a. From this, we infer x is integer.
Note that, we can write it in another way:
2
b −k
x= a
This equation will do the talking now! Firstly, if x = 0, we are done since that would
2 2
give us b − k = 0 or k = b , a perfect square. So, we can assume that x ≠ 0. To
descend the solution, we will need x > 0. For the sake of contradiction, take x = −z
where z > 0. But that would give us
2 2 2 2
x − kbx + b − k = z + kbz + b − k
2 2
≥z +k+b −k
2 2
=z +b >0
This is impossible. Thus, x > 0 and now, if we can prove that 0 < x < a, then we will
have a solution (x, b) smaller than (a, b). We actually have this already because
2
b −k
x= a
2
b
< a
2
a
≤ a =a
290
§3. Vietta Jumping Masum Billal, Amir Hossein
Therefore, we must have a solution (0, b) for the equation which gives us k = b .
2
2 2
Problem 277. Let a and b be positive integers such that ab divides a + b + 1. Prove
2 2
that a + b + 1 = 3ab.
2 2
Solution. Again, let k = a +bab
+1
and among all the solutions of the equation, consider
the solution that minimizes the sum a + b. We can also assume that, a ≥ b. Now for
applying Vietta, we rewrite it as
2 2
a − kab + b + 1 = 0
Just like before, let’s fix b and make it quadratic in x, which already has a solution a:
2 2
x − kbx + b + 1 = 0
Equation (3) implies that x is positive and equation (4) implies that x is an integer.
2 2
1 +1 +1
Now, if a = b, we already get that k = = 3. So we are left with a > b. But
1⋅1
then,
2
b +1
x= a
2
b + 2b + 1
< a
(b + 1)
2
= a
2
a
≤ a
=a
Solution. Take
2 2
a + ab + b
k= ,
ab − 1
2 2
or a − a(kb − b) + k + b = 0 and fix b, when we consider the smallest sum a + b for a
solution (a, b) where a ≥ b. Consider it as a quadratic in x again which has a solution
291
§4. Vietta Jumping Masum Billal, Amir Hossein
a:
2 2
x − x(kb − b) + b + k = 0
⟹ x + a = kb − b
⟹ x = kb − a − b
2
xa = b + k
2
b +k
⟹ x= a
We have that x is a positive integer. Since a + b is minimal, we have x ≥ a. So
2
b +k
a ≥a
2 2
⟹ k ≥a −b
2 2
a + ab + b
But k = , so
ab − 1
2 2
a + ab + b 2 2
≥a −b
ab − 1
2 2 2 2
(5) ⟹ a + ab + b ≥ (a − b )(ab − 1)
2 2
= ab(a + b)(a − b) − a + b
2
⟹ a(a + b) ≥ ab(a + b)(a − b) − a
2
(6) ⟹ a ≥ (a + b)(ab − b − 1)
2
3a 2 2 2
If a = b, then k = 2 . Since a ⊥ a − 1, we have a − 1 divides 3 or a = 2. In that
a −1
2
a +a+1 2
case, k = 4. If b = 1, then k = so a − 1 divides a + a + 1.
a−1
2
a−1∣a −1
2 2
⟹ a − 1 ∣ a + a + 1 − (a − 1)
a+2
⟹ a − 1 ∣ (a + 2) − (a − 1) = 3
292
§4. Exponent GCD Lemma Masum Billal, Amir Hossein
Remember from definition (§4.3) that vp (n) = α means α is the greatest positive
integer so that p ∣n. Alternatively, we can denote this by p ∥n.
α α
g = (x − y, f (x, y, n)) ∣ n
This yields to
n−1 n−2 n−2 n−1
f (x, y, n) = x +x y + . . . + xy +y
P (x) = (x − a) ⋅ Q(x) + r
then r = P (a) (the reason is simple, just plug in a into P ). So, in this case,
f (x, y, n) = (x − y) ⋅ Q(x, y, n) + r
g = (x − y, f (x, y, n))
= (x − y, n)
which results in g ∣ n.
293
§5. Exponent GCD Lemma Masum Billal, Amir Hossein
Corollary 39. The following result is true for any odd positive integer n:
n n
x +y
(x + y, x + y ) ∣ n
divide the whole equation by d and still it remains an equation of the same form. Let’s
therefore, consider (x, y) = 1. Factorizing,
2 2 n
(x + y)(x − xy + y ) = p
g = (x + y, f (x, y, 3))
g ∣ (x + y, 3)
Problem 281. Find all primes p and positive integer x such that
x
p − 1 = (p − 1)!
294
§5. A Congruence Lemma Involving gcd Masum Billal, Amir Hossein
In this section, we discuss yet another lemma, which involves gcd like the previous one.
The first author of this book finds it really useful for solving some types of problems.
The lemma was proved in Theorem (39) of chapter (II).
Lemma 25. Let a, b, and n be three positive integers such that (a, n) = (b, n) = 1 and
x x
a ≡b (mod n)
y y
a ≡b (mod n)
then
(x,y) (x,y)
a ≡b (mod n)
Corollary 41. Let p be a prime and let a and b be integers not divisible by p so that
k k
a ≡b (mod p)
Then
(k,p−1) (k,p−1)
a ≡b (mod n)
Corollary 42. Let a, b, and n be three positive integers such that (a, n) = (b, n) = 1.
If h is the smallest integer such that
h h
a ≡b (mod n)
then h ∣ k.
(h,k) (h,k)
Proof. From the lemma, we have a ≡ b (mod n). We have (h, k) ≤ h and
(h, k) ∣ k. Now, if (h, k) < h then (h, k) is smaller than h which satisfies the condition.
So we must have (h, k) = h, or h ∣ k.
Corollary 43. Let p be a prime and let a be a positive integer. If ordp (a) = d and
a ≡ 1 (mod p), then d ∣ (p − 1, k).
k
(k,p−1)
≡ 1 (mod p). From the theorem, a
p−1
Proof. From Fermat’s little theorem, a ≡1
(mod p) and from corollary above, d ∣ (k, p − 1).
295
§5. A Congruence Lemma Involving gcd Masum Billal, Amir Hossein
You should see that if a problem can be solved using the dividing property of order,
then we can solve it using this lemma as well. Let’s see some problems that this lemma
is useful with. Sometimes, we have to couple this lemma with some other techniques
such as the smallest prime factor trick.
n
Problem 282. Find all n ∈ N such that 2 − 1 is divisible by n.
A standard problem with a very nice idea. There are many ways to start working
on such problems. A common one is to find the prime factors of n first. That way,
we have some idea about n at first, from which we can understand the nature of the
problem. Sometimes we have to find special prime factors first. The special
prime factors can provide some extra information necessary.
Solution. Here, we consider the smallest prime divisor of n. Let’s call this prime
n n
p. Since n divides 2 − 1, p divides it too. Because 2 − 1 is odd, both n and p must be
odd. So
n
2 ≡ 1 (mod p)
This equation alone does not say a lot, so we need more information. Remember
Fermat’s little theorem! This is another reason to find primes first. Only for primes
p−1 φ(n)
we can get the power a , otherwise from Euler’s Totient theorem, it would be a
which would bring troubles in this case. We have
p−1
2 ≡ 1 (mod p)
Whenever you get two congruences like this, be sure to use theorem (39). Using this,
(n,p−1)
2 ≡ 1 (mod p)
Now you will see why we specifically chose the smallest prime divisor instead of an
arbitrary prime divisor. Since p is the smallest prime divisor of n, if a prime q divides
p − 1, it can not divide n. Because if q∣n, then q ≤ p − 1 < p, which is a smaller
prime divisor than the smallest prime divisor of n, a contradiction! We must have
(n, p − 1) = 1. But then 2 ≡ 1 (mod p) or p∣2 − 1 = 1. Another contradiction. This
1
means for no prime p, n is divisible by p. So n can not have any primes i.e. n = 1.
Note. Not just smallest prime divisor, depending on the problem we occasionally take
the greatest prime divisor or something that makes our job easier to do. See the
following problems for better understanding.
Problem 283. Determine all pairs of primes (p, q) such that pq ∣ p + q + 1.
p q
Solution. If (p, q) is a solution, so is (q, p). Without loss of generality, assume that
p q q
p < q since p = q implies p∣1. Now, pq∣p + q + 1 gives us two things: p∣q + 1
p p
and q∣p + 1.. Consider p = 2, then q∣p + 1 = 5, so q = 5. Now, p is odd and so
q > p + 1. We can alternatively write them as q ≡ 1 (mod p) and p ≡ 1 (mod q).
2q 2p
296
§6. Lifting the Exponent Lemma Masum Billal, Amir Hossein
p p
5 − 2 ≡ 5 − 2 ≡ 3 (mod p)
Lifting The Exponent Lemma is a powerful method for solving exponential Diophantine
equations. It is pretty well-known in the literature though its origins are hard to trace.
Mathematically, it is a close relative of Hensel’s lemma in number theory (in both the
statement and the idea of the proof). This is a technique that has been used a lot in
recent Olympiad problems.
One can use the Lifting The Exponent Lemma (this is a long name, let’s call it
LTE!) in problems involving exponential equations, especially when there are some
prime numbers (and is actually an overkill for many problems). This lemma shows how
n n
to find the greatest power of a prime p – which is often ≥ 3 – that divides a ± b for
some positive integers a and b. The advantage of this lemma is that, it is quite simple
to understand and if in some contest, it is refrained from being used, the proof is not
hard as well.
In section (§4.3) of chapter (III), we defined vp (n). Recall that vp (n) is the highest
power of a prime p which divides a positive integer n. Here, we will make use of this
function to solve Diophantine equations.
Here is a problem which will explain the main idea behind LTE.
Problem 285. Show that there exist no positive integers x and y such that
6x+1 2y
2 +1=3
297
§6. Lifting the Exponent Lemma Masum Billal, Amir Hossein
Solution. The idea is that the largest power of 3 which divides the right side of the
given equation, should be the same as that of the left side. Clearly, v3 (3 ) = 2y. Let’s
2y
find v3 (2
6x+1
+ 1). Since 6x + 1 = 2 ⋅ 3 ⋅ x + 1 is odd, we can write
6x+1 6x 6x−1 6x−2
2 + 1 = (2 + 1) (2 −2 +2 − ⋯ − 2 + 1)
(2 − 2
6x 6x−1 6x−2
+2 − ⋯ − 2 + 1) is not divisible by 3 (try to figure out why, using
induction on x). Therefore
6x+1 6x 6x−1 6x−2
v3 (2 + 1) = v3 (2 + 1) + v3 (2 −2 +2 − ⋯ − 2 + 1)
=1+0
=1
This means that 2y = 1, which is impossible since y is an integer.
298
§6. Lifting the Exponent Lemma Masum Billal, Amir Hossein
Proof. We may use induction on vp (n). First, let us prove the following statement:
p p
(7) vp (x − y ) = vp (x − y) + 1
and
2 p−1 p−2 p−2 p−1
(9) p ∤x +x y + ⋯ + xy +y
This means
t p−1−t p−1 p−2 2
yx ≡x + tkpx (mod p )
299
§6. Lifting the Exponent Lemma Masum Billal, Amir Hossein
So we proved the relation (9) and the proof of equation (7) is complete. Now let us
return to our problem. We want to show that
n n
vp (x − y ) = vp (x − y) + vp (n)
α
Suppose that n = p b where gcd(p, b) = 1. Then
α α
n n p b p b
vp (x − y ) = vp ((x ) − (y ) )
α α α−1 α−1
p p p p p p
= vp (x − y ) = vp ((x ) − (y ))
α−1 α−1 α−2 α−2
p p p p p p
= vp (x −y ) + 1 = vp ((x ) − (y ) )+1
α−2 α−2
p p
= vp (x −y )+2
..
.
1 1
p 1 p 1
= vp ((x ) − (y ) ) + α − 1 = vp (x − y) + α
= vp (x − y) + vp (n)
Theorem 201 (Second Form of LTE). Let x, y be two integers, n be an odd positive
integer, and p be an odd prime such that p ∣ x + y and none of x and y is divisible by
p. We have
n n
vp (x + y ) = vp (x + y) + vp (n)
Proof. This is obvious using theorem (200). See the trick we used in proof of lemma
(27).
300
§6. Lifting the Exponent Lemma Masum Billal, Amir Hossein
Theorem 203 (LTE for p = 2). Let x and y be two odd integers such that 4 ∣ x − y.
Then
n n
v2 (x − y ) = v2 (x − y) + v2 (n)
Proof. We showed that for any prime p such that gcd(p, n) = 1, p ∣ x − y and none of
x and y is divisible by p, we have
n n
vp (x − y ) = vp (x − y)
Factorization gives
n n n−1 n−1 n−2 n−2
2 2 2 2 2 2 2 2
x −y = (x +y )(x +y )⋯(x + y )(x + y)(x − y)
k k
Now since x ≡ y ≡ ±1 (mod 4) then we have x ≡ 1 (mod 4) for all positive
2 2
≡y
k k
integers k and so x + y ≡ 2 (mod 4), k = 1, 2, 3, . . . . Also, since x and y are odd and
2 2
4 ∣ x − y, we have x + y ≡ 2 (mod 4). This means the power of 2 in all of the factors
in the above product (except x − y) is one. We are done.
Theorem 204. Let x and y be two odd integers and let n be an even positive integer.
Then
n n
v2 (x − y ) = v2 (x − y) + v2 (x + y) + v2 (n) − 1
Proof. We know that the square of an odd integer is of the form 4k + 1. So for odd x
and y we have 4 ∣ x − y . Now let m be an odd integer and k be a positive integer such
2 2
k
that n = m ⋅ 2 . Then
k k
n n m⋅2 m⋅2
v2 (x − y ) = v2 (x −y )
k−1 k−1
2 2 2 2
= v2 ((x ) − (y ) )
..
.
2 2
= v2 (x − y ) + k − 1
= v2 (x − y) + v2 (x + y) + v2 (n) − 1
§6.4 Summary
Let p be a prime number and let x and y be two (not necessarily positive) integers that
are not divisible by p. Then:
301
§6. Lifting the Exponent Lemma Masum Billal, Amir Hossein
• if p ≠ 2 and p ∣ x − y, then
n n
vp (x − y ) = vp (x − y) + vp (n)
• if p = 2 and 4 ∣ x − y, then
n n
v2 (x − y ) = v2 (x − y) + v2 (n)
Note. The most common mistake in using LTE is when you do not check the p ∣ x ± y
condition, so always remember to check it. Otherwise your solution will be completely
wrong.
302
§6. Lifting the Exponent Lemma Masum Billal, Amir Hossein
a
1. m > 1. We can prove by induction that 3 ≥ a + 2 for all integers a ≥ 1, and so
we have v3 (k) ≤ k − 2 (why?). Let M = max(x, y). Since x + y = 3 ≥ 9, we
m
have M ≥ 5. Then
k k k k−1
x +y ≥M = M ⋅M
ÍÎÌÏ Í ÎÌ Ï
x+y 1 m
≥ 2
= 2 ⋅3 ≥5k−1
1 m k−1
> 3 ⋅5
2
m k−2
>3 ⋅5
m+k−2
≥3
m+v3 (k)
≥3
n
=3
which is a contradiction.
1+v3 (k) k
2. m = 1. Then x + y = 3, so x = 1, y = 2 (or x = 2, y = 1). Thus 3 = 1+2 .
v (k) v (k)
But note that 3 3 ∣ k so 3 3 ≤ k. Thus
k v3 (k)+1
1+2 =3
v (k)
=3⋅3 3
Í ÎÌ Ï
≤k
≤ 3k
k
⟹ 2 + 1 ≤ 3k
And one can check that the only odd value of k > 1 that satisfies the above
inequality is k = 3. So (x, y, n, k) = (1, 2, 2, 3), (2, 1, 2, 3) in this case.
Problem 287 (Balkan 1993). Let p be a prime number and m > 1 be a positive integer.
Show that if for some positive integers x > 1, y > 1 we have
p p
x +y x+y m
= ( )
2 2
then m = p.
303
§6. Lifting the Exponent Lemma Masum Billal, Amir Hossein
we should have m ≥ p. Let d = gcd(x, y), so there exist positive integers x1 and y1 with
gcd(x1 , y1 ) = 1 such that x = dx1 , y = dy1 , and
m−1 p p m−p m
2 (x1 + y1 ) = d (x1 + y1 )
1. Assume that p is odd. Take any prime divisor q of x1 + y1 and let v = vq (x1 + y1 ).
If q is odd, we see that
p p
vq (x1 + y1 ) = v + vq (p)
m−p m
vq (d (x1 + y1 ) ) ≥ mv
Problem 288. Find all positive integers a, b that are greater than 1 and satisfy
a b
b ∣a −1
Solution. Let p be the least prime divisor of b. Let m be the least positive integer for
which p∣a − 1. Then m∣b and m ∣ p − 1, so any prime divisor of m divides b and is
m
less than p. Thus, not to run into a contradiction, we must have m = 1. Now, if p is
odd, we have avp (b) ≤ vp (a − 1) + vp (b), so
a − 1 ≤ (a − 1)vp (b)
≤ vp (a − 1)
whence
a ≤ (a − 1)v2 (b) + 1
≤ v2 (a − 1) + v2 (a + 1)
which is possible only if a = 3 and v2 (b) = 1. Put b = 2B with odd B and rewrite the
condition as 2 B ∣ 3 − 1. Let q be the least prime divisor of B (now, surely, odd).
3 3 2B
Let n be the least positive integer such that q ∣ 3 −1. Then n ∣ 2B and n ∣ q −1 whence
n
304
§7. Zsigmondy’s Theorem Masum Billal, Amir Hossein
2009 2009 z
Problem 289. Find all positive integer solutions of the equation x +y =7
§7 Zsigmondy’s Theorem
2
Zsigmondy’s theorem (see Birkhoff and Vandiver and Zsigmondy ) is one of the
tactics that can easily tackle a good number of hard problems in recent years. This is
indeed a mighty theorem to be used in an olympiad. We do not prove this theorem here,
3
interested readers can see Billal and Riasat for a proof (it is completely elementary
although a little beyond the scope of this book).
Primitive Divisor. For a sequence of integers a1 , a2 , ⋯, an , ⋯ a prime number
p is a primitive divisor of an if p divides an but p doesn’t divide ak for any k < n.
4
Carmichael called such a prime an intrinsic divisor.
k
Example. Consider the sequence ak = 2 − 1. a1 = 1, a2 = 3, a3 = 7, a4 = 15. Note that,
a3 has primitive divisor 7 and a4 has the primitive divisor 5.
305
§7. Zsigmondy’s Theorem Masum Billal, Amir Hossein
n n
• a − b has a primitive divisor except when:
(a) a − b = 1, n = 1.
(b) a = 2, b = 1 and n = 6.
(c) a + b is a power of 2 and n = 2.
n n 3 3
• a + b has a primitive divisor for n ≥ 2 except for the case 2 + 1 .
Therefore
k l n n l k
p∣a +ab +a b +b
k k
We already know p∣a + b , so if n = l + m (since l ≤ n), then
l n n l
p∣ab +a b
l l m m
= a b (a + b )
Problem 290 (Japanese Math Olympiad, 2011). Find all 5−tuples (a, n, x, y, z) of
positive integers so that
n x y z
a − 1 = (a − 1)(a − 1)(a − 1)
306
§7. Zsigmondy’s Theorem Masum Billal, Amir Hossein
n
Solution. If a, n ≥ 3 and n > x, y, z, we already know from the theorem that a − 1
x y z
has a prime divisor that none of a − 1, a − 1 or a − 1 has. Therefore, two sides can
never be equal. We are left with cases n ≤ 3. Note that, n ∉ {x, y, z}. But a − 1
x
n
divides a − 1, so x divides n. Thus, n > x, y, z and hence a, n ≤ 3, like we said before.
Now, either a < 3 or n < 3. If a < 3, then a = 2 and
n x y z
2 − 1 = (2 − 1)(2 − 1)(2 − 1)
So, {x, y, z} = {2, 2, 3}. Only n < 3 is left to deal with and it is easy to check that there
are no solutions in this case.
Problem 291 (Polish Math Olympiad). If p and q are distinct odd primes, show that
pq
2 − 1 has at least three distinct prime divisors.
q
Solution. Without loss of generality, consider that 2 < q < p < pq. Then 2 − 1 has at
p q pq
least one prime factor, 2 − 1 has a prime factor that is not in 2 − 1 and 2 − 1 has a
p q p pq q pq
prime factor that is not in any of 2 − 1 or 2 − 1. Since 2 − 1∣2 − 1 and 2 − 1∣2 − 1,
we have three distinct prime factors.
Problem 292 (Hungary 2000, Problem 1). Find all 4−tuples (a, b, p, n) of positive
integers with p a prime number such that
3 3 n
a +b =p
Solution. To apply the theorem, first we need to make a and b relatively prime. If q is a
prime divisor of (a, b) = g, then q∣p. Therefore, g = p for some r. Let, a = p x, b = p y
r r r
Assume that m = n − 3r. Since the power is three, we need to consider the exceptional
case first. The case x = 2 and y = 1 when p = 3 and n − 3r = 2 produces infinitely many
3 3
solutions. Otherwise, x + y has a prime divisor that does not divide x + y. Obviously
x + y is divisible by p since x + y > 1. This is a contradiction. Therefore, the only
families of solutions are
r r r r
(a, b, p, n) ∈ {(2 ⋅ 3 , 3 , 3, 3r + 2), (3 , 2 ⋅ 3 , 3, 3r + 2)}
307
§8. Zsigmondy’s Theorem Masum Billal, Amir Hossein
In order to prove this theorem, let’s first prove the following lemma.
p1 ⋯pn n
Lemma 28. Let N = 2 + 1 where pi > 3 is a prime. Then N has at least 2
distinct prime divisors.
Proof. The number M = p1 p2 . . . pn has (1 + 1)(1 + 1) . . . (1 + 1) = 2 divisors. Say
n
Í ÎÌ Ï
n times
the divisors are
1 = d1 < d2 < ⋯ < d2n = p1 ⋯pn
d d
Then first 2 1 + 1 has the prime divisor 3. 2 2 + 1 has a divisor that is not 3. Generally,
d
each di > di−1 gives us a new primitive divisor that was not in 2 i−1 + 1. Therefore, we
n
have at least 2 distinct prime divisors.
Now we prove the theorem.
n
Proof. Let’s assume that these 2 primes are q1 , q2 , . . . , q2n . Then,
N = q1 q2 . . . q2n K
for some integer K
n
≥ 1. Thus, every divisor of D = q1 q2 . . . q2n is a divisor of N and so,
2
N has at least 2 divisors.
This theorem can be generalized even more.
Theorem 209. Let a, b, n be positive integers with a⊥b.
τ (n)
i. If 3 ∤ n, a + b has at least 2
n n
divisors. That is,
n n τ (n)
τ (a + b ) ≥ 2
n n τ (n)
ii. If n is odd and a − b > 1, a − b has at least 2 divisors. That is,
n n τ (n)
τ (a − b ) ≥ 2
n n
Problem 294 (Romanian TST 1994). Prove that the sequence an = 3 − 2 contains
no three numbers in geometric progression.
2
Solution. Assume to the contrary, an = am ak , since they are in geometric progression.
So
n n 2 k k m m
(3 − 2 ) = (3 − 2 )(3 − 2 )
Since k, m, n are distinct, we must have k < n < m. If not, we can not have n < k < m
or n > m > k because that would make one side larger. But due to the fact m > n, we
m m n n
get that, 3 − 2 has a prime divisor that does not divide 3 − 2 .
The next problem is taken from the IMO Shortlist.
Problem 295 (IMO Shortlist 2000). Find all positive integers a, m, and n such that
m n
a + 1 ∣ (a + 1)
Solution. Note that (a, m, n) = (1, m, n) is a solution for all m, n. (a, m, n) = (2, 3, n)
m
is a solution for n > 1. If m ≠ 3 and a, m ≥ 2, then a + 1 has a prime factor that is
not a prime factor of a + 1. Therefore, in such cases there are no solutions.
308
§8. How to Use Matrices Masum Billal, Amir Hossein
Matrices come to the rescue as a useful tool in many problems (for example, in Dio-
phantine equations or representation problems), and contribute a much better and more
elegant solution. But since we are not doing a linear algebra course, we will define and
discuss only what’s required here.
Matrix. A matrix is a rectangular array which can consist of numbers, variables, or
anything. Like a grid, it can have m horizontal rows and n vertical columns. So, there
are mn cells in a matrix. Then the matrix is of the size m × n. There are some common
notations for denoting matrix. But we will use the usual one:
Here, aij are the entries of the m × n matrix A. Notice how the index of each entry is
th th
written. The entry aij belongs to the i row and j column of the matrix.
⎛1 0 0⎞
A=⎜
⎜0 1 0⎟
⎟
⎝0 0 1⎠
⎛1 2⎞
⎜3 4⎟
B=⎜
⎜
⎜
⎟
⎟
⎜
⎜5 6⎟
⎟
⎟
⎝7 8⎠
−1 0 1 −1
C=( )
0 0 0 1
A is 3 × 3, B is 4 × 2, and C is 2 × 4.
Square Matrix. A matrix is square if the number of rows is equal to the number of
columns, i.e., m = n if the size is m × n. The example above is a square matrix as well.
Matrix Diagonals. Let Am×n be a matrix with entries aij . The main diagonal of
A is the collection of entries aij where i = j.
Identity Matrix. An square matrix An×n is called identity matrix and denoted by
In if entries of its main diagonal equal to one, and all other entries are zero.
309
§8. How to Use Matrices Masum Billal, Amir Hossein
Example. Matrix A in the previous example is a square matrix however B and C are
not. Moreover, I is an identity matrix of dimension 3, that is, A = I3 . The main
diagonal of matrix B is formed by the entries b11 = 1 and b22 = 4.
Matrices might seem a bit confusing. You might wonder why someone would create
matrices, what’s wrong with normal numbers? Before giving you an application of
where matrices are used, you should know how to do some basic matrix operations.
Matrix Addition. The matrix addition is the operation of adding two matrices by
adding the corresponding entries together. If A and B are m × n matrices, then
Note. The product AB is defined only if the number of columns in A equals the number
of rows in B.
310
§8. How to Use Matrices Masum Billal, Amir Hossein
Example. Let
⎛ ⎞
⎜
⎜ 1 1 5 ⎟
⎟
⎜
⎜ ⎟
⎟
A= ⎜
⎜
⎜
2 3 1 ⎟
⎟
⎟
⎜
⎜ ⎟
⎟
⎜
⎜ 4 6 1 ⎟
⎟
⎝ 2 1 3 ⎠
⎛ ⎞
⎜
⎜
3 1 0 2 ⎟
⎟
B= ⎜
⎜
⎜ 5 1 0 1 ⎟
⎟
⎟
⎜ ⎟
⎝ 4 0 1 1 ⎠
⎛ ⎞ ⎛ ⎞
⎜
⎜ 1 1 5 ⎟
⎟ ⎛ ⎞ ⎜ c11 c12 c13 c14 ⎟
⎜
⎜ ⎟
⎟ ⎜ 3 1 0 2 ⎟ ⎜ ⎜ c21 ⎟
⎟
⎜
⎜ 2 3 1 ⎟
⎟ ⎜
⎜ ⎟
⎟ = ⎜
⎜ c22 c23 c24 ⎟
⎟
⎜ ⎟ ⋅ ⎜
⎜ ⎟
⎟ ⎜ ⎟
⎜
⎜
⎜ 4 6 1 ⎟
⎟
⎟ ⎜ 5 1 0 1 ⎟ ⎜ ⎜
⎜ c31 c32 c33 c34 ⎟
⎟
⎟
⎜ ⎟ ⎝ 4 0 1 1 ⎠ ⎜ c ⎟
⎝ 2 1 3 ⎠ ⎝ 41 c42 c43 c44 ⎠
From the definition, the entry c11 of C is calculated by multiplying the corresponding
entries of the first row of A and the first column of B (and you can now see why number
of columns of A must be equal to the number of rows of B). That is,
c11 = 1 ⋅ 3 + 1 × 5 + 5 × 4 = 28
th
In general, the entry cij is calculated by multiplying the corresponding entries of i
th
row of A and j column of B. Do the product yourself and check the result with the
following:
⎛28 2 5 8 ⎞
⎜25 5 1 8 ⎟
C=⎜
⎜
⎜
⎜
⎟
⎟
⎟
⎜46 10 1 15⎟
⎟
⎝23 3 3 8 ⎠
Note. Let A and B be square matrices of the same dimension. Then both AB and
BA are defined. However, they are not necessarily equal, i.e., matrix multiplication is
not commutative.
2
Matrix Powers. For a square matrix An×n , we define A as the multiplication of A
k k−1
by itself. The definition of all higher powers of A is followed. In fact, A = A ⋅ A , for
0
any positive integer k. We also assume that A = In , where In is the n−dimensional
identity matrix.
311
§8. How to Use Matrices Masum Billal, Amir Hossein
For the simplest case when A is 1 × 1 (a single number), the determinant of A equals
A, which is sensible (what else would it be?). The definition above is not the exact
definition of the determinant. We will first explain how to calculate the determinant of
a 2 × 2 matrix and then move to the precise definition of determinants.
Definition. The determinant of a 2 × 2 matrix is the product of entries on its main
diagonal minus the product of the two other entries. That is, if
a b
A=( )
c d
»»1 2»»
»» »
Example. »»3 4»»» = 4 − 6 = −2.
»» »»
We will now generalize the definition of determinant to n × n matrices. For this,
you need to know what cofactors and minors are first.
Minor. Let A be an n × n matrix. The minor for entry aij is denoted by Mij and is
th th
the determinant that results when the i row and the j column of A are deleted.
⎛ ⎞
⎜ 1 1 5 ⎟
A= ⎜
⎜
⎜
⎜
⎟
⎟
⎟
⎟
⎜ 2 3 1 ⎟
⎝ 4 6 1 ⎠
The corresponding row and column (which should be deleted in order to calculate the
»»1 5»»
minor) are shown in the matrix. Therefore, M21 = »»»» »» = 1 − 30 = −29.
»
»»6 1»»»
⎛ 3 − 6 2 − 4 12 − 12⎞
M =⎜
⎜1 − 30 1 − 20 6 − 4 ⎟
⎟
⎝1 − 15 1 − 10 3 − 2 ⎠
⎛ −3 −2 0⎞
=⎜
⎜−29 −19 2⎟
⎟
⎝−14 −9 1⎠
312
§8. How to Use Matrices Masum Billal, Amir Hossein
Cofactor. The cofactor for any entry of a matrix is either the minor or the opposite
of the minor, depending on where the element is placed in the original determinant. If
the row and column of the entry add up to an even number, then the cofactor is the
same as the minor. If the row and column of the entry add up to an odd number, then
the cofactor is the opposite of the minor.
In other words, if we denote Cij to be the cofactor of the corresponding entry ai ,
then Cij = (−1) Mij .
i+j
Example. You are now be able to make sense of the definition of matrix of cofactors.
The matrix of cofactors of matrix A in previous examples is
M =⎜
⎜ ⎟
⎜(−1) (1 − 30) (−1) (1 − 20) (−1) (6 − 4) ⎟
3 4 5
⎟
⎝(−1) (1 − 15) (−1) (1 − 10) (−1) (3 − 2) ⎠
4 5 6
⎛ −3 2 0⎞
=⎜
⎜ 29 −19 −2⎟
⎟
⎝−14 9 1⎠
See the difference between the matrix of minors and the matrix of cofactors of A.
Now you are ready to see a formula for determinant. Our method is computing
larger determinants in terms of smaller ones.
Definition. Given the n × n matrix A with entries aij , the determinant of A can be
written as the sum of the cofactors of any row or column of A multiplied by the entries
th
that generated them. In other words, the cofactor expansion along the j column gives
th
The cofactor expansion along the i row gives:
Example. Consider the matrix A in the previous examples. If we use the cofactor
expansion along the second column, we get
313
§8. How to Use Matrices Masum Billal, Amir Hossein
Also, if we use the cofactor expansion along the third row, we get
Note that we used the matrix of cofactors found above for Cij . As you see, the result
of both calculations is the same.
If you carefully track what we explained until now, you see that we used the de-
terminant of 2 × 2 matrices when calculating the matrix of cofactors of A. Then, in
order to calculate det(A), we used some entries of the matrix of cofactors of A. All in
all, we have used the determinant of 2 × 2 matrices when calculating the determinant
of the 3 × 3 matrix A. This process is the same for larger matrices. For example, in
order to find determinant of a 4 × 4 matrix, you need to calculate four 3 × 3 matrices
determinants.
Finding the determinant of large matrices (larger than 4 × 4) is a really boring job
and we do not want you to calculate such determinants. You know the basics and you
can find the determinant of any n × n matrix. It’s just the matter of time it takes to
find it.
The definition of the determinant may seem useless to you, but it actually is im-
possible to find the inverse of a matrix without knowing its determinant. However, we
are not going to introduce inverse matrices. We want to use determinants in a number
theoretical approach. We will only use the formula for determinant of 2 × 2 matrices,
however we included the definition of the determinant so that you can find 3 × 3 (or
even larger) determinants easily.
We state two theorems without proof. If you are interested in seeing a proof, you
can read any book on linear algebra.
Theorem 210. Let A and B be n × n matrices. The product of the determinant of A
and B equals the determinant of their product, i.e.,
314
§8. How to Use Matrices Masum Billal, Amir Hossein
2 2
so we try to represent x + dy in the form ad − bc, which is the determinant of some
matrix. This is pretty simple. Assume the matrices
x yd
M=( )
−y x
u vd
N =( )
−v u
2 2 2 2 2 2
(x + dy )(u + dv ) = (xu − dvy) + d(vx + uy)
which is of the same form.
2 2
Problem 298. Prove that the product of two numbers of the form x − dy is again
of the same form.
Solution. This is the same as previous one. The only difference is that the matrix
would be
x yd
M=( )
y x
Problem 299. Prove that the following equation has infinitely many solutions for
integers a, b, c, d, e, and f :
2 2 2 2 2 2
(a + ab + b )(c + cd + d ) = (e + ef + f )
Solution. The following identity gives an infinite family of solutions:
2 2 4 2
(x + x + 1)(x − x + 1) = x + x + 1
But we present a different solution using matrices. In fact, we can prove that for any
quartet (a, b, c, d) there are integers e and f such that
2 2 2 2 2 2
(a + ab + b )(c + cd + d ) = (e + ef + f )
Again, we need to choose a suitable matrix to prove our claim. We choose
a b
A=( )
−b a + b
c d
B=( )
−d c + d
After this, the process is analogous to previous problems.
Note. We could factorize a + ab + b as (a + ζb)(a + ζ b), where ζ = 1 is the third root
2 2 2 3
of unity (don’t worry if this is unfamiliar for you, it needs some knowledge in complex
numbers).
315
§8. How to Use Matrices Masum Billal, Amir Hossein
0, 1, 1, 2, 3, 5, 8, 13, ⋯
p q G Gn−1 G Gn
( )( n ) = ( n+1 )
1 0 Gn−1 Gn−2 Gn Gn−1
Corollary 44.
n
1 1 F Fn
( ) = ( n+1 )
1 0 Fn Fn−1
Corollary 46.
2 n−1
Ln+1 Ln−1 − Ln = 5 ⋅ (−1)
316
§9. A Proof for the Law of Quadratic Reciprocity Masum Billal, Amir Hossein
1 1
Solution. Consider I = ( ). Then, I
m+n m n
= I I . Note that
1 0
Fm+1 Fm
=( )
m
I
Fm Fm−1
Fn+1 Fn
I =( )
n
Fn Fn−1
Fm+n+1 Fm+n
=( )
m+n
I
Fm+n Fm+n−1
Thus
Fm+1 Fm F Fn F F + Fm Fn Fm+1 Fn + Fm Fn−1
( ) ⋅ ( n+1 ) = ( m+1 n+1 )
Fm Fm−1 Fn Fn−1 Fm Fn+1 + Fm−1 Fn Fm Fn + Fm−1 Fn−1
We finally find that
Fm+1 Fn+1 + Fm Fn Fm+1 Fn + Fm Fn−1 F Fm+n
( ) = ( m+n+1 )
Fm Fn+1 + Fm−1 Fn Fm Fn + Fm−1 Fn−1 Fm+n Fm+n−1
Equating the cells of these two matrices, we get
Fm+n+1 = Fm+1 Fn+1 + Fm Fn
The following corollaries are immediately concluded.
Corollary 47.
Fmk+n = Fmk+1 Fn + Fmk Fn−1
Corollary 48. Setting m = n, we have
2 2
F2n+1 = Fn + Fn+1
We end the discussion here, but hopefully you have a better idea of how useful
matrices can actually be.
Law of quadratic reciprocity (theorem (58)) states that for any two different odd primes
p and q, we have
p q p−1 q−1
( q ) ( p ) = (−1) 2 2
⋅
317
§9. A Proof for the Law of Quadratic Reciprocity Masum Billal, Amir Hossein
Mathematicians have provided many proofs for the law of quadratic reciprocity.
Gauss himself proved this theorem as well. However, we will be showing arguably the
5
most amazing proof of this theorem, which is due to Eisenstein . Before explaining the
proof, we should prove two lemmas.
Lemma 29. Let p be a prime and let a be an integer co-prime to p. When the numbers
a, 2a, . . . p−1
2
a are reduced modulo p into the range from − p−1
2
to p−1
2
, the reduced values
p−1
are ±1, ±2, . . . , ± 2 in some order, with each number appearing once with either a plus
sign or a minus sign.
a⊥p, we get k − t ≡ 0 (mod p). But since k and t are both at most p−1 2
, we should have
k − t = 0 or k = t. On the other hand, if ak ≡ −at (mod p), then k + t ≡ 0 (mod p).
But
p−1 p−1
k+t≤ + =p−1
2 2
so it’s impossible to have k + t ≡ 0. This finishes the proof.
The second lemma uses the definition of µ(a, p) which we defined in Gauss’s Crite-
rion (theorem (56)).
Lemma 30. Let p be a prime and let a be an odd integer co-prime to p. Then
p−1
2
ka
∑ ⌊ p ⌋ ≡ µ(a, p) (mod 2)
k=1
ka = pqk + rk
p−1 p−1
− < rk <
2 2
Notice that this is different from the normal division (try to see why we can write ka
like that). Now divide both sides by p to get
ka rk
⌊ p ⌋ = qk + ⌊ p ⌋
1 rk
− < p
2
1
<
2
5
Do not confuse it with Einstein.
318
§9. A Proof for the Law of Quadratic Reciprocity Masum Billal, Amir Hossein
p−1 p−1
2 2
ka
∑ ⌊ p ⌋ = ∑ qk − X
k=1 k=1
where X is the number of negative rk s. If you look more closely, you see that X = µ(a, p)
(why?), and so
p−1 p−1
2 2
ka
∑ ⌊ p ⌋ = ∑ qk − µ(a, p)
k=1 k=1
p−1
which is just what we want. The trick is to write the equation ka = pqk + rk modulo 2.
Since both a and p are odd, ka ≡ k (mod 2) and pqk ≡ qk (mod 2), and so
k ≡ qk + rk (mod 2)
∑ k ≡ ∑ qk + ∑ rk (mod 2)
k=1 k=1 k=1
From lemma (29), we see that the numbers r1 , r2 , . . . , r p−1 are equal to the numbers
2
∑ rk ≡ ∑ k (mod 2)
k=1 k=1
p−1
2
⟹ ∑ qk ≡ 0 (mod 2)
k=1
319
§9. A Proof for the Law of Quadratic Reciprocity Masum Billal, Amir Hossein
Proof of law of quadratic reciprocity. This proof is based on geometry, and that’s in-
teresting. Consider a triangle in the xy-plane with vertices on (0, 0), (p/2, 0), and
(p/2, q/2).
• • • • • ( p2 , 2q )
• • • • • • •
• • • • • • •
• • • • • • •
• • • • • • •
• • • • • • •
• • • • • • •
• • • • • • •
(0, 0) ( 2 , 0)
p
The number of points with integer coordinates inside this triangle equals
p−1
2
kq
∑⌊ p ⌋
k=1
You can easily verify this by using the fact that the hypotenuse of triangle lies on the
line y = pq x, and so the number of points with x = k (where 1 ≤ k ≤ p−1 2
) inside the
triangle equals ⌊ kq
p
⌋ (actually, we are counting the points vertically).
Now consider the triangle with vertices on (0, 0), (0, q/2), and (p/2, q/2).
320
§9. A Proof for the Law of Quadratic Reciprocity Masum Billal, Amir Hossein
• • • • • ( p2 , 2q )
(0, 2q )
• • • • • • •
• • • • • • •
• • • • • • •
• • • • • • •
• • • • • • •
• • • • • • •
• • • • • • •
(0, 0)
We can find the number of points with integer coordinates inside this triangle in a
similar way to the previous one. This time, count the points horizontally and sum up
the number of points with y = 1, y = 2, . . ., and y = p−1
2
. The result is
q−1
2
kp
∑⌊ q ⌋
k=1
Now put these two triangles together to form a rectangle with vertices on (0, 0), (0, q/2),
(p/2, 0), and (p/2, q/2).
Let x be number of the points with integer coordinates inside this rectangle. Obvi-
ously, x is equal to the sum of such points in triangles (notice that since p and q are
different, there is no point with integer coordinates on the hypotenuse of triangles). So
p−1 q−1
2 2
kq kp
x = ∑⌊ p ⌋ + ∑⌊ q ⌋
k=1 k=1
321
§10. Darij-Wolstenholme Theorem Masum Billal, Amir Hossein
• • • • • ( p2 , 2q )
(0, 2q )
• • • • • • •
• • • • • • •
• • • • • • •
• • • • • • •
• • • • • • •
• • • • • • •
• • • • • • •
(0, 0) ( p2 , 0)
p−1 q−1
µ(q, p) + µ(p, q) ≡ ⋅ (mod 2)
2 2
Now apply Gauss’s criterion to finish the proof:
p q µ(p,q) µ(q,p)
( q ) ( p ) = (−1) ⋅ (−1)
µ(p,q)+µ(q,p)
= (−1)
p−1 q−1
= (−1) 2
⋅ 2
322
§10. Darij-Wolstenholme Theorem Masum Billal, Amir Hossein
Recall section (§4.3) where we defined vp (x) for x being an integer as the greatest
power of p which divides x. Now, since we are working with fractions, we need to
generalize this concept to include rational numbers.
Definition. Let p be a prime and let x = ab ≠ 0 be a rational number reduced to
lowest terms. Define the p-adic evaluation of x as vp (x) = vp (a) − vp (b).
Example. v3 ( 16
9
) = 2, and v5 ( 34
25
) = −2.
Note. We can easily check the sign of vp (x) for any rational number x = ab . If p ∣ a,
then vp (x) > 0. If p divides none of a and b, then vp (x) = 0. And if p ∣ b, then
vp (x) < 0. Also, vp (xy) = vp (x) + vp (y) and vp (x + y) ≥ min (vp (x) , vp (y)) for all
rationals x and y.
(mod p) because
p−2 1
Solution. Let a⊥p be an integer. We can write a ≡ a
p−1
1 a −1
vp (a − a ) = vp (
p−2
a )>0
The idea of the proof is similar to the proof of Wolstenholme’s theorem. We need
to prove a lemma first.
Lemma 31. Let p be a prime and let n be an integer such that 1 ≤ n ≤ p − 2. Then
p−1
n
∑ k ≡ 0 (mod p)
k=1
323
§10. Darij-Wolstenholme Theorem Masum Billal, Amir Hossein
(40) says that the set B = {0, a , (2a) , . . . , ((p − 1)a) } also forms a complete residue
n n n
system modulo p. Therefore, the sum of elements of both sets are equivalent modulo
p. So
p−1 p−1
n n
∑ k ≡ ∑(a ⋅ k)
k=1 k=1
p−1
n n
≡ a ∑k (mod p)
k=1
p−1
k n
(a − 1) ∑ k ≡ 0 (mod p)
k=1
p−1
n
∑ k ≡ 0 (mod p)
k=1
If the proof seemed confusing to you, here is a potentially better version. Consider a
primitive root g of p (we already know there is one from modular arithmetic chapter).
Then we also know that {1, 2, . . . , p−1} can be generated by g (the set {1, g, g , . . . , g }).
2 p−2
So,
n n n n n 2n p−2 n
1 + 2 + ⋯ + (p − 1) = 1 + g + g + ⋯ + (g )
(g ) − 1
n p−1
=
gn − 1
(p−1)n
g −1
= n
g −1
Proof of Darij-Wolstenholme Theorem. The idea is to use the trick explained in lemma
324
§10. Darij-Wolstenholme Theorem Masum Billal, Amir Hossein
1 1
(2). That is, we write the given sum as a sum of terms of the form ku
+ (p−k) u . We have
We have used the fact that u is an odd integer to expand (p − k) in above lines. Now
u
So instead of showing
p−1
1
vp (2 ∑ )≥2
k=1
ku
325
§10. Darij-Wolstenholme Theorem Masum Billal, Amir Hossein
Since
u−1 u−2 u−1 u−1
p − up k + ⋯ + uk ≡ uk (mod p)
u u u u
k (p − k) ≡ k (−k)
u 2u
≡ (−1) k (mod p)
p − 1 2p
2⋅ ≤
3 3
p−1
<2⋅ +1
3
326
§10. Darij-Wolstenholme Theorem Masum Billal, Amir Hossein
which means
2p p−1
⌊ ⌋=2⋅
3 3
2p p−1
⌊⌊ ⌋/2⌋ = ⌊ (2 ⋅ )/2⌋
3 3
p−1
=
3
Finally,
2p p−1
p−⌊( )/2⌋ = p −
3 3
p−1
=2⋅ +1
3
2p
=⌊ ⌋+1
3
as desired.
p−2 2p
2⋅ +1≤
3 3
p−2
< (2 ⋅ + 1) + 1
3
This gives
2p p−2
⌊⌋=2⋅ +1
3 3
2p p−2
⌊⌊ ⌋/2⌋ = ⌊ (2 ⋅ + 1)/2⌋
3 3
p−2 1
=⌊ + ⌋
3 2
p−2
=
3
And finally
2p p−2
p − ⌊⌊ ⌋/2⌋ = p −
3 3
p−2
= (2 ⋅ + 1) + 1
3
2p
=⌊ ⌋+1
3
327
§11. Darij-Wolstenholme Theorem Masum Billal, Amir Hossein
The proof of equation (15) is finished. We will now prove the problem. Obviously,
⌊2p/3⌋
(−1)
i−1
1 −1
∑ = ∑ + ∑
i=1
i i i
1≤i≤⌊2p/3⌋; 1≤i≤⌊2p/3⌋;
i is odd i is even
1 1
= ∑ − ∑
i i
1≤i≤⌊2p/3⌋; 1≤i≤⌊2p/3⌋;
i is odd i is even
⎛ ⎞
⎜
=⎜
1 1⎟
⎟
1
⎜ ∑
⎜ i
+ ∑
i ⎟
⎟ −2 ∑
i
⎝1≤i≤⌊2p/3⌋; 1≤i≤⌊2p/3⌋; ⎠ 1≤i≤⌊2p/3⌋;
i is odd i is even i is even
⌊2p/3⌋
1 1
= ∑ −2 ∑
i=1
i i
1≤i≤⌊2p/3⌋;
i is even
⌊2p/3⌋ ⌊⌊2p/3⌋/2⌋
1 1
= ∑ −2 ∑
i=1
i j=1
2j
⌊2p/3⌋ ⌊⌊2p/3⌋/2⌋
1 1
= ∑ + ∑
i=1
i j=1
−j
⌊2p/3⌋ ⌊⌊2p/3⌋/2⌋
1 1
≡ ∑ + ∑ (mod p)
i=1
i j=1
p−j
In the second sum in the last line of above equations, we have used the fact that
−j ≡ p − j (mod p). Replacing j by p − i in the second sum, we have
⌊2p/3⌋ ⌊2p/3⌋ p−1
(−1)
i−1
1 1
∑ ≡ ∑ + ∑
i=1
i i=1
i i
i=p−⌊⌊2p/3⌋/2⌋
Wilson’s theorem says that (p − 1)! ≡ −1 (mod p) for all primes p. Clearly, for any
integer n larger than p, we have n! ≡ 0 (mod p). Now, if we remove the multiples of p
from n! and then calculate the result modulo p, what would it be? We will state this
as a generalization for Wilson’s theorem. But first, some definitions and lemmas.
Definition. Let n be a positive integer and p a prime number. The p-reduced factorial
of n is the product of all positive integers less than or equal to n which are not divisible
by p. We denote this by (n!)p .
(10!)5 = 9 × 8 × 7 × 6 × 4 × 3 × 2 × 1
= 72, 576
Theorem 215. Let p be a prime number and let (nk nk−1 ⋯n1 n0 )p be a positive integer.
Then
⌊n ⌋
(n!)p ≡ (−1) p
⋅ n0 ! (mod p)
1 2 ⋯ n0 ⋯ p−1
p+1 p+2 ⋯ p + n0 ⋯ 2p − 1
.. .. .. .. .. ..
. . . . . .
([ np ] − 1)p + 1 ([ np ] − 1)p + 2 ⋯ ([ np ]p − 1)p + n0 ⋯ [ np ]p − 1
[ np ]p + 1 [ np ]p + 2 ⋯ [ np ]p + n0
⎛[ p ]−1
n
⎞
⎜
⎜ ∏ ((kp + 1) ⋅ (kp + 2)⋯(kp + p − 1)) ⎟
⎟ ⋅ ([ p ]p + 1) ([ p ]p + 2) . . . ([ p ]p + n0 )
n n n
⎝ k=0 ⎠
which is equal to
⎛[ p ]−1 ⎛[ p ]−1
n n
⎞ ⎞
⎜
⎜ ∏ (1 ⋅ 2⋯(p − 1)) ⎟
⎟ ⋅ ([ n
]p + 1) ([ n
]p + 2) . . . ([ n
]p + n0 ) ≡ ⎜
⎜ ∏ (−1)⎟
⎟ ⋅ (1 ⋅ 2⋯n0 )
p p p
⎝ k=0 ⎠ ⎝ k=0 ⎠
[n ]
≡ (−1) p
n0 ! (mod p)
329
§11. Generalization of Wilson’s and Lucas’ Theorem Masum Billal, Amir Hossein
Proof. This is exactly the same as the proof of Wilson’s theorem. All numbers in the
product (p !)p have a multiplicative inverse modulo p . If the inverse of a number a
n n
among these numbers is b ≠ a, then ab ≡ 1 (mod p ) and we can remove a and b from
n
the product (p !)p . Our only concern is when the inverse of a equals a itself. But if
n
1 or p − 1. All in all, we see that the product of all numbers in (p !)p except p − 1
n n n
n n
equals 1 modulo p , and if we multiply this number by p − 1, the result will be −1
n
modulo p .
Theorem 216 (Generalization of Wilson’s Theorem). Let p be a prime number and let
(nk nk−1 ⋯n1 n0 )p be the representation of a positive integer n in base p. Then
n! vp (n!)
(16) vp (n!)
≡ (−1) n0 !n1 ! . . . nk ! (mod p)
p
Proof. According to Theorem 215, one can write
⌊n/p⌋ n
n! = (n!)p ⋅ p (⌊ p ⌋)!
⌊n/p⌋ ⌊n/p⌋ n
≡ (−1) n0 ! ⋅ p (⌊ p ⌋)!
Now write (⌊ np ⌋)! in the same way and continue this process. The result is concluded.
Note. If you are interested, you can find a (different) generalization of Wilson’s theorem
in Problem 108.
1 m m0 ! md !
( ) ≡ (−1) ( )⋯ ( )
ℓ
ℓ n
(mod p)
p n0 !r0 ! nd !rd !
330
§12. Inverse of Euler’s Totient Function Masum Billal, Amir Hossein
m
ℓ = vp (( n ))
m!
= vp ( )
n!r!
= vp (n!) − vp (n!) − vp (r!)
k k k
m n r
= ∑⌊ i⌋ − ∑⌊ i⌋ − ∑⌊ i⌋
i=1
p i=1
p i=1
p
k
m n r
= ∑ (⌊ i
⌋ − ⌊ i ⌋ − ⌊ i ⌋)
i=1
p p p
For a given positive integer n, we can find φ(n) after factorizing n. What about the
reverse problem? That is, given φ(n), can you find n? A more interesting question is
whether this solution n is unique or there are other solutions. We can answer the latter
question pretty quickly using an example: φ(4) = 2 and φ(6) = 2. In other words, φ is
not a one to one function. Now, another question normally arises here:
Problem 304. Is there any n ∈ N such that φ(x) = n has a unique solution for x?
There are good results on this topic. It has also been studied how to find such x,
and the upper or lower bounds of x. Here we will discuss some of the results, which fits
into our book.
Let n be a positive integer. Assume that φ (n) is the set of all
−1
Inverse Phi.
possible values of x ∈ N such that φ(x) = n. In other words,
φ (n) = {x ∶ φ(x) = n}
−1
We call φ (n) the inverse of Euler’s totient function, or simply the inverse of phi
−1
function. Moreover, for ever positive integer x, we define N (x) to be the number of
positive integers y such that φ(x) = φ(y).
331
§12. Inverse of Euler’s Totient Function Masum Billal, Amir Hossein
greater than 1 but due to his proof being inadequate, this is a conjecture now:
Conjecture 14 (Carmichael’s Totient Conjecture). For a positive integer n, the number
of solutions to φ(x) = n is either 0 or at least 2.
After this statement, quite a lot of number theorists worked on it. There has been
no proof of the theorem to our knowledge, though there are some nice results on it.
And it is indeed a very interesting topic to work on. Even though it is a conjecture,
everything points this to be true. For example, Jr pointed out that if N (x) = 1 then
7
400 37
x and φ(x) are both larger than 10 . Carmichael originally proved that x > 10 must
be true. Let’s start investigating N (x).
Theorem 218. Let x be a positive integer. If N (x) = 1, then x is divisible by 4.
Proof. For n > 2, φ(n) is always even. If x is odd, then 2⊥x so φ(2x) = φ(x) so y = 2x
is a solution, so contradiction. Again, if x = 2t with t odd then φ(x) = φ(t) by same
argument. Thus, x is divisible by 4.
The following theorem is due to Carmichael.
k
Theorem 219. Let x be a positive integer and let p = 2 + 1 be a prime divisor of x,
where k is some natural number. If N (x) = 1, then p ∣ x.
2
e
Proof. To the contrary, assume that x = 2 ps for some positive integers e and s with
s⊥2p. Then,
e
φ(x) = φ(2 )φ(p)φ(s)
e−1 k
=2 2 φ(s)
k+e
= φ(2 )φ(s)
k+e
= φ(2 s)
s ≠ x satisfies the condition, so we must have p ∣ s and hence p ∣ x.
k+e 2
Thus, y = 2
Here is a very nice result that provides us with a sufficient condition for N (x) = 1
8
to happen. The result is due to Pomerance.
Theorem 220 (Carl Pomerance). Let x be a positive integer. Suppose that the following
property holds for every prime p:
p − 1 ∣ φ(x)
2
⟹ p ∣x
Then N (x) = 1. That is, if φ(y) = φ(x) for some positive integer y, then y = x.
6
Robert Daniel Carmichael
1907 “On Euler’s φ-function”, Bull. Amer. Math. Soc., vol. xiii, pp. 241-243.
7
Victor Klee Jr
1947 “On a conjecture of Carmichael”, Bulletin of the American Mathematical Society, vol. liii, no. 12,
pp. 1183-1187, doi: 10.1090/s0002-9904-1947-08940-0.
8
Carl Pomerance
1974 “On Carmichael’s Conjecture”, Proceedings of the American Mathematical Society, 2nd ser.,
vol. xliii (Apr. 1974), pp. 297-298.
332
§12. Inverse of Euler’s Totient Function Masum Billal, Amir Hossein
Proof. For every positive integer n, define S(n) to be the set of prime divisors of n. If
r e
the prime factorization of n is ∏i=1 pi i , then
r
e −1
φ(n) = ∏ pi i (pi − 1)
i=1
According to our assumption, x is a positive integer such that if p−1 ∣ φ(x) then p ∣ x.
2
We are required to prove that under this assumption, if φ(x) = φ(y) then x = y must
hold. If p ∈ S(y) then p − 1 ∣ φ(y) = φ(x). So, from the assumption, p ∣ x for any
2
1. p divides n. Suppose that p ∥n. Then we have p ∣ φ(n). But is this the highest
e e−1
exponent possible? No. Because in the factorization of φ(n), there are factors of
the form (q − 1) for any other prime divisor q of n. If p ∣ q − 1 for any such q,
those will contribute to νp (φ(n)) as well. That is,
νp (φ(n)) = νp (n) − 1 + ∑ νp (q − 1)
q∈S(n)
2. p does not divide n. In this case, only factors of the form (q − 1) for any prime
divisor q of n may contribute to νp (φ(n)). In other words,
νp (φ(n)) = ∑ νp (q − 1)
q∈S(n)
Combining these two results, we find out that for any prime p and any positive
integer n,
∑q∈S(n) νp (q − 1) if p ∤ n
νp (φ(n)) = {
νp (n) − 1 + ∑q∈S(n) νp (q − 1) otherwise
Let p be a prime factor of x. Since φ(x) = φ(y), for any prime p, we must have
νp (φ(x)) = νp (φ(y))
1. p ∉ S(y) or p ∤ y. Then,
νp (x) − 1 + ∑ νp (q − 1) = ∑ νp (q − 1)
q∈S(x) q∈S(y)
≤ ∑ νp (q − 1)
q∈S(x)
since S(y) ⊆ S(x). The latter result implies νp (x) ≤ 1. But this is impossible since
νp (x) ≥ 2 due to the fact that p ∣ x.
2
333
§12. Inverse of Euler’s Totient Function Masum Billal, Amir Hossein
2. p ∈ S(y). That is, p ∣ y, or S(x) = S(y). In this case we should expect to get x = y.
One way to prove this is to show that νp (x) = νp (y). Notice that
νp (x) = νp (φ(x)) + 1 − ∑ νp (q − 1)
q∈S(x)
= νp (φ(y)) + 1 − ∑ νp (q − 1)
q∈S(y)
Gupta found upper and lower bounds for φ (n). For odd n, φ (n) is empty.
9 −1 −1
Theorem 221 (Gupta). Let m and n be two positive integers such that n ∈ φ (m).
−1
Then,
p
m<n≤m ∏
p−1
p−1∣m
Proof. For even n, m = φ(n) < n because φ(n) = n holds for n = 1 only. This proves
the lower bound. For the upper bound, we can write
n p
=∏
φ(n) p−1
p∣n
p
≤ ∏
p−1
p−1∣m
The last line is true because if p ∣ n then p − 1 ∣ m must hold, but the converse is not
true. If p − 1 ∣ m, p may or may not divide n.
Theorem 222. Let m be a positive integers and suppose that φ (m) contains A ele-
−1
ments. Then, the number of odd elements of φ (m) is less than or equal to A/2.
−1
Proof. For a positive integer n, if φ(n) = m then φ(2n) = m is true as well. Thus, for
any odd n, there is an even x which belongs to φ (m). This proves that the number
−1
Theorem 223. For a prime p, there exists a positive integer n such that n ∈ φ (2p)
−1
334
§12. Inverse of Euler’s Totient Function Masum Billal, Amir Hossein
Proof. The “only if” part is easy to prove. When q = 2p + 1 is a prime, φ(q) = 2p so
q ∈ φ (2p).
−1
Now we prove the “if” part. For a positive integer n ∈ φ (m), consider that
−1
φ(n) = 2p. In other words, suppose that n ∈ φ (2p). If p = 2 we see that n = 5 works.
−1
φ(n) = p1 − 1
= 2p
⟹ p1 = 2p + 1
implying 2p + 1 is a prime.
2. If a = 0, then
e −1 e −1 e −1
φ(n) = p11 p22 . . . pkk (p1 − 1)(p2 − 1) . . . (pk − 1)
= 2p
3. If k = 0, then
a−1
φ(n) = 2
= 2p
Theorem 225. For an odd m, the number of odd elements in φ (m) is equal to the
−1
335
§13. Exercises Masum Billal, Amir Hossein
§13 Exercises
Problem 305. Let p be a prime number. Prove that there exist integers x and y such
2 2
that p = 2x + 3y if and only if p is congruent to 5 or 11 modulo 24.
3 2
Problem 306 (KöMaL). Prove that the equation x − x + 9 = 5y has no solution
among the integers.
2 2
Problem 307 (India 1998). If an integer n is such that 7n is the form a + 3b , prove
that n is also of that form.
Problem 308 (USA TST 2017). Prove that there are infinitely many triples (a, b, p)
of positive integers with p prime, a < p, and b < p, such that (a + b) − a − b is a
p p p
3
multiple of p .
Problem 309. Let p be a prime other than 7. Prove that the following conditions are
equivalent:
2 2
1. There exist integers x and y such that x + 7y = p.
−7
2. ( p ) = 1.
3. p is congruent to 1, 2, or 4 modulo 7.
Problem 310. Let p be a prime larger than 5. Prove that the following conditions are
equivalent:
2 2
1. There exist integers x and y such that x + 6y = p.
336
§13. Exercises Masum Billal, Amir Hossein
Problem 315. Let a, b, and n be positive integers such that n > 2. Prove that if
n n
a +b
k=
(ab)n−1 + 1
th
is an integer, then k is a perfect n power.
2 2
Problem 316 (IZHO 2005). Solve the equation p −6pq+(q +4) = 0 in prime numbers
less than 2005.
Problem 318 (IMO 2007). Let a and b be positive integers. Show that if 4ab − 1
divides (4a − 1) , then a = b.
2 2
Problem 320 (IMO ShortList 2003). Determine all pairs of positive integers (a, b)
such that
2
a
2ab2 − b3 + 1
is a positive integer.
Problem 321. Find all triples (x, y, z) of positive integers such that (x+y+z) = 7xyz.
2
2 2
Problem 322. Let a and b be positive integers such that ab divides a + b + 2. Prove
2 2
that a +b
ab
+2
= 4.
2 2
Problem 323. Find all positive integers x, y, and z such that x + y + 2 = xyz.
Problem 324 (Ireland 2005). Let m, n be integers with the same parity such that
2 2 2 2 2
m − n + 1 divides n − 1. Prove that m − n + 1 is a perfect square.
Problem 325 (Mongolia 2000). For which positive integer k there exist positive inte-
gers x, y, and z such that (x + y + z) = kxyz?
2
337
§13. Exercises Masum Billal, Amir Hossein
Problem 326. Prove that the following equation has no positive integer solution
(x, y, z)
2 2 2
x + y + z = xyz + 1
Problem 327. Prove that the equation
2 2 2
x + y + z = n(xyz + 1)
has a solution (x, y, z) in positive integers if and only if n can be represented as sum
of two perfect squares.
Problem 328. Let a and b are positive integers such that
2
a+1∣b +1
2
b+1∣a +1
Problem 333 (Putnam 1933). Prove that for every real number N , the equation
2 2 2 2
a + b + c + d = abc + bcd + cda + dab
Prove that
n−1
a ≡ 1 (mod p )
338
§13. Exercises Masum Billal, Amir Hossein
Problem 335 (Iran Second Round 2008). Show that the only positive integer value of
n
a for which 4(a + 1) is a perfect cube for all positive integers n, is 1.
Problem 336. Let k > 1 be an integer. Show that there exists infinitely many positive
integers n such that
n n n n
n∣1 +2 +3 +⋯+k
Problem 337 (Ireland 1996). Let p be a prime number, and a and n positive integers.
Prove that if
p p n
2 +3 =a
then n = 1.
Problem 338 (Russia 1996). Let x, y, p, n, k be positive integers such that n is odd
n n k
and p is an odd prime. Prove that if x + y = p , then n is a power of p.
88
Problem 339. Find the sum of all the divisors d of N = 19 − 1 which are of the form
a b
d = 2 3 with a, b ∈ N.
p k
Problem 340. Let p be a prime number. Solve the equation a − 1 = p in the set of
positive integers.
in positive integers.
n n
Problem 342 (Bulgaria 1997). For some positive integer n, the number 3 − 2 is a
perfect power of a prime. Prove that n is a prime.
Problem 343. Let m, n, b be three positive integers with m ≠ n and b > 1. Show that
n m
if prime divisors of the numbers b − 1 and b − 1 be the same, then b + 1 is a perfect
power of 2.
Problem 344 (IMO ShortList 1991). Find the highest degree k of 1991 for which
k
1991 divides the number 1992 1990
1991 1991
1990 + 1992
a−1
Problem 345. Prove that the number a − 1 is never square-free for all integers
a > 2.
x p
Problem 346 (Czech Slovakia 1996). Find all positive integers x, y such that p − y =
1, where p is a prime.
Problem 347. Let x and y be two positive rational numbers such that for infinitely
n n
many positive integers n, the number x − y is a positive integer. Show that x and y
are both positive integers.
Problem 348 (IMO 2000). Does there exist a positive integer n such that n has exactly
n
2000 prime divisors and n divides 2 + 1?
339
§13. Exercises Masum Billal, Amir Hossein
Problem 349 (China Western Mathematical Olympiad 2010). Suppose that m and k
m
2
are non-negative integers, and p = 2 + 1 is a prime number. Prove that
m+1 k
≡ 1 (mod p );
2 p k+1
• 2
m+1 k n
• 2 p is the smallest positive integer n satisfying the congruence equation 2 ≡ 1
(mod p ).
k+1
Problem 350. Let p ≥ 5 be a prime. Find the maximum value of positive integer k
such that
k 2(p−1) p−1
p ∣ (p − 2) − (p − 4)
prime.
7 7
Problem 353. Prove that there are no positive integers x, y, and z such that x + y =
z
1998 .
Problem 354 (Baltic Way 2012). Let d(n) denote the number of positive divisors of n.
Find all triples (n, k, p), where n and k are positive integers and p is a prime number,
such that
d(n) k
n −1=p
Problem 355 (IZHO 2017). For each positive integer k, denote by C(k) the sum of
the distinct prime divisors of number k. For example, C(1) = 0, C(2) = 2, C(45) = 8.
n
Determine all positive integers n such that C(2 + 1) = C(n).
Problem 356 (Hong Kong TST 2016). Find all triples (m, p, q) such that
m 2 7
2 p +1=q
Problem 357 (Brazil 2016). Define the sequence of integers an (for n ≥ 0) such that
a0 is equal to an integer a > 1 and
an
an+1 = 2 −1
Let A be a set such that x belongs to A if and only if x is a prime divisor of an for
some n ≥ 0. Show that the number of elements of A is infinite.
Problem 358 (USAMO2017). Prove that there are infinitely many distinct pairs (a, b)
b a
of relatively prime integers a > 1 and b > 1 such that a + b is divisible by a + b.
Problem 359 (Italy TST 2003). Let a and b be positive integers and p be a prime.
a b a
Find all solutions to the equation 2 + p = 19 .
340
§13. Exercises Masum Billal, Amir Hossein
Problem 360 (Turkey EGMO TST 2017). Determine all triples (m, k, n) of positive
integers satisfying the following equation
m k 3
3 5 = n + 125
Problem 361 (Balkan 2013). Determine all positive integers x, y, and z such that
5 y z
x + 4 = 2013 .
Problem 362. If pn is the nth prime then prove that the integer N = p1 p2 p3 . . . pn + 1
can not be a perfect power.
Problem 363. Find all ordered triplets (a, b, c) of positive integers such that
a b c
2 −5 ⋅7 =1
Problem 364 (Vietnam TST 2016). Find all positive integers a and n with a > 2 such
2016
n 3
that each prime divisor of a − 1 is also prime divisor of a − 1.
n
Problem 365. Find all positive integers n, for which n and 2 + 1 have the same set
of prime divisors.
Problem 366. Find all triplets (x, y, z) of positive integers such that
x y
(z + 1) − z = −1
341
Part II
Problem Column
CHAPTER VI.
Paul Erdős
Problem 367. Prove divisibility criteria for 2, 3, 4, 5, 7, 9, 11, 13, 17, 19, as stated in
section (§1.1).
This PDF was created
for Amazon.
k
2 ∣ 10 ak + ⋯ + 10a1
k k
2 ∣ 10 ak + ⋯ + 10a1 + a0 − (10 ak + ⋯ + 10a1 ) = a0
This implies that 2 must divide a0 . Since a0 is a digit, a0 ∈ {0, 2, 4, 6, 8}.
Now, assume that, a0 is even so a0 = 2b0 . Then we have
k
n = 10 ak + ⋯ + 10a1 + a0
k−1 k
= 2(2 5 ak + ⋯ + 5a1 + b0 )
which is obviously divisible by 2.
An alternative approach would be using congruence.
k
n ≡ 10 ak + ⋯ + 10a1 + a0 (mod 2)
≡ a0 (mod 2)
since 10 ≡ 0 (mod 2).
§0. Solving Challenge Problems Masum Billal, Amir Hossein
⎛ ⎞
⎜
=3⋅⎜ ak + ⋯ + 3a1 ⎟
⎟
⎜
⎜3⋯9 ⎟
⎟ + ak + ⋯ + a1 + a0
Í ÎÌ
⎝ k 3’s Ï ⎠
Notice that, when we divide n by 3, the term with 3 vanishes since it is divisible
by 3. This is now straightforward that 3 will divide n if and only if ak + ⋯ + a0
is divisible by 3. Since ak , ⋯, a0 are digits of n in base 10, the claim is proven.
4: n is divisible by 4 if and only if the number formed by the last two digits of n is
divisible by 4.
k
n = 10 ak + ⋯ + 10a1 + a0
k
= 10 ak + ⋯ + 100a2 + 4l
k−2
= 4 (25 ⋅ 10 ak + ⋯ + l)
Problem 368. Let n be a positive integer. Show that the product of n consecutive
integers is divisible by n!.
Before we solve this problem, let me tell you about my story when I first encountered
1
this problem. Since n! = 1 ⋅ 2⋯n, the first thing that I thought was: since there are
n consecutive integers, one must leave the remainder 0 modulo n. And this has to be
true for all m ≤ n. But then I immediately realized that even if we proved that the
product of these n integers is divisible by all m ≤ n individually, we can not guarantee
that their 1 ⋅ 2⋯n will divide their product too! It would be a common mistake to
think so. Beginners tend to make assumptions that are wrong. For example, a and b
both divide c, then ab divides c too. We will see some common mistakes as we solve
the problems. Be aware of them whenever you are thinking about a problem. So, to be
on the safe side, if you assume something, don’t think it’s true until you can prove it.
Appearances can be deceiving! Now, let’s see a correct solution.
346
§0. Solving Challenge Problems Masum Billal, Amir Hossein
that,
S
If we can prove that this product is an integer, we are done.
n!
S a!
=
n! (a − n)!n!
a
= (n )
2
which is clearly an integer.
Solution. This problem can be dealt with very easily if you know Wolstenholme’s
theorem which says for p > 3,
2p 2 3
( p ) ≡ (1) (mod p )
3
≡ 2 (mod p )
3 2p
p ∣(p)−2
Remark . Another way to do it, if you don’t know or can not remember the theorem.
Use the identity:
n 2
n 2n
∑ (i) = ( n )
i=0
p 2
p 2p
∑ (i) = ( p )
i=0
2
We already know that for 0 < i < p, p divides (pi). So p divides (pi) for such i and we
2
347
§0. Solving Challenge Problems Masum Billal, Amir Hossein
have,
p 2 2 2
p p p 2
∑ ( i ) ≡ ( 0 ) + (p ) (mod p )
i=0
2p 2
( p ) ≡ 2 (mod p )
2 2p
p ∣(p)−2
gn = (f (n + 1), f (n))
= f (n)
ln = [f (n), f (n + 1)]
= f (n + 1)
This holds because if a ∣ b, then (a, b) = a and [a, b] = b. Since f (n) ∣ f (n + 1), we
f (n + 1)
can define a sequence (bi )i≥1 with bn = and b1 = f (1), which is obviously an
f (n)
integer sequence.
f (n + 1) = bn f (n)
= bn bn−1 f (n − 1)
= bn bn−1 bn−2 f (n − 2)
..
.
= bn bn−1 ⋯b1
n
= ∏ bi
i=1
348
§0. Solving Challenge Problems Masum Billal, Amir Hossein
Problem 371 (Russia, 2000). If a and b are positive integers such that a + b = (a, b) +
[a, b] then one of a, b divides the other.
This is a problem that has many solutions, being a relatively easier problem. We
will show two solutions here. Let g = (a, b) and l = [a, b] for brevity. Then the equation
becomes a + b = g + l. Without loss of generality, we can assume a ≤ b.
ab
Solution (First). We know ab = gl or l = g . Substituting this into the equation:
ab
a+b=g+ g
2
g + ab = g(a + b)
(g − a)(g − b) = 0
g(x + y) = g + gxy
xy + 1 = x + y
(x − 1)(y − 1) = 0
Problem 372 (Slovenia 2010). Find all primes p, q, r with 15p + 7pq + qr = pqr.
p(qr − 15 − 7q) = qr
pr − 15 − 7p = r
r(p − 1) = 7p + 15
p − 1 ∣ 7p + 15
pq − 15 − 7q = q
(p − 8)q = 15
349
§0. Solving Challenge Problems Masum Billal, Amir Hossein
Problem 373 (Serbia 2014). A special number is a positive integer n for which there
exist positive integers a, b, c and d with
3 3
a + 2b
n= 3
c + 2d3
Prove that,
Solution. Proving (a) is easy since we just have to show an infinite such n. So we
can choose a, b, c, d however we want, as long as they serve our purpose. Let’s go with
a = ck, b = dk, then
3 3 3 3 3 3
a + 2b c k + 2d k
3 3
=
c + 2d c3 + 2d3
3
=k
We can consider modulo 19 in this equation. We just have to check cubes modulo 19
and the reader can verify that if a ≡ −2b (mod 19), then we must have 19 ∣ a, b since
3 3
3 3 3 3 3
19 (x + 2y ) = 2 ⋅ 19 ⋅ 53(c + 2d )
3 3
19 ∣ c + 2d
Problem 374 (Croatia 2015). Let n > 1 be a positive integer so that 2n − 1 and 3n − 2
are perfect squares. Prove that 10n − 7 is composite.
2 2
Solution. Take 2n − 1 = x and 3n − 2 = y . We need to reach 10n somehow here,
and incidentally 10 = 12 − 2 = 3 ⋅ 4 − 2 ⋅ 1. So, we do this:
2 2
4(y ) − 1(x ) = 4(3n − 2) − (2n − 1)
(2y + x)(2y − x) = 10n − 7
350
§0. Solving Challenge Problems Masum Billal, Amir Hossein
m n
Problem 375. Find all non-negative integers m, n such that 3 −5 is a perfect square.
m n 2
Solution. Let 3 − 5 = a . Since there are squares, we should consider modulo 4,
the numbers 3, 5 also suggest us to take modulo 4. That way, we get to know about m
and n. Since both sides must leave the same remainder upon division by 4,
m n 2
(−1) − 1 ≡ a ≡ 0, 1 (mod 4)
l 2 2 n
(3 ) − a = 5
l l n
(3 + a)(3 − a) = 5
l x l y
In the right side there is nothing but 5, so we must have 3 + a = 5 , 3 − a = 5 for
some non-negative integer x, y. If we add them
l x y
2⋅3 =5 +5
If y is 0, then
l x
2⋅3 =5 +1
x
5 + 1 is divisible by 2 and 3, but according to Zsigmondy’s theorem 5 + 1 will have a
prime factor that is neither 2 nor 3 if x > 1. Clearly x > y so if y ≠ 0, then 5 divides
l
2 ⋅ 3 , contradiction. So there is no such integers m, n except the trivial solutions when
x = 0 or x = 1.
Problem 376 (Croatia 2015). Prove that there does not exist a positive integer n for
n n
which 7 − 1 is divisible by 6 − 1.
subtraction gives
n n n
6 − 1 ∣ 7 − 1 − (6 − 1)
n n
=7 −6
351
§0. Solving Challenge Problems Masum Billal, Amir Hossein
n 2
Solution. Clearly 2 + 1 is odd, so n − 1 must be odd as well. This means that n is
even. Let n = 2k for some positive integer k. Then
2 2
n − 1 ≡ 4k − 1 ≡ 3 (mod 4).
By Theorem 21, every number of the form 4k + 3 has a prime divisor of that form.
Therefore, there is a prime p such that p ∣ n − 1 and p ≡ 3 (mod 4). Now, according
2
k 2
to Theorem 54, every prime divisor of 2 + 1 = (2 ) + 1 is of the form 4k + 1. This is
n
Note. Although some problems seem difficult at first sight, they are pretty easy if you
think in a proper way.
Solution. n = 1 is obviously a solution (which works for any m), so let’s look at n > 1
2 2 2 2 2
only. Note that m + 9 = m + 3 , if m ⊥ 3, then m + 3 is a bisquare. Therefore, if
n > 1 then 2 − 1 ≡ −1 (mod 4), so m + 9 will have a prime divisor of the form 4k + 3.
n 2
But we know that, no bisquare has a prime divisor of this form. Therefore, m must be
divisible by 3. If m = 3k,
n 2
2 − 1 ∣ 9(k + 1)
2
Now, no matter what k is, k + 1 is always a bisquare. Therefore, it can not have any
divisors of the form 4k + 3. So, 2 − 1 ∣ 9, checking with 2 − 1 = 1, 3, 9, we get that
n n
You never know what’s coming next until you think clearly!
2 n!
Problem 379. If n > 1, prove that n − 1 divides 2 − 1 for even n.
(m−1)!
Solution. If we set m = n + 1, then we need to prove m(m − 2) divides 2 − 1.
Since n is even, m is odd so m is relatively prime to 2.
φ(m)
2 ≡ 1 (mod m)
φ(m−2)
2 ≡ 1 (mod m − 2)
Since φ(m) < m and φ(m−2) ≤ m−2, φ(m) and φ(m−2) divides (m−1)!. Therefore,
(m−1)!
2 ≡ 1 (mod m)
(m−1)!
2 ≡ 1 (mod m − 2)
(m−1)! (m−1)!
This implies m ∣ 2 − 1 and m − 2 ∣ 2 − 1. Since m ⊥ m − 2 for odd m, we
(m−1)!
have m(m − 2) ∣ 2 − 1.
n
Problem 380. Prove that n divides 2 + 1 for infinitely many n ∈ N.
352
§0. Solving Challenge Problems Masum Billal, Amir Hossein
Solution. One can easily observe that n = 3 works since n is odd, so we could take
3k k
n = 3k. Then we see that 2 + 1 = 8 + 1 is divisible by 9 since k is odd. This suggests
k
us to take n = 3 . Indeed, it works because due to LTE, 3 ∥2 + 1, so n = 3 gives
k k+1 3 k
us infinitely such n.
Problem 381 (Croatia 2015). Determine all positive integers n for which there exists
a divisor d of n such that dn + 1 ∣ d + n .
2 2
Problem 382 (IMO Shortlist 2013, N1, Proposed by Malaysia). Find all functions
f ∶ N → N such that
2
m + f (n) ∣ mf (m) + n
Arithmetic functional equations or divisibility problems are really popular for IMO
or Shortlist. Anyway, let’s see how we can solve this one. We say it beforehand that, it
can be solved in many ways, being an easy problem. So if you try yourself you should
be able to do it.
Solution (First). There are two variables in this divisibility. Sometimes reducing to
one variable and then working on it alone suffices for some problems. By the way, you
have probably guessed already, f (n) = n is the solution.
First let’s play with some values of m and n. To remove two variables, set m = n.
2
n + f (n) ∣ nf (n) + n
2
nf (n) + n ≥ n + f (n)
(n − 1)(f (n) − n) ≥ 0
4 + f (2) ∣ 2f (2) + 2
4 + f (2) ∣ 8 + 2f (2)
4 + f (2) ∣ 8 + 2f (2) − (2f (2) + 2)
4 + f (2) ∣ 6
353
§0. Solving Challenge Problems Masum Billal, Amir Hossein
Thus, f (n) ∣ f (n)f (f (n)) + n or f (n) ∣ n, so f (n) ≤ n. Now, we will explain our main
idea. We will make the right side a prime (think what the benefit of doing so). But
we need to understand if that’s achievable. It is, since we can take n as we please, and
there is a free n on the right side. Let p = mf (m) + n for a prime p > mf (m). In fact,
we take a prime p > m , that way we also ensure p > mf (m) since f (m) ≤ n. So, for
2
that m,
2
m + f (n) ∣ mf (m) + n = p
2
p − m = f (n) ≤ n
= p − mf (m)
Solution. Let’s see if we can determine the smallest prime factor again. If p is the
smallest prime divisor of n,
n
2 ≡ −1 (mod p)
2n
2 ≡ 1 (mod p)
(2n,p−1)
2 ≡ 1 (mod p)
354
§0. Solving Challenge Problems Masum Billal, Amir Hossein
α
the smallest prime. So, we can assume n = 3 k where k is not divisible by 3. Think
yourself about the reason to do this. It would be certainly fruitful to find out what
values α can assume. This is where Lifting the Exponent lemma comes to the rescue!
But first we need to make sure we can actually apply LTE. In this case, we can because
2 + 1 = 3, divisible by 3 and 2⊥1. We have
2 2α 2
ν3 (n ) = ν3 (3 k )
2α 2
= ν3 (3 ) + ν3 (k )
= 2α
n ∣ 2 + 1 implies that
2 n
n 2
ν3 (2 + 1) ≥ ν3 (n )
1 + α ≥ 2α
1≥α
Here, we again try to determine the smallest prime divisor of k, we call it q. Then
8 ≡ −1 (mod q).
k
2k
8 ≡ 1 (mod q)
q−1
8 ≡ 1 (mod q)
(2k,q−1)
8 ≡ 1 (mod q)
2
8 ≡ 1 (mod q)
We hope the lines above don’t need a second explanation. This way, q ∣ 63 = 3 ⋅ 7.
2
This is impossible, which means k doesn’t have any prime divisor i.e. k = 1. The only
solution we have is n = 1, 3.
Note. This is a fantastic problem which uses couple of techniques at the same time.
Worthy of being a problem 3 at the IMO!
Problem 384 (All Russian Olympiad 2014, Day 2). Define m(n) to be the greatest
proper natural divisor of n ∈∈ N . Find all n such that n + m(n) is a power of 10.
355
§0. Solving Challenge Problems Masum Billal, Amir Hossein
a
Solution. Let n + m(n) = 10 . If n is a prime then m(n) is clearly 1. In that case,
a
p + 1 = 10
a
p = 10 − 1
Right side is divisible by 10 − 1 = 9, so p can not be prime. Now, if n > 1 and not a
prime, then n has a smallest prime divisor. Then the greatest proper divisor of n will
n
be p , let’s say n = pk. Be careful here, p is the smallest prime does not mean that k
2 r
is not divisible by p. For example, 12 = 2 ⋅ 3 so k = 6. Take k = p l where all prime
factors of l must be greater than p and r ≥ 0.
a
n + m(n) = 10
a
pk + k = 10
r a
p l(p + 1) = 10
a
If r ≥ 1 then p divides 10. So p = 2 or p = 5. If p = 2, then p + 1 = 3 divides 10 ,
a
contradiction. If p = 5, p + 1 = 6 divides 10 , again contradiction. So r = 0 and
l(p + 1) = 10 . It is clear that l is odd, otherwise 2 ∣ l and hence p < 2 since all prime
a
x
factors of l are greater than p. This also provides with p + 1 ≤ l. Since l is odd, l = 5
for some 1 ≤ x ≤ a. Since p is less than all prime factors of l, we must have p = 3.
x a a
5 ⋅4=2 5
2
which immediately gives a = 2, so x = a = 2. Thus, n = pk = 3 ⋅ 5 = 75.
x p
Problem 385 (Czech Slovakia 1996). Find all positive integers x, y such that p −y = 1
where p is a prime.
Problem 386 (China 2001, Problem 4). We are given three integers a, b, c such that
a, b, c, a + b − c, a + c − b, b + c − a, and a + b + c are seven distinct primes. Let d be
the difference between the largest and smallest of these seven primes. Suppose that
800 ∈ {a + b, b + c, c + a}. Determine the maximum possible value of d.
Solution. Observation: all of a, b, c are odd prime. In cases like this, show a contra-
diction that the other case can not happen. So let’s assume that a = 2 and b, c are odd.
Then a + b − c is even since b − c is even, so not a prime unless a + b − c = 2 but then
b = c which contradicts that b, c are distinct primes. We leave the other cases for the
reader.
From what we just proved, the smallest prime of a, b, c (namely c ≥ 3) must be at
least 3. What other information is there for us to use? 800 ∈ {a + b, b + c, c + a}, but
we don’t need to analyze every case since they are symmetric over a, b, c. Without loss
of generality, take a + b = 800. a + b − c > 0 is a prime too, so c < a + b = 800 or
c ≤ 799, a prime. We can check that 17 divides 799, so c ≤ 797, inferring a + b + c ≤
356
§0. Solving Challenge Problems Masum Billal, Amir Hossein
800 + 797 = 1597. And by luck, 1597 is a prime (well, that’s how the problem creator
created the problem). So if we can find a, b so that all are primes, we are done and in
that case, d = a + b + c − 3 = 1594 since a + b + c is the largest prime and 3 is the
smallest prime. a must be greater than or equal to 5, but since a + b = 800, a can not
be 5. Let’s check starting from a = 7, b = 793. With some tedious calculations, we can
find that a = 13, b = 787 satisfies all the conditions. Other primes would be 23, 1571.
Problem 387. Find the number of positive integers d so that for a given positive
n
integer n, d divides a − a for all integer a.
Solution. Let’s focus only on n > 1. How do we understand the nature of d? Surely we
should take a prime divisor of d, say p. If we can find the values of p and the exponent
of p in d, we can find d. So we get p ∣ a − a for all p ∣ d. What should we use to get
n
a clue on the exponents? We can set different values of a. And it seems wise to use
a = p. This shows that p ∣ p − p. Now, if p ∣ d then we would have p ∣ p − p which
n 2 2 n
would breed a contradiction p ∣ p because p ∣ p for n > 1. Therefore, for any prime
2 2 n
Now, we only need to find the valid values of p. This is where it gets tricky. For
any integer a, either p ∣ a or a ⊥ p. It’s safe to work only for a ⊥ p since the problem
≡ 1 (mod p).
p−1
asks for all values of a. In that case, from Fermat’s little theorem, a
n−1
And from the problem statement, we have a(a − 1) is divisible by p. Since a ⊥ p,
≡ 1 (mod p). This almost tells us to infer that
n−1 n−1
we get a − 1 is divisible by p, or a
we must have p − 1 ∣ n − 1. That is the case indeed, however, we have to prove that
p − 1 must be the order of a for some integer a. You should think on this more and get
to the point where you understand: we should set a = g where g is a primitive root of
≡ 1 (mod p) and ordp (g) = p − 1. Therefore, from g
p−1 n−1
p. So that, we can tell g ≡1
(mod p), we get p − 1 ∣ n − 1.
Notice that, if D = ∏ p, then any d ∣ D satisfies the condition of the problem.
p−1∣n−1
Therefore the number of such positive integer d is τ (D). If the number of primes p ∣ n
for which p − 1 ∣ n − 1 is t(n) i.e.
t(n) = ∑ 1
p∣n
p−1∣n−1
then τ (D) = 2
t(n)
.
357
§0. Solving Challenge Problems Masum Billal, Amir Hossein
d can’t have a prime factor i.e. d must be 1. And then, a and b both are integers.
Problem 389. Prove that, σ(n) = n + k has a finite number of solutions for a fixed
positive integer k.
√ √
Solution. We can easily show that σ(n) > n + n which says k > n. In other words,
n is bounded above so it can not have arbitrary number of solutions.
Note. We can use some sharper inequalities to get a upper bound of k. Try to sharpen
the inequality as much as you can.
Problem 390. Prove that, for a positive integer n,
2n
( n ) ∣ [1, 2, ⋯, 2n]
Solution. When proving divisibility like this, you should consider Theorem 9. The
idea is that if we can show the exponent in the left side of the divisibility is less than
or equal to the exponent in the right side for a prime p, we are done. It is clear that no
side of divisibility will have a prime p > 2n. So we should consider only primes p < 2n,
since 2n is not a prime for n > 1. Using Theorem 19, if for a prime p, α = logp (2n),
νp ([1, 2, ⋯, 2n]) = α
On the other hand, from Legendre’s theorem, if N = (2n
n
),
∞
2n n
νp (N ) = ∑ ⌊ i
⌋ − 2⌊ i ⌋
i=1
p p
logp (2n)
2n n
= ∑ ⌊ i
⌋ − 2⌊ i ⌋
i=1
p p
a
≤ ∑1
i=1
=α
νp (N ) ≤ νp ([1, 2, ⋯, 2n])
This is exactly what we needed to prove.
358
§0. Solving Challenge Problems Masum Billal, Amir Hossein
Problem 391 (Italy TST 2003). Find all triples of positive integers (a, b, p) such that
a b a
2 + p = 19 .
b a a
Solution. Rewrite the equation as p = 19 − 2 . Right side is divisible by 19 − 2 = 17
b a a a a
which is a prime. Therefore, p = 17, 17 = 19 − 2 . But if a > 1 then 19 − 2 has a
prime factor other than 17, contradiction. Thus, the only solution is (a, b) = (1, 1, ).
p
n +1
Problem 392 (APMO 2012 - Problem 3). Find all pairs of (n, p) so that is a
pn + 1
positive integer where n is a positive integer and p is a prime number.
Solution. We can re-state the relation as
n p
p +1∣n +1
Obviously, we need
2 n 2 n
n +1≥2 +1⇒n ≥2
n 2
But, using induction we can easily say that for n > 4, 2 > n giving a contradiction.
Checking n = 1, 2, 3, 4 we easily get the solutions:
and p odd, there are p terms in the right factor, therefore odd. So, we infer that
2 ∣ n + 1 where k is the maximum power of 2 in p + 1.
k
We will use the following theorem from elementary calculus, which can also be
proved elementarily.
Theorem VI.226.
1 n
lim (1 + n ) = e
n→∞
359
§0. Solving Challenge Problems Masum Billal, Amir Hossein
1 p 1 p
(1 + n ) ≤ (1 + p )
p n
Therefore, since we assumed n ≤ p ,
1 p
(n + 1) = n (1 + n )
p p
1 p
≤ p (1 + p )
n
n
≤p ⋅e
n+1
<p
since e < 3.
Back to the problem. Assume that q is odd.
n
q ∣p +1
p
∣n +1
Suppose, e = ordq (n) i.e. e is the smallest positive integer such that
e
n ≡ 1 (mod q)
From p odd and q ∣ p + 1, p > q and so p and q − 1 are relatively prime. Thus,
(2p, q − 1) = (2, q − 1) = 2
This gives us, e ∣ (2p, q −1) and so we must have e = 2. Again, since p odd, if p = 2r +1,
2r+1
n ≡ n (mod q)
p
Hence, q ∣ n + 1. If q ∣ n +1
n+1
, then by the Theorem 199 we get
p
n +1
q ∣ gcd (n + 1, )
n+1
⟹ q∣p
360
§0. Solving Challenge Problems Masum Billal, Amir Hossein
which would imply q = 1 or p. Both of the cases are impossible. So, if s is the maximum
power of q so that q ∣ p + 1, then we have q ∣ n + 1 too for every prime factor q of
s s
Combining these two, p = n is the only possibility to happen. Thus, the solutions are
(n, p) = (4, 2), (p, p).
(a
φ(n) φ(n)
Problem 393. Prove that a − 1) is always divisible by n for all positive
integers a and n.
Solution. Let p be any prime divisor of n. Suppose that that p ∣ n but p ∤ n,
k k+1
k k
p ∣ a
k
k φ(p )
a ∣a
k n
φ(p ) φ(a )
a ∣a
consecutive natural numbers with b > 1 among which 2012 will be nutty. Let say those
1 2 2014
numbers are a +1, a +2, ⋯, a +2014. Crucial observation: If n is nutty for a, b then
k
n is nutty for a , b where k is a positive integer. Since there are integers 1, 2, 3, ⋯, 2014
associated and we are free to choose a as long as a > 1, it makes sense to take the
exponent 2014!. But we can not change b, therefore, we must introduce this factorial
within a. So, let’s take a positive integer x > 1 and look at the numbers
2014 2014! 2014!
x ! + 1, x + 2, ⋯, x + 2014
2014! 2 2014! 2014
2014!
x + 1, (x 2
) + 2, ⋯, (x 2014 ) + 2014
361
§0. Solving Challenge Problems Masum Billal, Amir Hossein
All of them are nutty except the first one (probably). But we need exactly two to be
not nutty. A way to do that is to divide 2014! by a number and hope it doesn’t remain
nutty. Let’s say this number is k, that is, we are looking at the numbers
2014! 2014! 2 2014! 2014
x k
+ 1, (x 2k
) + 2, ⋯, (x 2014k ) + 2014
We can see that there are only two numbers which can be candidates to be not nutty.
2014! 2014! k
+ 1 and (x ) + k. Essentially we don’t want the case k divides 2014!. This is
2
x k k2
a hint to using primes! If we take a prime p > 1007, p ∤ 2014!. Now we that have 2012
2
numbers nutty for sure, we just need to find x, p so that those two numbers become not
nutty.
2014!
b
x p
+1=a +b
2014!
b
x p
+p=a +b
N b N b
Take N = 2014!
p
. If we find x, p so that the equations x + 1 = a + b and x + p = a + b
don’t have solutions, we are done. Let’s try with x = 2 since a ≥ 2, we might be able
to use inequalities. For b ≥ N ,
N b
2 +p=a +b
b
≥2 +b
N
≥2 +N
N
>2 +p
So b < N . This also means we are in the right track to solve the problem. And b > p
too must hold. Otherwise,
b N
p−b=a −2
N b
b
= a − (2 b )
N N (b−1)
= (a − 2 b ) (a )
b−1
+⋯+2 b
>p
0>b
contradiction. Now , if a is even, let a = 2u.
N b b
b−p=2 −2 u
Since b < N , 2 ∣ b − p but clearly b − p < 2 . Thus, a is odd. If b is even with b = 2v,
b b
N 2
v 2
b − p = (2 2 ) − (2 )
N N
v v
= (2 2 + 2 )(2 2 − 2 )
>b
N
again contradiction. Try to do the same with 2 + 1.
362
§0. Solving Challenge Problems Masum Billal, Amir Hossein
Problem 395 (Columbia 2010). Find the smallest n ∈ N such that n! is divisible by
10
n .
k
Solution. Let p be a prime divisor of n and p-base representation of n is n = ak p +
⋯ + a1 p + a0 . Then
n − (ak + ⋯ + a0 )
νp (n!) =
p−1
If νp (n) = α then the last α digits of n in base p is 0.
n − (ak + ⋯ + aα )
νp (n!) = and
p−1
10 10α
νp (n ) = νp (p ) = 10α
n − (ak + ⋯ + aα )
≥ 10α
p−1
where α ≤ logp (n). Remember that, we are looking for the smallest n, not all n.
α
Therefore, we should first consider the case n = p first. Then In base p,
n = (1 0⋯0 )p
Í ÎÌ Ï
α zeros
α
p −1
νp (n!) = and so,
p−1
α
p −1
≥ 10α
p−1
α
We need to find such p, α such that p is minimum. Therefore, p must be 2. Now we
α
need the smallest α for which 2 − 1 ≥ 10α. See that α = 6 works. But can we minimize
10
n even further? Since n! must be divisible by n , so we need to look at primes for
which we get the exponent at least 10. If p ∣ n for some prime p, we need νp (n!) ≥ 20
2
10
for some n < 64. The minimum n for which n! is divisible by 3 is 24. For n < 64,
63 63 63
ν3 (n!) ≤ + +⌊ ⌋
3 9 27
= 21 + 7 + 2 = 30
63 63
And we see that n = 63 is in fact a solution because ν7 (63!) =+ ⌊ ⌋ = 10. The
7 49
minimum n for which ν5 (n!) ≥ 10 is n = 45. Using the arguments we made already,
show that we can not minimize n further.
Problem 396 (Greece National Mathematical Olympiad, 2015). Find all triplets
(x, y, p) of positive integers such that p is a prime number and
3
xy
x+y =p
363
§0. Solving Challenge Problems Masum Billal, Amir Hossein
Solution. This equation does not suggest it, but we will take (x, y) = g and x =
ga, y = gb where a⊥b. Because that way, we can reduce the equation or extract more
information.
3 3
gag b
=p
g(a + b)
3 3
g ab = p(a + b)
Now this equation talks more than the previous one. Since a⊥b, a + b⊥a, a + b⊥b and
b ⊥a + b. Therefore, a ∣ p(a + b) gives us a ∣ p and b ∣ p(a + b) gives b ∣ p. From this,
3 3 3
Problem 397 (Korea 2010). A prime p is called a nice prime if there exists a sequence
of positive integers (n1 , ⋯, nk ) satisfying following conditions for infinitely positive
integers k, but not for k = 1.
p+1
• For 1 ≤ i ≤ k, ni ≥ .
2
n
n p i −1
• For 1 ≤ i ≤ k, p i − 1 is a multiple of ni+1 and ni+1
is relatively prime to ni+1 .
Set nk+1 = n1 .
Show that 2 is not a nice prime, but any odd prime is.
Solution. Let’s deal with the case p = 2 first. We will show that there does not exist
infinitely many k for which there exist n2 , ⋯, nk with ni+1 ∣ 2 i − 1. For i > 1, ni is
n
odd, and fix k. Consider all prime factors of ni for i > 1, let the smallest of them be
q. If q ∣ nl Then 2 l−1 ≡ 1 (mod q) and 2 ≡ 1 (mod q). If d = ordq (2), then we can
n q−1
364
§0. Solving Challenge Problems Masum Billal, Amir Hossein
does not hold. Again, we assume that q is the smallest prime divisor of n. Clearly
q ≠ p, and q⊥p.
n
p ≡ 1 (mod q)
q−1
p ≡ 1 (mod q)
(n,q−1)
p ≡ (mod q)
p ≡ 1 (mod q)
4
since n ⊥ q −1 < q. From this, you should be able to tell, you can invoke LTE! Because
q ∣ p − 1, from LTE,
n
p −1
νq ( n ) = νq (p − 1) − νq (n)
n
= νq (p − 1) + νq (n) − νq (n)
= νq (p − 1)
≥1
n
p −1
Therefore q divides n and q ∣ n, contradiction. Such n does not exist for k = 1.
We just have to find a construction for such (n1 , n2 , ⋯, nk ). First think on the
n
p i −1
condition (ni+1 , n ) = 1. This clearly means for any odd prime divisor q of ni+1 ,
5
i+1
n
p i −1
q does not divide n .
i+1
n
p i −1
νq ( n )=0
i+1
n
νq (p i − 1) − νq (ni+1 ) = 0
p+1
This suggests us to take n1 so that n1 = p − 1 and p − 1 ≥ is obvious for odd
2
p. Then we have n2 ∣ p − 1. If q ∥p − 1, then q ∥p − 1 according to LTE. Then
p−1 e 2e p−1
p−1
p −1
q∤ for any q ∣ p − 1. So we should include n2 = q . You should understand
2e
q2
that we have to define n3 the same way. Let q be a prime divisor of p − 1. Then
n
ei = νq (p i − 1)
e
ni+1 = q i
p+1
The only thing left to do is ensure that ni ≥ . Note that the sequence (ei )i≥1 is
2
p+1
increasing for a fixed q. Therefore, there will be an index r for which nr ≥ must
2
hold. We leave it to the reader to verify that they satisfy the conditions of the problem.
4
we already argued the same way before
5
we won’t show the case q = 2 here, do that yourself in the same fashion
365
§0. Solving Challenge Problems Masum Billal, Amir Hossein
Problem 398 (IMO Shortlist 2013, Problem 4, Proposed by Belgium). Prove that
there exist infinitely many positive integers n such that the largest prime divisor of
n + n + 1 is equal to the largest prime divisor of (n + 1) + (n + 1) + 1.
4 2 4 2
4 2
Solution. Let an = n + n + 1, and pn be the largest prime divisor of an . The problem
asks to prove there are infinite n for which pn = pn+1 .
4 2 2 2
(1) (n + n + 1) = (n + n + 1)(n − n + 1)
2
This identity tells us to consider the numbers bn = n + n + 1, and the largest prime
divisor of bn is qn . Then an = bn2 and pn = qn2 . From equation (1), pn = max(qn , qn−1 )
since bn−1 = (n − 1) + n − 1 + 1 = n − n + 1. By Euclidean Algorithm
2 2
2 2 2
(n + n + 1, n − n + 1) = (n − n + 1, 2n)
2
= (n − n + 1, 2)
=1
Therefore bn ⊥bn−1 , implying qn ≠ qn−1 . Up until now, all we have done was self im-
plicating. But what will allow us to prove that pn = pn+1 happens for infinite n?
pn = max(qn , qn−1 ) and pn+1 = max(qn+1 , qn ). The problem requires pn = pn+1 or
max(qn−1 , qn ) = max(qn+1 , qn ). This provides us a hint what we need to do. We will
focus on qn . That means, we will try to prove that for infinite n, qn = max(qn , qn−1 ) and
qn = max(qn+1 , qn ). In short, we have to prove qn > qn+1 and qn > qn−1 holds true for
infinite n. First we need to check that at least one such qn exists. q2 = 7, q3 = 13, q4 = 7,
so n = 3 gives us such a qn .
Assume to the contrary that, only for finite n, qn > qn−1 and qn > qn+1 . Then there
is a largest value of n for which this condition holds true, say it is N . Let’s think
if it is possible that qi > qi+1 for all i ≥ N . But that would give us an infinite set
of decreasing positive integers, which is impossible. So there is an i > N for which
qi < qi+1 (remember that qi ≠ qi+1 ). Then is it possible to have an infinite chain of
qi < qi+1 < qi+2 < ⋯? No, because q(i+1)2 = pi+1 = max(qi+1 , qi ) = qi+1 . Therefore, we
must have an j for which qj > qj+1 . For that j, we have qj > qj−1 , so it is a contradiction.
Thus, there are infinite such n.
Problem 399. Let p be an odd prime. If g1 , ⋯, gϕ(p−1) are the primitive roots (mod p)
in the range 1 < g ≤ p − 1, prove that
ϕ(p−1)
∑ gi ≡ µ(p − 1) (mod p)
i=1
= µ(p − 1)
(p−1)/d kd
Because ∑k=1 g = 0 mod p, when d < p − 1.
366
§0. Solving Challenge Problems Masum Billal, Amir Hossein
Problem 400 (IMO Shortlist 2014, N4, Proposed by Hong Kong, also used at Bangladesh
TST 2015). Let n be a given integer. Define the sequence (ak )k≥1 by:
k
n
ak = ⌊ ⌋
k
k is even it won’t divide any odd integer. No worries, we will just borrow a power of 2.
j
3⋅4
2
a3⋅4j =⌊ ⌋
3 ⋅ 4j
j
3⋅4 j
2 −4
=
3 ⋅ 4j
j
j 3⋅4 j
is an odd integer since 4 clearly divides 2 and 3 ⋅ 4 > j. Show why 3 divides the
numerator yourself.
Problem 401 (IMO Shortlist 2014, N5, Proposed by Belgium, also used at Bangladesh
TST 2015). Find all triples (p, x, y) consisting of a prime number p and two positive
p−1 p−1
integers x and y such that x + y and x + y are both powers of p.
p−1 a p−1 b
Solution. Let y + x = p and x + y = p and y > x without loss of generality (so
b > a too). If p = 2, then x + y = 2 so (x, y) = (x, 2 − x) works with any a ∈ N, x < 2 .
a a a
367
§0. Solving Challenge Problems Masum Billal, Amir Hossein
We need to deal with odd p now. Let g = (x, y) and x = gm, y = gn with m⊥n.
s
We intend to prove that x⊥y. If not, g = p for some s.
s s(p−1) p−1 a
p n+p m =p
s s(p−1) p−1 b
p m+p n =p
s
If s ≠ 0, the dividing the equations by p we get,
s(p−2) p−1 a−s
n+p m =p
s(p−2) p−2 b−s
m+p n =p
s(p−2) a−s b−s
Since p > 2, p divides p ,p and p , hence p divides both m and n. But this
contradicts the fact that m⊥n. Therefore, s = 0, and (x, p) = (y, p) = (x, y) = 1. From
FLT,
p−1
x+y ≡ x + 1 (mod p)
p−1
x + y ≡ y + 1 (mod p)
p p
νp (x − y ) = νp (x − y) + νp (p)
=α+1
368
§0. Solving Challenge Problems Masum Billal, Amir Hossein
(mod p).
2b
2 ≡ 1 (mod p)
p−1
2 ≡ 1 (mod p)
(2b,p−1)
2 ≡ 1 (mod p)
Without loss of generality, we can assume that p < q, r where q and r are the smallest
prime divisors of b and c (even if it is not, we can just switch the places of p and q, or
r). Therefore, (2b, p − 1) = 2 and p ∣ 2 − 1 = 3 so p = 3. Let a = 3x. We can see
2
q is smaller than the smallest prime divisor of b and c. But this again gives that q = 3,
which gives the contradiction that x is divisible by 3. Thus, we can say q divides b or
c. If q ∣ c, then
3x
2 ≡ −1 (mod q)
2x
8 ≡ 1 (mod q)
q−1
8 ≡ 1 (mod q)
(2x,q−1)
8 ≡ 1 (mod q)
Here, x must have no smaller prime divisor than q, otherwise that would have been the
smallest prime divisor instead of q. So, (2x, q − 1) = 2 and q ∣ 8 − 1 = 3 ⋅ 7. Since q
2 2
contradiction due to
x
8 + 1 ≡ 1 + 1 (mod 7)
369
§0. Solving Challenge Problems Masum Billal, Amir Hossein
Thus, q must be the smallest prime divisor of b, and so c does not have any prime
divisor less than or equal to q. Similarly,
c
2 ≡ −1 (mod q)
2c
2 ≡ 1 (mod q)
q−1
2 ≡ 1 (mod q)
(2c,q−1)
2 ≡ 1 (mod q)
2
2 ≡ 1 (mod q)
which gives us q = 3 but then 3 ∣ b, a contradiction. Therefore, b can not have any
prime divisor, b = 1. We also have c ∣ 2 + 1 = 9, so c ∈ {1, 3, 9}. But if c = 1, it would
3
370
§0. Solving Challenge Problems Masum Billal, Amir Hossein
Problem 404 (APMO 2014, Problem 3). Find all positive integers n such that for any
3
integer k there exists an integer a for which a + a − k is divisible by n.
Solution. Make sense of the problem before you try it. It can be rephrased this way:
3
find all n such that the set a + a for a = 1, 2, ⋯, n we get a complete residue class
modulo n. Or, for no two 1 ≤ a < b ≤ n,
3 3
a + a ≡ b + b (mod n)
In order to understand the values of n, see some examples with smaller values first. A
k
pattern follows, n = 1, 3, 9 works. So may be the condition holds if and only if n = 3 .
Checking the if part is easy.
3 3 k
a + a ≡ b + b (mod 3 )
3 3 k
a − b + a − b ≡ 0 (mod 3 )
2 2 k
(a − b)(a + ab + b + 1) ≡ 0 (mod 3 )
a prime divisor p for which the condition doesn’t hold, then the same is true for n as
well, so let’s just look at the primes.
If p ≡ 1 (mod 4) is a prime, we know that −1 is a quadratic residue of p, so there
is an x for which
2
x ≡ −1 (mod p)
3
x + x ≡ 0 (mod p)
If we choose y = 0,
3 3
x +x≡y +y (mod p)
So, n can not have any prime factor ≡ 1 (mod 4). Let p ≡ 3 (mod 4) be a prime. We
must have
3 3 3
(1 + 1) ⋅ (2 + 2)⋯((p − 1) + p − 1) ≡ 1 ⋅ 2⋯(p − 1) (mod p)
p−1
2
1 ⋅ 2⋯(p − 1) ∏(k + 1) ≡ 1 ⋅ 2⋯(p − 1) (mod p)
k=1
p−1
2
∏(k + 1) ≡ 1 (mod p)
k=1
p−1
∏(k + i)(k − i) ≡ 1 (mod p)
k=1
371
§0. Solving Challenge Problems Masum Billal, Amir Hossein
Problem 405 (Croatia 2014). Do there exist positive integers m and n such that
2 2
m + n and n + m are squares of positive integers?
This is a problem where we use another technique, we will call it squeezing between
squares. The name is due to Dan Schwarz, who was a problem solver and creator from
Romania, and a user on Art of Problem Solving. He used the handle mavropnevma and
taught many people many things through the forum. In a solution of a similar problem,
he used the words squeezing between squares. So, out of respect we named this.
372
§0. Solving Challenge Problems Masum Billal, Amir Hossein
is
= (1, 10) + (2, 10) + (3, 10) + (4, 10) + (5, 10) + (6, 10)
+ (7, 10) + (8, 10) + (9, 10) + (10, 10)
and hence,
f (10) = 1 + 2 + 1 + 2 + 5 + 2 + 1 + 2 + 1 + 10
= 1 ⋅ 4 + 2 ⋅ 4 + 5 ⋅ 1 + 10 ⋅ 1
First of all, 1, 2, 5, 10 are divisors of 10. Since (i, n) will be a divisor of n, it makes sense.
Now we just need to figure out how to determine those numbers 4, 4, 1, 1 for 1, 2, 5, 10
respectively. Let’s think about the case when divisor, d = 2. We want (i, 10) = d so we
can write i = dj and 10 = dm where (j, m) = 1. Since we are counting all such possible
j, it is simply the number of j less than or equal to m, which are relatively prime to
10
m. In other words, the coefficient of i is φ(m) = φ( ). Now, let’s prove it formally.
d
n
f (n) = ∑(i, n)
i=1
n
= ∑(dj, dm)
i=1
m
= ∑ ∑ d(j, m)
d∣n j=1
j⊥m
= ∑ dφ(m)
d∣n
n
= ∑ dφ( )
d
d∣n
n
= ∑ φ(d)
d
d∣n
φ(d)
= n∑
d
d∣n
373
§0. Solving Challenge Problems Masum Billal, Amir Hossein
mn
= ∑ ef φ( )
d=ef
ef
e∣m
f ∣n
m n
= ∑ ef φ( e )φ( )
f
e∣m
f ∣n
m n
= ∑ eφ( e ) ∑ f ( )
f
e∣m f ∣n
= f (m)f (n)
We could also prove it using Dirichlet product. If f (n) = n and g(n) = φ(n), then
both f and g are multiplicative. So, their Dirichlet product would be multiplicative
as well.
n
f ∗ g = ∑ f (d)g( )
d
d∣n
n
= ∑ dφ( )
d
d∣n
But clearly the sum on the left side is hard to deal with. It would be better if we
could have another representation, probably a closed form instead of a summation.
Let’s determine f (p ) first.
i
φ(p )
e i
e e φ(d) e
f (p ) = p ∑ =p ∑
e
d
d∣p i=0
pi
(p − 1)
e i−1
e p
= p (1 + ∑ )
i=1
pi
e
e p−1
= p (1 + ∑ p )
i=1
e(p − 1)
= p (1 + )
e
p
374
§0. Solving Challenge Problems Masum Billal, Amir Hossein
e(p − 1)
p (1 + ) = ap
e e
p
and so,
e(p − 1)
1+ p =a
a = 1 + k(p − 1)
Problem 408 (IMO 2006). Find all integers x and y which satisfy the equation
x 2x+1 2
1+2 +2 =y
Removing 1 from both sides and then dividing by 4, one can write the above equation
as
x−2 x+1
(2) 2 (2 + 1) = k(k + 1)
375
§0. Solving Challenge Problems Masum Billal, Amir Hossein
∣ k(k + 1) reduces to
x−2 x−2
2. k is odd. So k + 1 is even and gcd(2 , k) = 1. Then 2
∣ k + 1. Let k + 1 = 2 ⋅ m and rewrite equation (2) as
x−2 x−2
2
x+1 x−2
2 + 1 = m(2 ⋅ m − 1)
Hence the solutions are: (x, y) = {(0, 2), (0, −2), (4, 23), (4, −23)}.
376
CHAPTER VII.
σ(n)
Problem 409. Show that the ratio n can be arbitrarily large for infinitely many
n.
This PDF was created
for Amazon.
Problem 410. Prove that for all positive integers n, there exists an n-digit prime.
Problem 411. There are n points on a circle with n > 10, and each point is given a
number that is equal to the average of the numbers of its two nearest neighbors. Show
that all the numbers must be equal.
Problem 412. Let F (n) be the nth Fibonacci number, show that for some n > 1,
F (n) ends with 2007 zeros.
Problem 413. Let N = .23571113... where N consists of all prime numbers concate-
nated together after the decimal. Determine if N is rational or irrational.
Problem 414. Prove that there exists a positive integer n such that the four leftmost
digits of the decimal representation of 2n is 2007.
Problem 415. The only sets of N − 1 (distinct) integers, with no non-empty subset
having its sum of elements divisible by N , are those where all integers are congruent to
a same residue modulo N , relatively prime with N .
Problem 416 (Austrian Mathematical Olympiad, 2016). Determine all composite pos-
itive integers n with the following property: If 1 = d1 < d2 < ⋯ < dk are the divisors of
n then
d2 − d1 ∶ d3 − d2 ∶ ⋯ ∶ dk − dk−1 = 1 ∶ 2 ∶ ⋯k − 1
n
Problem 417 (Belarus 2009). Find all m, n ∈ N such that m! + n! = m .
Problem 418. Integer n > 2 is given. Find the biggest integer d, for which holds, that
from any set S consisting of n integers, we can find three different (but not necessarily
disjoint) nonempty subsets, such that sum of elements of each of them is divisible by d.
Problem 419. Consider the setM = {1, 2, 3, ..., 2007}. Prove that in any way we
choose the subset X with 15 elements of M there exist two disjoint subsets A and B in
X such that the sum of the members of A is equal to the sum of the members of B.
§0. Practice Challenge Problems Masum Billal, Amir Hossein
Problem 423 (Slovenia 2010). Find all prime numbers p, q and r such that p > q > r
and the numbers p − q, p − r and q − r are also prime.
Problem 424 (Croatia Mathematical Olympiad, First Round, 2016). Determine the
number of positive integers smaller than 1000000, that are also perfect squares and give
a remainder 4 when divided by 8.
Problem 425. Prove that among 81 natural numbers whose prime divisors are in the
set {2, 3, 5} there exist four numbers whose product is the fourth power of an integer.
Problem 426. We chose n + 2 numbers from set {1, 2, ...3n}. Prove that there are
always two among the chosen numbers whose difference is more than n but less than
2n.
Problem 427 (India 2014). Let a, b be natural numbers with ab > 2. Suppose that the
sum of their greatest common divisor and least common multiple is divisble by a + b.
a+b a+b
Prove that the quotient is at most . When is this quotient exactly equal to ?
4 4
Problem 428. The integers 1, ..., n are arranged in any order. In one step any two
neighboring integers may be interchanged. Prove that the initial order can never be
reached after an odd number of steps.
Problem 429. A palindrome is a number or word that is the same when read forward
and backward, for example, 176671 and civic. Can the number obtained by writing the
numbers from 1 to n in order (for some n > 1) be a palindrome?
Problem 430 (IMO Shortlist N2, Proposed by Jorge Tipe, Peru). 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. Given positive integers a and b, consider the polynomial
P defined by P (x) = (x + a)(x + b).
(a) Prove that there exist distinct positive integers a and b such that all the number
P (1), P (2),. . ., P (50) are balanced.
(b) Prove that if P (n) is balanced for all positive integers n, then a = b.
2 2
Problem 431. Let n be an integer. Prove that if the equation x + xy + y = n has a
rational solution, then it also has an integer solution.
378
§0. Practice Challenge Problems Masum Billal, Amir Hossein
Problem 432 (Iran Olympiad, Third Round). Let p be a prime number. Prove that,
there exists integers x, y such that p = 2x + 3y if and only if p ≡ 5, 11 (mod 24).
2 2
Problem 433 (Polish Math Olympiad). Let S be a set of all positive integers which
2 2
can be represented as a + 5b for some integers a, b such that a⊥b. Let p be a prime
number such that p = 4n + 3 for some integer n. Show that if for some positive integer
k the number kp is in S, then 2p is in S as well.
3 2
Problem 434. Prove that the equation x − x + 9 = 5y has no solution in integers.
Problem 435 (India TST). On the real number line, paint red all points that corre-
spond to integers of the form 81x + 100y, where x and y are positive integers. Paint the
remaining integer point blue. Find a point P on the line such that, for every integer
point T , the reflection of T with respect to P is an integer point of a different colour
than T .
Problem 436. Prove that, for any positive integer k, there are positive integers a, b > 1
such that
2 2
a +b −1
k=
ab
2 2
Problem 437. Let a, b, and c be positive integers such that 0 ≤ a + b − abc ≤ c.
2 2
Prove that a + b − abc is a perfect square.
th
Problem 438. Let the n Lemur set, Ln , be the set composed of all positive integers
that are equal to the sum of the squares of their first n divisors. For example, L1 = {1},
L2 = {}, and L4 = {130}.
a Find L3 , L5 , and L6 .
Problem 439 (IMO 2007, Problem 5). Let a and b be positive integers so that 4ab − 1
divides (4a − 1) . Prove that a = b.
2 2
Problem 440. Let a1 , a2 , . . . , an be positive integers such that a1 < a2 < ⋯ < an .
Prove that
n−1
1
∑ <1
i=1
[ai , ai−1 ]
p ⋯p
Problem 441. Let N = 2 1 n + 1 where pi are distinct primes greater than 2 and
τ (N ) is the number of divisors of N . Maximize τ (N ).
379
§0. Practice Challenge Problems Masum Billal, Amir Hossein
⌊ d2 ⌋
N =2 +1
λ(n)−2
2 −1
has at least 2 divisors.
Fn 2
≡ 1 (mod Fn+m )
Problem 444. Let f (x) = x + 17. Prove that for each natural number n ≥ 2, there
3
Problem 445 (Boylai). Show that every Fermat prime is of the form 6k − 1.
Problem 446 (Iran TST 2015). We are given three natural numbers a1 , a2 , a3 . For
n ≥ 3,
Problem 447 (Bosnia Olympiad 2013, Second Day). Find all primes p and q such
that p ∣ 30q − 1 and q ∣ 30p − 1.
Problem 448 (IMO Shortlist 2004, N3, Proposed by Iran). f is a function with f ∶
N → N so that
2 2 2
f (m) + f (n) ∣ (m + n)
Problem 449 (Columbia 2010). Find all pairs of positive integers (m, n) such that
m + n = (m + 1)(n + 1).
2 2
Problem 450 (AMOC 2014, Senior Section). For which integers n ≥ 2 is it possible
to separate the numbers 1, 2, . . . , n into two sets such that the sum of the numbers in
one of the sets is equal to the product of the numbers in the other set?
Problem 451 (Greece). Determine all triples (p, m, n) of positive integers such that
m 3
p is a prime number and p − 8 = n .
Problem 452 (Canadian Students Math Olympiad 2011). For a fixed positive integer
k, prove that there exist infinitely many primes p such that there is an integer w, where
2
w − 1 is not divisible by p, and the order of w modulo p is the same as the order of w
k
modulo p .
380
§0. Practice Challenge Problems Masum Billal, Amir Hossein
Problem 453 (China TST 2009). Let a > b > 1 and b be an odd integer, n ∈ N. If
n
3
b ∣ a − 1, then prove that a > n .
n n b
Problem 455 (Kazakhstan 2015). Pk (n) is the product of all divisors of n that are
divisible by k (in empty case it is 1). Prove that, P1 (n) ⋅ P2 (n)⋯Pn (n) is a perfect
square.
Problem 457 (Croatia 2014). For a positive integer n denote by s(n) the sum of all
positive divisors of n and by d(n) the number of positive divisors of n. Determine all
positive integers n such that
s(n) = n + d(n) + 1
Problem 458 (IMO 2003, Problem 2, N3). Find all pairs of positive integers (a, b)
such that
2
a
2ab − b3 + 1
2
is a positive integer.
Problem 460 (IMO Shortlist 2004, N2 Part (c)). Find all n for which f (n) = an has
a unique solution where,
n
f (n) = ∑(i, n)
i=1
Problem 461. Let k be a positive integer. Find all positive integers n such that
3 ∣ 2 − 1.
k n
Problem 462. Let a, b be distinct real numbers such that the numbers
2 2 3 3
a − b, a − b , a − b , . . .
Problem 463 (MOSP 2001). Find all quadruples of positive integers (x, r, p, n) such
r n
that p is a prime number, n, r > 1 and x − 1 = p .
Problem 464 (China TST 2009). Let a > b > 1 be positive integers and b be an odd
n
number, let n be a positive integer. If b ∣ a − 1, then show that a > 3n .
n n b
381
§0. Practice Challenge Problems Masum Billal, Amir Hossein
Problem 465 (Romanian Junior Balkan TST 2008). Let p be a prime number, p ≠ 3,
and integers a, b such that p ∣ a + b and p ∣ a + b . Prove that p ∣ a + b or p ∣ a + b .
2 3 3 2 3 3 3
Problem 466. Let m and n be positive integers. Prove that for each odd positive
integer b there are infinitely many primes p such that p ≡ 1 (mod b ) implies b ∣ n.
n m m−1
Problem 469. For some natural number n let a be the greatest natural number for
n n a
which 5 − 3 is divisible by 2 . Also let b be the greatest natural number such that
b
2 ≤ n. Prove that a ≤ b + 3.
Problem 470. Determine all sets of non-negative integers x, y and z which satisfy the
equation
x y 2
2 +3 =z
Problem 471 (IMO ShortList 2007). Find all surjective functions f ∶ N → N such
that for every m, n ∈ N and every prime p, the number f (m + n) is divisible by p if
and only if f (m) + f (n) is divisible by p.
Problem 472 (Romania TST 1994). Let n be an odd positive integer. Prove that
n
(n−1) +1
((n − 1) + 1) divides n(n − 1)
n 2
+ n.
n n
Problem 473. Find all positive integers n such that 3 − 1 is divisible by 2 .
Problem 474 (Romania TST 2009). Let a, n ≥ 2 be two integers, which have the
following property: there exists an integer k ≥ 2, such that n divides (a − 1) . Prove
k
n−1 n−2
that n also divides a +a + ⋯ + a + 1.
a
5 +1
Problem 475. Find all the positive integers a such that 3a
is a positive integer.
Problem 476. Find all primes p, q such that pq ∣ 5 + 5 .
p q
Problem 478 (APMO 2016). A positive integer is called fancy if it can be expressed
in the form
a a a
2 1 + 2 2 + ⋯ + 2 100
where a1 , a2 , ⋯, a100 are non-negative integers that are not necessarily distinct. Find
the smallest positive integer n such that no multiple of n is a fancy number.
Problem 479 (Argentina Intercollegiate Olympiad First Level 2016). Find all positive
integers a, b, c, and d, all less than or equal to 6, such that
a c
= +2
b d
382
§0. Practice Challenge Problems Masum Billal, Amir Hossein
Problem 480 (Argentina Intercollegiate Olympiad Second Level 2016). Find all pos-
itive integers x and y which satisfy the following conditions:
Note. A palindromic number is a number that remains the same when its digits are
reversed. For example, 16461 is a palindromic number.
Problem 481 (Argentina Intercollegiate Olympiad Third Level 2016). Find a number
with the following conditions:
1. it is a perfect square,
2. when 100 is added to the number, it equals a perfect square plus 1, and
3. when 100 is again added to the number, the result is a perfect square.
Problem 482 (Argentina Intercollegiate Olympiad Third Level 2016). Let a1 , a2 , . . . , a15
be an arithmetic progression. If the sum of all 15 terms is twice the sum of the first 10
terms, find ad , where d is the common difference of the progression.
1
Problem 483 (Austria Federal Competition for Advanced Students Final Round
2016). Determine all composite positive integers n with the following property: If
1 = d1 < d2 < ⋅ ⋅ ⋅ < dk = n are all the positive divisors of n, then
Problem 484 (Austria National Competition Final Round 2016). Let a, b, and c be
integers such that
ab ac bc
c + b + a
is an integer. Prove that each of the numbers
ab ac bc
,
c b , and a
is an integer.
Problem 485 (Austria Beginners’ Competition 2016). Determine all non-negative in-
tegers n having two distinct positive divisors with the same distance from n/3.
Problem 486 (Austria Regional Competition 2016). Determine all positive integers k
and n satisfying the equation
2 n
k − 2016 = 3
Problem 487 (Azerbaijan TST 2016). The set A consists of natural numbers such that
these numbers can be expressed as 2x + 3y , where x and y are integers. (x + y =/ 0)
2 2 2 2
383
§0. Practice Challenge Problems Masum Billal, Amir Hossein
2. Prove that multiple of odd number of elements of the set A cannot be a perfect
square.
34! = 295232799039a041408476186096435b0000000
Problem 489 (Azerbaijan Junior Mathematical Olympiad 2016). Prove that if for a
n
real number a, a + a1 is integer then a + a1n is also integer for any positive integer n.
Problem 491 (Balkan 2016). Find all monic polynomials f with integer coefficients
satisfying the following condition: there exists a positive integer N such that p divides
2(f (p)!) + 1 for every prime p > N for which f (p) is a positive integer.
Note: A monic polynomial has a leading coefficient equal to 1.
k k
Problem 492 (Bay Area Olympiad 2016). Let A = 2 − 2 and B = 2 ⋅ A, where k is
an integer (k ≥ 2). Show that, for every integer k greater than or equal to 2,
Problem 493 (Bay Area Olympiad 2016). Find a positive integer N and a1 , a2 , ⋯, aN
where ak = 1 or ak = −1, for each k = 1, 2, ⋯, N, such that
3 3 3 3
a1 ⋅ 1 + a2 ⋅ 2 + a3 ⋅ 3 ⋯ + aN ⋅ N = 20162016
Problem 494 (Belgium Flanders Math Olympiad Final Round 2016). Find the small-
est positive integer n which does not divide 2016!.
Problem 495 (Belgium National Olympiad Final Round 2016). Solve the equation
2m+1 m 2
2 +9⋅2 +5=n
384
§0. Practice Challenge Problems Masum Billal, Amir Hossein
Problem 496 (Benelux 2016). Find the greatest positive integer N with the following
2
property: there exist integers x1 , . . . , xN such that xi − xi xj is not divisible by 1111 for
any i ≠ j.
Problem 497 (Benelux 2016). Let n be a positive integer. Suppose that its positive
divisors can be partitioned into pairs (i.e. can be split in groups of two) in such a way
that the sum of each pair is a prime number. Prove that these prime numbers are
distinct and that none of these are a divisor of n.
Problem 498 (Bosnia and Herzegovina TST 2016). For an infinite sequence a1 < a2 <
a3 < . . . of positive integers we say that it is nice if for every positive integer n holds
a2n = 2an . Prove the following statements:
(a) If there is given a nice sequence and prime number p > a1 , there exist some term
of the sequence which is divisible by p.
(b) For every prime number p > 2, there exist a nice sequence such that no terms of
the sequence are divisible by p.
Problem 499 (Bosnia and Herzegovina TST 2016). Determine the largest positive
integer n which cannot be written as the sum of three numbers bigger than 1 which are
pairwise relatively prime.
Problem 500 (Bulgaria National Olympiad 2016). Find all positive integers m and n
m n
such that (2 + 1) (2 + 1) is divisible by mn.
2 2
Problem 501 (Bulgaria National Olympiad 2016). Determine whether there exists a
9
positive integer n < 10 such that n can be expressed as a sum of three squares of
positive integers by more than 1000 distinct ways.
Problem 504 (Canada National Olympiad 2016). Find all polynomials P (x) with
integer coefficients such that P (P (n)+n) is a prime number for infinitely many integers
n.
Problem 505 (CCA Math Bonanza 2016). Let f (x) = x + x + 1. Determine the
2
Problem 506 (CCA Math Bonanza 2016). Let f (x) = x + x + 1. Determine the
2
385
§0. Practice Challenge Problems Masum Billal, Amir Hossein
Problem 508 (CCA Math Bonanza 2016). Pluses and minuses are inserted in the
expression
±1 ± 2 ± 3 ⋅ ⋅ ⋅ ± 2016
such that when evaluated the result is divisible by 2017. Let there be N ways for this
to occur. Compute the remainder when N is divided by 503.
Problem 509 (CCA Math Bonanza 2016). What is the largest integer that must divide
5 3
n − 5n + 4n for all integers n?
Problem 510 (CCA Math Bonanza 2016). Determine the remainder when
6 10 12 4 2 2 10 6 12
2 ⋅ 3 ⋅ 5 − 75 (26 − 1) + 3 − 50 + 5
is divided by 1001.
Problem 511 (CentroAmerican 2016). Find all positive integers n that have 4 digits,
all of them perfect squares, and such that n is divisible by 2, 3, 5, and 7.
Problem 512 (CentroAmerican 2016). We say a number is irie if it can be written
1
in the form 1 + for some positive integer k. Prove that every integer n ≥ 2 can be
k
written as the product of r distinct irie numbers for every integer r ≥ n − 1.
Problem 513 (Chile 2016). Determine all triples of positive integers (p, n, m) with p
a prime number, which satisfy the equation:
m 3
p − n = 27
1
Problem 514 (Chile 2016 ). Find all prime numbers that do not have a multiple
ending in 2015.
2
Problem 515 (Chile 2016). Find the number of different numbers of the form ⌊ 2015
i
⌋,
where i = 1, 2, . . . , 2015.
Problem 516 (China Girls Mathematical Olympiad 2016). Let m and n are relatively
prime integers and m > 1, n > 1. Show that there are positive integers a, b, c such that
a b
m = 1 + n c , and n and c are relatively prime.
Problem 517 (China National Olympiad 2016). Let p be an odd prime and a1 , a2 , ..., ap
be integers. Prove that the following two conditions are equivalent:
1. There exists a polynomial P (x) with degree ≤ p−1
2
such that P (i) ≡ ai (mod p)
for all 1 ≤ i ≤ p.
1
Thanks to Kamal Kamrava and Behnam Sajadi for translating the problem.
386
§0. Practice Challenge Problems Masum Billal, Amir Hossein
p−1
2. For any natural d ≤ 2
,
p
2
∑(ai+d − ai ) ≡ 0 (mod p)
i=1
Problem 519 (China South East Mathematical Olympiad 2016). Let {an } be a se-
quence consisting of positive integers such that n ∣ ∑i=1 ai and an ≤ (n + 2016) for all
2 n 2
n ≥ 2016. Define bn = an+1 − an . Prove that the sequence {bn } is eventually constant.
Problem 520 (China South East Mathematical Olympiad 2016). Define the sets
3 3 3
A = {a + b + c − 3abc ∶ a, b, c ∈ N}
B = {(a + b − c)(b + c − a)(c + a − b) ∶ a, b, c ∈ N}
P = {n ∶ n ∈ A ∩ B, 1 ≤ n ≤ 2016}
integer n and for any positive odd number a ≤ n, ∏m=1 f (m) is a multiple of a.
n
Problem 523 (China TST 2016). Does there exist two infinite positive integer sets
S, T , such that any positive integer n can be uniquely expressed in the form
n = s1 t1 + s2 t2 + . . . + sk tk
holds for all integers n ≥ M . Prove that the above equation is true for all positive
integers n. (Here Sq (x) is the sum of digits of x taken in base q).
387
§0. Practice Challenge Problems Masum Billal, Amir Hossein
Problem 525 (China Western Mathematical Olympiad 2016). For an n-tuple of inte-
gers, define a transformation to be:
Find all ordered pairs of integers (n, k) with n, k ≥ 2, such that for any n-tuple of
integers (a1 , a2 , . . . , an−1 , an ), after a finite number of transformations, every element
in the of the n-tuple is a multiple of k.
Problem 526 (China Western Mathematical Olympiad 2016). Prove that there exist
infinitely many positive integer triples (a, b, c) such that a, b, c are pairwise relatively
prime ,and ab + c, bc + a, ca + b are pairwise relatively prime.
Problem 527 (Croatia First Round Competition 2016). Can the sum of squares of
three consecutive integers be divisible by 2016?
Problem 528 (Croatia First Round Competition 2016). Let a = 123456789 and N =
3 2
a − 2a − 3a. Prove that N is a multiple of 540.
Problem 529 (Croatia First Round Competition 2016). Find all pairs (a, b) of positive
integers such that 1 < a, b ≤ 100 and
1 1
+
loga 10 logb 10
is a positive integer.
Problem 530 (Croatia First Round Competition 2016). A sequence (an ) is given:
a1 = a2 = 1, and
2 2 2
a a a
an+1 = a2 + a3 + ⋅ ⋅ ⋅ + a n
1 2 n−1
(b) Prove that there are no two positive integers such that the difference of their cubes
is 987654.
Problem 534 (Croatia Second Round Competition 2016). How many ordered pairs
(m, k) of positive integers satisfy the following?
388
§0. Practice Challenge Problems Masum Billal, Amir Hossein
Problem 535 (Croatia Second Round Competition 2016). Determine all pairs (a, b)
of positive integers such that
3
a − 3b = 15
2
b − a = 13
Problem 536 (Croatia Second Round Competition 2016). Prove that, for every pos-
itive integer n > 3, there are n different positive integers whose reciprocals add up to
1.
Problem 537 (Croatia Second Round Competition 2016). Determine all pairs (a, b)
of integers such that (7a − b) = 2(a − 1)b .
2 2
Problem 538 (Croatia Final Round National Competition 2016). Determine the sum
2 2 2
2 +1 3 +1 100 + 1
2
+ 2 + ⋅⋅⋅ +
2 −1 3 −1 1002 − 1
Problem 539 (Croatia Final Round National Competition 2016). Let a, b, and c be
positive integers such that
b 1
c=a+ a −
b
Prove that c is the square of an integer.
Problem 540 (Croatia Final Round National Competition 2016). Determine all pairs
(m, n) of positive integers for which exist integers a, b, and c that satisfy
a+b+c=0
2 2 2 m n
a +b +c =2 ⋅3
Problem 541 (Croatia Final Round National Competition 2016). Prove that there
2
does not exist a positive integer k such that k + 4 and k + 5k + 2 are cubes of positive
integers.
Problem 542 (Croatia Final Round National Competition 2016). Determine all triples
(m, n, k) of positive integers such that 3 + 7 = k .
m n 2
Problem 543 (Croatian Mathematical Olympiad 2016). Find all pairs (p, q) of prime
numbers such that
2
p(p − p − 1) = q(2q + 3)
Problem 544 (Croatian TST for MEMO 2016, Sweden 2014). Find all pairs (m, n)
of positive integers such that
m n
3⋅5 −2⋅6 =3
Problem 545 (Croatia IMO TST 2016). Prove that for every positive integer n there
2 2
exist integers a and b such that n divides 4a + 9b − 1.
389
§0. Practice Challenge Problems Masum Billal, Amir Hossein
9
Problem 546 (Croatia IMO TST 2016, Bulgaria TST 2016). Let p > 10 be a prime
1
number such that 4p+1 is also prime. Prove that the decimal expansion of 4p+1 contains
all the digits 0, 1, . . . , 9.
Problem 547 (Denmark Georg Mohr Contest Second Round 2016). Find all possible
values of the number
a+b a+c b+c
c + b + a
a+b a+c b+c
where a, b, and c are positive integers, and c
, b , and a
are also positive integers.
Problem 548 (ELMO 2016). Cookie Monster says a positive integer n is crunchy if
there exist 2n real numbers x1 , x2 , . . . , x2n , not all equal, such that the sum of any n
of the xi ’s is equal to the product of the other n of the xi ’s. Help Cookie Monster
determine all crunchy integers.
Problem 549 (ELMO 2016). Big Bird has a polynomial P with integer coefficients
such that n divides P (2 ) for every positive integer n. Prove that Big Bird’s polynomial
n
Problem 551 (Estonia IMO TST First Stage 2016). Prove that for every positive
integer n ≥ 3,
√ √ 3 √
2 ⋅ 3 ⋅ 4 . . . n−1 n > n
Problem 552 (Estonia IMO TST Second Stage 2016). Find all positive integers n
such that
2 n
(n + 11n − 4) ⋅ n! + 33 ⋅ 13 + 4
is a perfect square.
Problem 553 (Estonia National Olympiad Tenth Grade 2016). Find all pairs of inte-
gers (a, b) which satisfy
2 2
3(a + b ) − 7(a + b) = −4
Problem 554 (Estonia National Olympiad Eleventh Grade 2016). Find the greatest
2016 n
positive integer n for which 3 − 1 is divisible by 2 .
Problem 555 (Estonia National Olympiad Eleventh Grade 2016). Let n be a positive
integer. Let δ(n) be the number of positive divisors of n and let σ(n) be their sum.
Prove that
(δ(n))
2
σ(n) >
2
390
§0. Practice Challenge Problems Masum Billal, Amir Hossein
Problem 556 (Estonia Regional Olympiad Tenth Grade 2016). Does the equation
2 2 2 2
x + y + z + w = 3 + xy + yz + zw
p1 , p1 + p2 , . . . , p1 + p2 + ⋅ ⋅ ⋅ + pn
Problem 561 (European Mathematical Cup Juniors 2016). Let d(n) denote the num-
ber of positive divisors of n. For a positive integer n we define f (n) as
where 1 = k1 < k2 < . . . < km = n are all divisors of the number n. We call an integer
n > 1 almost perfect if f (n) = n. Find all almos perfect numbers.
Problem 562 (Finland MAOL Competition 2016). Let n be a positive integer. Find
all pairs (x, y) of positive integers such that
n
(4a − b)(4b − a) = 1770
Problem 563 (Germany National Olympiad First Round Ninth/Tenth Grade, 2016).
(A) Prove that there exists an integer a > 1 such that the number
8 4
82 ⋅ (a − a )
is divisible by the product of three consecutive positive integers each of which has
at least two digits.
391
§0. Practice Challenge Problems Masum Billal, Amir Hossein
(B) Determine the smallest prime number a with at least two digits such that the
number
8 4
82 ⋅ (a − a )
is divisible by the product of three consecutive positive integers each of which has
at least two digits.
(C) Determine the smallest integer a > 1 such that the number
8 2
82 ⋅ (a − a )
is divisible by the product of three consecutive positive integers each of which has
at least two digits.
Problem 564 (Germany National Olympiad First Round Eleventh/Twelfth Grade,
2016). Consider the following system of equations:
2(z − 1) − x = 55
4xy − 8z = 12
a(y + z) = 11
Find two largest real values for a for which there are positive integers x, y, and z that
satisfy the system of equations. In each of these solutions, determine xyz.
Problem 565 (Germany National Olympiad First Round Eleventh/Twelfth Grade,
2016). Find all pairs (a, b) of positive integers for which (a + 1)(b + 1) is divisible by
ab.
Problem 566 (Germany National Olympiad Second Round Tenth Grade, 2016). For
each of the following cases, determine whether there exist prime numbers x, y, and z
such that the given equality holds
2 2
(a) y = z − x .
2 4
(b) x + y = z .
2 3 4
(c) x + y = z .
Problem 567 (Germany National Olympiad Second Round Eleventh/Twelfth Grade,
2016). The sequence x1 , x2 , x3 , . . . is defined as x1 = 1 and
xk+1 = xk + yk
where yk is the last digit of decimal representation of xk . Prove that the sequence
x1 , x2 , x3 , . . . contains all powers of 4. That is, for every positive integer n, there exists
n
some natural k for which xk = 4 .
Problem 568 (Germany National Olympiad Third Round Eleventh/Twelfth Grade,
2016). Find all positive integers a and b which satisfy
ab + 1
( 2 ) = 2ab(a + b)
392
§0. Practice Challenge Problems Masum Billal, Amir Hossein
Problem 573 (Germany TST 2016). The positive integers a1 , a2 , . . . , an are aligned
clockwise in a circular line with n ≥ 5. Let a0 = an and an+1 = a1 . For each i ∈
{1, 2, . . . , n} the quotient
ai−1 + ai+1
qi = a1
2
Thanks to Arian Saffarzadeh for translating the problem.
393
§0. Practice Challenge Problems Masum Billal, Amir Hossein
2n ≤ q1 + q2 + ⋅ ⋅ ⋅ + qn
< 3n
Problem 574 (Germany TST 2016, Taiwan TST First Round 2016). Determine all
positive integers M such that the sequence a0 , a1 , a2 , ⋯ defined by
1
a0 = M +
2
ak+1 = ak ⌊ak ⌋
..
.
Problem 576 (Greece TST 2016). Given is the sequence (an )n≥0 which is defined as
follows:a0 = 3 and an+1 − an = n(an − 1) , ∀n ≥ 0. Determine all positive integers m
such that gcd(m, an ) = 1 for all n ≥ 0.
Problem 577 (Harvard-MIT Math Tournament 2016). Denote by N the positive in-
tegers. Let f ∶ N → N be a function such that, for any w, x, y, z ∈ N,
2
f (f (f (z)))f (wxf (yf (z))) = z f (xf (y))f (w)
394
§0. Practice Challenge Problems Masum Billal, Amir Hossein
Problem 581 (Hong Kong Preliminary Selection Contest 2016). Let n be a positive
integer. If the two numbers (n + 1)(2n + 15) and n(n + 5) have exactly the same prime
factors, find the greatest possible value of n.
Problem 582 (Hong Kong Preliminary Selection Contest 2016). An arithmetic se-
quence with 10 terms has common difference d > 0. If the absolute value of each term
is a prime number, find the smallest possible value of d.
2
Problem 583 (Hong Kong Preliminary Selection Contest 2016). Let a1 = 3
and
√
an 24an + 9 9
an+1 = + −
4 256 48
for all integers n ≥ 1. Find the value of
a1 + a2 + a3 + . . .
2
Problem 584 (Hong Kong TST 2016). Find all natural numbers n such that n, n +10,
2 3 5
n − 2, n + 6, and n + 36 are all prime numbers.
Problem 585 (Hong Kong TST 2016). Find all triples (m, p, q) such that
m 2 7
2 p +1=q
Problem 586 (Hong Kong TST 2016). Find all prime numbers p and q such that
p ∣ q + 1 and q ∣ p − 1.
2 3 2 6
Problem 587 (Hong Kong TST 2016). Let p be a prime number greater than 5.
2
Suppose there is an integer k satisfying that k + 5 is divisible by p. Prove that there
2 2 2
are positive integers m and n such that p = m + 5n .
Problem 588 (IberoAmerican 2016). Find all prime numbers p, q, r, k such that pq +
qr + rp = 12k + 1.
Problem 590 (IMO Shortlist 2015, India TST 2016, Taiwan TST Second Round
2016, Croatian Mathematical Olympiad 2016, Switzerland TST 2016). Let m and n be
positive integers such that m > n. Define
m+k
xk =
n+k
for k = 1, 2, . . . , n + 1. Prove that if all the numbers x1 , x2 , . . . , xn+1 are integers, then
x1 x2 . . . xn+1 − 1 is divisible by an odd prime.
395
§0. Practice Challenge Problems Masum Billal, Amir Hossein
Problem 591 (IMO 2016). A set of postive integers is called fragrant if it contains at
least two elements and each of its elements has a prime factor in common with at least
one of the other elements. Let P (n) = n + n + 1. What is the least possible positive
2
integer value of b such that there exists a non-negative integer a for which the set
is fragrant?
Problem 592 (India IMO Training Camp 2016). Given that n is a natural number
n n
such that the leftmost digits in the decimal representations of 2 and 3 are the same,
find all possible values of the leftmost digit.
Problem 593 (India IMO Practice Test 2016). We say a natural number n is perfect
if the sum of all the positive divisors of n is equal to 2n. For example, 6 is perfect since
its positive divisors 1, 2, 3, 6 add up to 12 = 2 × 6. Show that an odd perfect number
has at least 3 distinct prime divisors.
Problem 594 (India TST 2016). Let n be a natural number. We define sequences ⟨ai ⟩
and ⟨bi ⟩ of integers as follows. We let a0 = 1 and b0 = n. For i > 0, we let
⎧
⎪(2ai−1 + 1, bi−1 − ai−1 − 1) if ai−1 < bi−1
⎪
⎪
⎪
(ai , bi ) = ⎨(ai−1 − bi−1 − 1, 2bi−1 + 1) if ai−1 > bi−1
⎪
⎪
⎪
⎪
⎩(ai−1 , bi−1 ) if ai−1 = bi−1
Given that ak = bk for some natural number k, prove that n + 3 is a power of two.
Problem 595 (India TST 2016). Let N denote the set of all natural numbers. Show
that there exists two nonempty subsets A and B of N such that
1. A ∩ B = {1};
3. each prime number is a divisor of some number in A and also some number in B;
4. one of the sets A and B has the following property: if the numbers in this set are
written as x1 < x2 < x3 < ⋯, then for any given positive integer M there exists
k ∈ N such that xk+1 − xk ≥ M ;
(i) Show that for each n ∈ N, there exists k such that T (n) = 1.
k
(ii) For k ∈ N, let ck denote the number of elements in the set {n ∶ T (n) = 1}. Prove
k
396
§0. Practice Challenge Problems Masum Billal, Amir Hossein
Problem 598 (Iran Third Round National Olympiad 2016). Let F be a subset of the
set of positive integers with at least two elements and P be a polynomial with integer
coefficients such that for any two elements of F like a and b, the following two conditions
hold
(i) a + b ∈ F , and
Problem 599 (Iran Third Round National Olympiad 2016). Let P be a polynomial
with integer coefficients. We say P is good if there exist infinitely many prime numbers
q such that the set
X = {P (n) mod q ∶ n ∈ N}
q+1 3
has at least 2
members. Prove that the polynomial x + x is good.
Problem 600 (Iran Third Round National Olympiad 2016). Let m be a positive
integer. The positive integer a is called a golden residue modulo m if gcd(a, m) = 1
and x ≡ a (mod m) has a solution for x. Given a positive integer n, suppose that a
x
n
n n
is a golden residue modulo n . Show that a is also a golden residue modulo n .
Problem 601 (Iran Third Round National Olympiad 2016). Let p, q be prime numbers
(q is odd). Prove that there exists an integer x such that
p p
q ∣ (x + 1) − x
if and only if
q ≡ 1 (mod p)
Problem 602 (Iran Third Round National Olympiad 2016). We call a function g
f (x)
special if g(x) = a (for all x) where a is a positive integer and f is polynomial with
integer coefficients such that f (n) > 0 for all positive integers n.
A function is called an exponential polynomial if it is obtained from the product or
2
x x +x−1 2x
sum of special functions. For instance, 2 3 + 5 is an exponential polynomial.
Prove that there does not exist a non-zero exponential polynomial f (x) and a non-
constant polynomial P (x) with integer coefficients such that
P (n) ∣ f (n)
397
§0. Practice Challenge Problems Masum Billal, Amir Hossein
Problem 603 (Iran Third Round National Olympiad 2016). A sequence P = {an }n=1
∞
is called a permutation of natural numbers if for any natural number m, there exists a
unique natural number n such that an = m.
We also define Sk (P ) as Sk (P ) = a1 + a2 + ⋅ ⋅ ⋅ + ak (the sum of the first k elements
of the sequence).
Prove that there exists infinitely many distinct permutations of natural numbers
like P1 , P2 , . . . such that for all k and i < j,
Sk (Pi ) ∣ Sk (Pj )
Problem 604 (Iran TST 2016). Let p ≠ 13 be a prime number of the form 8k + 5 such
that 39 is a quadratic non-residue modulo p. Prove that the equation
4 4 4 4
x1 + x2 + x3 + x4 ≡ 0 (mod p)
Problem 605 (Italy National Olympiad 2016). Determine all pairs of positive integers
(a, n) with a ≥ n ≥ 2 for which (a + 1) + a − 1 is a power of 2.
n
Problem 607 (Japan Mathematical Olympiad Preliminary 2016). Determine the num-
ber of pairs (a, b) of integers such that 1 ≤ a, b ≤ 2015, a is divisible by b+1, and 2016−a
is divisible by b.
Problem 608 (Japan Mathematical Olympiad Finals 2016). Let p be an odd prime
number. For positive integer k satisfying 1 ≤ k ≤ p − 1, the number of divisors of kp + 1
between k and p exclusive is ak . Find the value of a1 + a2 + . . . + ap−1 .
Problem 609 (Junior Balkan Mathematical Olympiad 2016). Find all triplets of in-
tegers (a, b, c) such that the number
(a − b)(b − c)(c − a)
N= +2
2
is a power of 2016.
Problem 610 (Korea Summer Program Practice Test 2016). A infinite sequence
{an }n≥0 of real numbers satisfy an ≥ n . Suppose that for each i, j ≥ 0 there exist
2
for some n.
Problem 611 (Korea Summer Program Practice Test 2016). A finite set S of positive
integers is given. Show that there is a positive integer N dependent only on S, such
that any x1 , . . . , xm ∈ S whose sum is a multiple of N , can be partitioned into groups
each of whose sum is exactly N . (The numbers x1 , . . . , xm need not be distinct.)
398
§0. Practice Challenge Problems Masum Billal, Amir Hossein
Problem 612 (Korea Winter Program Practice Test 2016). p(x) is an irreducible
polynomial with integer coefficients, and q is a fixed prime number. Let an be a number
n
of solutions of the equation p(x) ≡ 0 mod q . Prove that we can find M such that
{an }n≥M is constant.
Problem 613 (Korea Winter Program Practice Test 2016). Find all {an }n≥0 that
satisfies the following conditions.
1. an ∈ Z,
2. a0 = 0, a1 = 1,
4. For every n ≥ 2,
Problem 614 (Korea Winter Program Practice Test 2016). Find all positive integers
a, b, m, and n such that
2 2 2 2
a +b =m −n
ab = 2mn
Problem 615 (Korea Winter Program Practice Test 2016). Find all pairs of positive
integers (n, t) such that 6 + 1 = n t, and (n, 29 × 197) = 1.
n 2
Problem 616 (Korea National Olympiad Final Round 2016). Prove that for all ratio-
nals x, y, x − x1 + y − y1 = 4 is not true.
n
2
Problem 617 (Kosovo TST 2016). Show that for any n ≥ 2, the number 2 + 1 ends
with 7.
Problem 619 (Latvia National Olympiad 2016). Prove that among any 18 consecutive
positive 3 digit numbers, there is at least one that is divisible by the sum of its digits.
399
§0. Practice Challenge Problems Masum Billal, Amir Hossein
Problem 620 (Latvia National Olympiad 2016). Two functions are defined by equa-
tions: f (a) = a + 3a + 2 and g(b, c) = b − b + 3c + 3c. Prove that for any positive
2 2 2
integer a there exist positive integers b and c such that f (a) = g(b, c).
Problem 621 (Macedonian National Olympiad 2016). Solve the equation in the set
of natural numbers 1 + x + y = lcm(x , y ).
z z z z
Problem 622 (Macedonian National Olympiad 2016). Solve the equation in the set
of natural numbers xyz + yzt + xzt + xyt = xyzt + 3.
Problem 623 (Macedonian Junior Mathematical Olympiad 2016). Solve the equation
4 4 4 3
x1 + x2 + ⋅ ⋅ ⋅ + x14 = 2016 − 1
Problem 624 (Macedonian Junior Mathematical Olympiad 2016). Solve the equation
2 2
x + y + (gcd(x, y)) = xy ⋅ gcd(x, y)
Problem 628 (Middle European Mathematical Olympiad 2016). For a positive integer
2 2 2
n, the equation a + b + c + n = abc is given in the positive integers. Prove that:
Problem 629 (Netherlands TST 2016). Find all positive integers k for which the
equation:
lcm(m, n) − gcd(m, n) = k(m − n)
has no solution in integers positive (m, n) with m ≠ n.
400
§0. Practice Challenge Problems Masum Billal, Amir Hossein
to 2016 and
i + j ∣ iai + jaj
a + b = cd
c + d = ab
Problem 632 (Pan-African Mathematical Olympiad 2016). For any positive integer
n, we define the integer P (n) by
Find the greatest common divisor of the integers P (1), P (2), P (3), . . . , P (2016).
Problem 633 (Philippine Mathematical Olympiad Area Stage 2016). Let a, b, and
c be three consecutive even numbers such that a > b > c. What is the value of
2 2 2
a + b + c − ab − bc − ac?
Problem 634 (Philippine Mathematical Olympiad Area Stage 2016). Find the sum
of all the prime factors of 27,000,001.
Problem 635 (Philippine Mathematical Olympiad Area Stage 2016). Find the largest
number N so that
N
1 1
∑ <
n=5
n(n − 2) 4
Problem 636 (Philippine Mathematical Olympiad Area Stage 2016). Let sn be the
sum of the digits of a natural number n. Find the smallest value of sn if n is a four-digit
n
number.
Problem 637 (Philippine Mathematical Olympiad Area Stage 2016). The 6 digit
number 739ABC is divisible by 7, 8, and 9. What values can A, B, and C take?
Problem 638 (Polish Mathematical Olympiad 2016). Let p be a certain prime number.
Find all non-negative integers n for which polynomial P (x) = x − 2(n + p)x + (n − p)
4 2 2
401
§0. Practice Challenge Problems Masum Billal, Amir Hossein
Problem 639 (Polish Mathematical Olympiad 2016). Let k, n be odd positive integers
greater than 1. Prove that if there a exists natural number a such that k ∣ 2 + 1, n ∣
a
Problem 640 (Polish Mathematical Olympiad 2016). There are given two positive real
number a < b. Show that there exist positive integers p, q, r, s satisfying following
conditions:
p r
1. a < q
< s
< b.
2 2 2 2
2. p + q = r + s .
Problem 641 (Romania Danube Mathematical Competition 2016). Determine all pos-
itive integers n such that all positive integers less than or equal to n and prime to n
are pairwise relatively prime.
Problem 642 (Romania Danube Mathematical Competition 2016). Given an integer
n ≥ 2, determine the numbers that can be written in the form
k
∑ ai−1 ai
i=2
(b) Determine the possible values of a2015 ⋅ a2016 for a cubic sequence satisfying the
condition in part (a).
Problem 645 (Romanian Mathematical Olympiad District Round Grade 5, 2016).
Find all three-digit numbers which decrease 13 times when the tens’ digit is suppressed.
Problem 646 (Romanian Mathematical Olympiad District Round Grade 5, 2016). If
A and B are positive integers, then AB will denote the number obtained by writing,
in order, the digits of B after the digits of A. For instance, if A = 193 and B = 2016,
then AB = 1932016. Prove that there are infinitely many perfect squares of the form
AB in each of the following situations:
402
§0. Practice Challenge Problems Masum Billal, Amir Hossein
/ M.
Prove that 2015 ∈ M but 2016 ∈
where {⋅} denotes the fractional part. Prove that 4a + 1 is a perfect square.
403
§0. Practice Challenge Problems Masum Billal, Amir Hossein
Problem 661 (Romanian Mathematical Olympiad Final Round Grade 8, 2016). Let
n be a non-negative integer. We will say that the non-negative integers x1 , x2 , . . . , xn
have property (P ) if
x1 x2 ⋯xn = x1 + 2x2 + . . . + nxn
404
§0. Practice Challenge Problems Masum Billal, Amir Hossein
(a) Show that for every non-negative integer n, there exists n positive integers with
property (P ).
(b) Find all integers n ≥ 2 so that there exists n positive integers x1 , x2 , . . . , xn with
x< x2 < ⋅ ⋅ ⋅ < xn , having property (P ).
(a) Prove that 7 cannot be written as a sum of squares of three rational numbers.
(b) Let a be a rational number that can be written as a sum of squares of three rational
m
numbers. Prove that a can be written as a sum of squares of three rational
numbers, for any positive integer m.
is divisible by 625.
n = aa . . . a +5a
Í ÎÌ Ï
k times
405
§0. Practice Challenge Problems Masum Billal, Amir Hossein
(b) Let n be a given positive integer. Prove that there exists a perfect square of the
form
aab cc⋯c
Í ÎÌ Ï
2n times
x+z = 2y
{
y+t = 2z
406
§0. Practice Challenge Problems Masum Billal, Amir Hossein
Problem 675 (Romanian Stars of Mathematics Junior Level 2016). Show that there
are positive odd integers m1 < m2 < . . . and positive integers n1 < n2 < . . . such that
k 4
mk and nk are relatively prime, and mk − 2nk is a perfect square for each index k.
Problem 676 (Romanian Stars of Mathematics Junior Level 2016). Given an integer
n ≥ 3 and a permutation a1 , a2 , . . . , an of the first n positive integers, show that at least
√
n distinct residue classes modulo n occur in the list
a1 , a1 + a2 , . . . , a1 + a2 + ⋅ ⋅ ⋅ + an
Problem 677 (Romanian Stars of Mathematics Senior Level 2016). Let n be a positive
integer and let a1 , a2 , . . . , an be n positive integers. Show that
n √ n
2
ak 1
∑ <∑
1 + a1 + a2 + ⋅ ⋅ ⋅ + ak k
k=1 k=1
Problem 678 (Romania TST for Junior Balkan Mathematical Olympiad 2016). Let
M be the set of natural numbers k for which there exists a natural number n such that
n
3 ≡k (mod n)
Problem 679 (Romania TST for Junior Balkan Mathematical Olympiad 2016). Let
n be an integer greater than 2 and consider the set
n n n
A = {2 − 1, 3 − 1, . . . , (n − 1) − 1}
Given that n does not divide any element of A, prove that n is a square-free number.
Does it necessarily follow that n is a prime?
Problem 680 (Romania TST for Junior Balkan Mathematical Olympiad 2016). Let
n be a positive integer and consider the system
2 2 2
x + ny = z
S(n) ∶ { 2 2 2
nx + y = t
prove that
(a) 7 ∈ M1 and 10 ∈ M2 .
407
§0. Practice Challenge Problems Masum Billal, Amir Hossein
Problem 681 (Romania TST 2016). Let n be a positive integer and let a1 , a2 , . . . , an
be pairwise distinct positive integers. Show that
n
1
∑ <4
k=1
[a1 , a2 , . . . , ak ]
where [a1 , a2 , . . . , ak ] is the least common multiple of the integers a1 , a2 , . . . , ak .
Problem 682 (Romania TST 2016). Determine the integers k ≥ 2 for which the
sequence
2n
( n ) (mod k)
Problem 686 (Romaina TST 2016). Given a √positive integer n, show that for no set
of integers modulo n, whose size exceeds 1 + n + 4, is it possible that the pairwise
sums of unordered pairs be all distinct.
Problem 687 (Romania TST 2016). Given a prime p, prove that the sum
⌊q/p⌋
p−1
∑k
k=1
408
§0. Practice Challenge Problems Masum Billal, Amir Hossein
Problem 690 (San Diego Math Olympiad 2016). Let a, b, c, d be four integers. Prove
that
(b − a) (c − a) (d − a) (d − c) (d − b) (c − b)
is divisible by 12.
2
Problem 691 (San Diego Math Olympiad 2016). Quadratic equation x +ax+b+1 = 0
2 2
have 2 positive integer roots, for integers a, b. Show that a + b is not a prime.
Problem 692 (Saudi Arabia Pre-selection Test 2016). Let p be a given prime. For
each prime r, we define
(p − 1)(p − 1)
rp
F (r) =
(pr − 1)(pp − 1)
2. Show that F (r) and F (s) are relatively prime for any primes r and s such that
r ≠ p, s ≠ p and r ≠ s.
3. Fix a prime r ≠ p. Show that there is a prime divisor q of F (r) such that p ∣ q − 1
but p ∤ q − 1.
2
Problem 693 (Saudi Arabia Pre-selection Test 2016). Let u and v be positive rational
numbers with u ≠ v. Assume that there are infinitely many positive integers n with
n n
the property that u − v is an integer. Prove that u and v are integers.
Problem 694 (Saudi Arabia Pre-selection Test 2016). Let a and b be two positive
integers such that
2
b+1∣a +1
2
a+1∣b +1
1. Prove that there are infinitely many positive integers n such that there exists a
permutation of 1, 2, 3, . . . , n with the property that the difference between any
two adjacent numbers is equal to either 2015 or 2016.
2. Let k be a positive integer. Is the statement in part 1 still true if we replace the
numbers 2015 and 2016 by k and k + 2016, respectively?
Problem 696 (Saudi Arabia Pre-selection Test 2016). Let n be a given positive integer.
Prove that there are infinitely many pairs of positive integers (a, b) with a, b > n such
409
§0. Practice Challenge Problems Masum Billal, Amir Hossein
that
2015
∏(a + i) ∣ b(b + 2016)
i=1
2015
∏(a + i) ∤ b
i=1
2015
∏(a + i) ∤ (b + 2016)
i=1
Problem 697 (Saudi Arabia TST for Gulf Mathematical Olympiad 2016). Find all
positive integer n such that there exists a permutation (a1 , a2 , . . . , an ) of (1, 2, 3, . . . , n)
satisfying the condition:
k ∣ a1 + a2 + . . . + ak
for 1 ≤ k ≤ n.
Problem 698 (Saudi Arabia TST for Balkan Mathematical Olympiad 2016). Show
that there are infinitely many positive integers n such that n has at least two prime
n n 2
divisors and 20 + 16 is divisible by n .
Problem 699 (Saudi Arabia TST for Balkan Mathematical Olympiad 2016). Let m
and n be odd integers such that (n − 1) is divisible by m + 1 − n . Prove that
2 2 2
∣m + 1 − n ∣ is a perfect square.
2 2
Problem 700 (Saudi Arabia TST for Balkan Mathematical Olympiad 2016). Let a >
b > c > d be positive integers such that
2 2 2 2
a + ac − c = b + bd − d
Problem 701 (Saudi Arabia TST for Balkan Mathematical Olympiad 2016). For any
positive integer n, show that there exists a positive integer m such that n divides
m
2016 + m.
Problem 702 (Saudi Arabia TST for Balkan Mathematical Olympiad 2016). Let d be
a positive integer. Show that for every integer S, there exist a positive integer n and a
sequence a1 , a2 , . . . , an ∈ {−1, 1} such that
2 2 2
S = a1 (1 + d) + a2 (1 + 2d) + ⋅ ⋅ ⋅ + an (1 + nd)
Problem 703 (Saudi Arabia TST for Balkan Mathematical Olympiad 2016). Let p
and q be given primes and the sequence (pn )n≥1 defined recursively as follows: p1 = p,
p2 = q, and pn+2 is the largest prime divisor of the number (pn + pn+1 + 2016) for all
n ≥ 1. Prove that this sequence is bounded. That is, there exists a positive real number
M such that an < M for all positive integers n.
410
§0. Practice Challenge Problems Masum Billal, Amir Hossein
Problem 704 (Saudi Arabia IMO TST 2016). Let n ≥ 3 be an integer and let
x1 , x2 , . . . , xn be n distinct integers. Prove that
2 2 2
(x1 − x2 ) + (x2 − x3 ) + ⋅ ⋅ ⋅ + (xn − x1 ) ≥ 4n − 6
Problem 705 (Saudi Arabia IMO TST 2016). Let k be a positive integer. Prove that
there exist integers x and y, neither of which divisible by 7, such that
2 2 k
x + 6y = 7
Problem 706 (Saudi Arabia IMO TST 2016). Define the sequence a1 , a2 , . . . as follows:
a1 = 1, and for every n ≥ 2, an = n − 2 if an−1 = 0 and an = an−1 − 1, otherwise. Find
the number of 1 ≤ k ≤ 2016 such that there are non-negative integers r and s and a
positive integer n satisfying k = r + s and an+r = an + s.
Problem 707 (Saudi Arabia IMO TST 2016). Let a be a positive integer. Find all
prime numbers p with the following property: there exist exactly p ordered pairs of
integers (x, y), with 0 ≤ x, y ≤ p − 1, such that p divides y − x − a x.
2 3 2
Problem 708 (Saudi Arabia IMO TST 2016). Find the number of permutations
(a1 , a2 , . . . , a2016 ) of the first 2016 positive integers satisfying the following two con-
ditions:
2. There are exactly two indices i < j with 1 ≤ i < j ≤ 2016 such that ai = i and
aj = j.
Problem 709 (Saudi Arabia IMO TST 2016). Call a positive integer N ≥ 2 special if
for every k such that 2 ≤ k ≤ N , N can be expressed as a sum of k positive integers
that are relatively prime to N (although not necessarily relatively prime to each other).
Find all special positive integers.
Problem 710 (Serbia Additional TST 2016). Let w(x) be largest odd divisor of x.
Let a, b be natural numbers such that (a, b) = 1 and a + w(b + 1) and b + w(a + 1) are
powers of two. Prove that a + 1 and b + 1 are powers of two.
Problem 711 (Serbia National Olympiad 2016). Let n > 1 be an integer. Prove that
n
there exist m > n such that m n
n −m
m+n
is a positive integer.
Problem 712 (Serbia National Olympiad 2016). Let a1 , a2 , . . . , a22016 be positive inte-
2016
gers not bigger than 2016. We know that for each n ≤ 2 , a1 a2 . . . an + 1 is a perfect
square. Prove that for some i , ai = 1.
Problem 713 (Serbia TST for Junior Balkan Mathematical Olympiad 2016). Find
minimal number of divisors that can number ∣2016 − 36 ∣ have,where m and n are
m n
natural numbers.
411
§0. Practice Challenge Problems Masum Billal, Amir Hossein
abcd = 20 ⋅ ab + 16 ⋅ cd
412
§0. Practice Challenge Problems Masum Billal, Amir Hossein
Problem 723 (South Africa National Olympiad 2016). Let k and m be integers with
1 < k < m. For a positive integer i, let Li be the least common multiple of 1, 2, . . . , i.
Prove that k is a divisor of
m m−k
Li ⋅ [( i ) − ( i )]
for all i ≥ 1.
Problem 724 (Slovenia National Math Olympiad First Grade 2016). Find all relatively
prime integers x and y that solve the equation
3 3 2
4x + y = 3xy
Problem 725 (Slovenia National Math Olympiad Fourth Grade 2016). Find all inte-
gers a, b, c, and d that solve the equation
2 2 2
a + b + c = d + 13
d
a + 2b + 3c = + 13
2
Problem 726 (Slovenia IMO TST 2016). Let
15
N = 2 ⋅ 2015
2
How many divisors of N are strictly smaller than N and do not divide N ?
Problem 727 (Slovenia IMO TST 2016, Philippine 2015). Prove that for all positive
integers n ≥ 2,
√ √ √ 2
1 1 3 2 n n − 1 n
2
+
2
+
3
+ ⋅⋅⋅ + n < n+1
Problem 728 (Slovenia IMO TST 2016, Romania JBMO TST 2015). Find all positive
integers a, b, c, and d such that
a b c d
4 ⋅ 5 − 3 ⋅ 11 = 1
Problem 729 (Spain National Olympiad 2016). Two real number sequences are guiven,
one arithmetic (an )n∈N and another geometric sequence (gn )n∈N none of them constant.
Those sequences verifies a1 = g1 ≠ 0, a2 = g2 and a10 = g3 . Find with proof that, for
every positive integer p, there is a positive integer m, such that gp = am .
Problem 730 (Spain National Olympiad 2016). Given a positive prime number p.
Prove that there exist a positive integer α such that p ∣ α(α − 1) + 3, if and only if
there exist a positive integer β such that p ∣ β(β − 1) + 25.
Problem 731 (Spain National Olympiad 2016). Let m be a positive integer and a and
2 2
b be distinct positive integers strictly greater than m and strictly less than m + m.
2 2
Find all integers d such that m < d < m + m and d divides ab.
413
§0. Practice Challenge Problems Masum Billal, Amir Hossein
Problem 732 (Switzerland Preliminary Round 2016). Determine all natural numbers
n such that for all positive divisors d of n,
d+1∣n+1
Problem 733 (Switzerland Final Round 2016). Find all positive integers n for which
primes p and q exist such that
Problem 734 (Switzerland Final Round 2016). Let an be a sequence of positive inte-
gers defined by a1 = m and an = an−1 − 1 for n = 2, 3, 4, . . . . A pair (ak , al ) is called
2
interesting if
(i) 0 < l − k < 2016, and
(ii) ak divides al .
Prove that there exists a positive integer m such that the sequence an contains no
interesting pair.
Problem 735 (Switzerland TST 2016). Let n be a positive integer. We call a pair
of natural numbers incompatible if their greatest common divisor is equal to 1. Find
the minimum value of incompatible pairs when one divides the set {1, 2, . . . , 2n} into n
pairs.
n
7
Problem 736 (Switzerland TST 2016). Let n be a positive integer. Show that 7 + 1
has at least 2n + 3 prime divisors (not necessarily distinct).
Problem 737 (Switzerland TST 2016). Find all positive integers n such that
2
∑ d = 5(n + 1)
d∣n
1≤d≤n
Problem 738 (Syria Central Round First Stage 2016). A positive integer n ≥ 2 is called
2
special if n can be written as sum of n consecutive positive integers (for instance, 3 is
2
special since 3 = 2 + 3 + 4).
(i) Prove that 2016 is not special.
(ii) Prove that the product of two special numbers is also special.
Problem 739 (Syria Central Round Second Stage 2016). Find all integers a and b
3 2
such that a − b = 2.
Problem 740 (Syria TST 2016). Find all positive integers m and n such that
1 1 3
+ =
m n 2014
Problem 741 (Taiwan TST First Round 2016). Find all ordered pairs (a, b) of positive
integers that satisfy a > b and the equation (a − b) = a b .
ab b a
414
§0. Practice Challenge Problems Masum Billal, Amir Hossein
Problem 742 (Taiwan TST Second Round 2016). Let a and b be positive integers
such that a! + b! divides a!b!. Prove that 3a ≥ 2b + 2.
Problem 743 (Taiwan TST Second Round 2016). Let ⟨Fn ⟩ be the Fibonacci sequence,
that is, F0 = 0, F1 = 1, and Fn+2 = Fn+1 + Fn holds for all non-negative integers n.
Find all pairs (a, b) of positive integers with a < b such that Fn − 2na is divisible by b
n
Problem 744 (Taiwan TST Third Round 2016). Let n be a positive integer. Find the
number of odd coefficients of the polynomial (x − x + 1) .
2 n
Problem 745 (Taiwan TST Third Round 2016). Let k be a positive integer. A se-
quence a0 , a1 , . . . , an (n > 0) of positive integers satisfies the following conditions:
(i) a0 = an = 1;
(iii) For each j = 2, 3, . . . , k, the number j appears φ(j) times in the sequence a0 , a1 , . . . , an
(φ(j) is the number of positive integers that do not exceed j and are relatively
prime to j);
bi+1 bi
>
ai+1 ai
for all i = 0, 1, . . . , n − 1. Find the minimum value for bn − b0 .
Problem 746 (Taiwan TST Third Round 2016). Let f (x) be the polynomial with
integer coefficients (f (x) is not constant) such that
3 2 3 2
(x + 4x + 4x + 3)f (x) = (x − 2x + 2x − 1)f (x + 1)
Prove that for each positive integer n ≥ 8, f (n) has at least five distinct prime divisors.
Problem 747 (Turkey TST for European Girls’ Mathematical Olympiad 2016). Prove
that for every square-free integer n > 1, there exists a prime number p and an integer
m satisfying p ∣ n and n ∣ p + p ⋅ m .
2 p
Problem 748 (Turkey TST for Junior Balkan Mathematical Olympiad 2016). Let n
be a positive integer, p and q be prime numbers such that
p
pq ∣ n + 2
p p
n+2∣n +q
415
§0. Practice Challenge Problems Masum Billal, Amir Hossein
Problem 749 (Turkey TST for Junior Balkan Mathematical Olympiad 2016). Find
all pairs (p, q) of prime numbers satisfying
3 9 2
p + 7q = q + 5p + 18p
Problem 750 (Turkey TST 2016). p is a prime. Let Kp be the set of all polynomials
with coefficients from the set {0, 1, . . . , p − 1} and degree less than p. Assume that for
all pairs of polynomials P, Q ∈ Kp such that P (Q(n)) ≡ n (mod p) for all integers n,
the degrees of P and Q are equal. Determine all primes p with this condition.
Problem 751 (Turkmenistan Regional Olympiad 2016). Find all distinct prime num-
bers p, q, r, s such that
1 1 1 1 1
1 − p − q − r − s = pqrs
Problem 752 (Tuymaada Senior League 2016). For each positive integer k determine
the number of solutions of the equation
k 3 3 3
8 = x + y + z − 3xyz
416
§0. Practice Challenge Problems Masum Billal, Amir Hossein
Problem 760 (USA AIME 2016). For a permutation p = (a1 , a2 , . . . , a9 ) of the digits
1, 2, . . . , 9, let s(p) denote the sum of the three 3-digit numbers a1 a2 a3 , a4 a5 a6 , and
a7 a8 a9 . Let m be the minimum value of s(p) subject to the condition that the units
digit of s(p) is 0. Let n denote the number of permutations p with s(p) = m. Find
∣m − n∣.
Problem 761 (USA AIME 2016). A strictly increasing sequence of positive inte-
gers a1 , a2 , a3 , . . . has the property that for every positive integer k, the subsequence
a2k−1 , a2k , a2k+1 is geometric and the subsequence a2k , a2k+1 , a2k+2 is arithmetic. Suppose
that a13 = 2016. Find a1 .
2
Problem 762 (USA AIME 2016). Find the least positive integer m such that m −
m + 11 is a product of at least four not necessarily distinct primes.
Problem 763 (USA AIME 2016). Let x, y and z be real numbers satisfying the system
3 5 7 9
Q(x) = P (x)P (x )P (x )P (x )P (x )
50
i
= ∑ ai x
i=0
Then,
50
m
∑ ∣ai ∣ = n
i=0
Problem 765 (USA AIME 2016). Find the number of sets {a, b, c} of three distinct
positive integers with the property that the product of a, b, and c is equal to the product
of 11, 21, 31, 41, 51, and 61.
Problem 766 (USA AIME 2016). The sequences of positive integers 1, a2 , a3 , . . . and
1, b2 , b3 , . . . are an increasing arithmetic sequence and an increasing geometric sequence,
respectively. Let cn = an + bn . There is an integer k such that ck−1 = 100 and ck+1 =
1000. Find ck .
Problem 767 (USA AIME 2016). For positive integers N and k, define N to be k-nice
k
if there exists a positive integer a such that a has exactly N positive divisors. Find
the number of positive integers less than 1000 that are neither 7-nice nor 8-nice.
417
§0. Practice Challenge Problems Masum Billal, Amir Hossein
6
Problem 768 (USAJMO 2016). Prove that there exists a positive integer n < 10 such
n
that 5 has six consecutive zeros in its decimal representation.
Problem 769 (USAMO 2016). Prove that for any positive integer k,
k−1
2 j!
(k )! ⋅ ∏
j=0
(j + k)!
is an integer.
Problem 770 (USAMO 2016).
s 2
(a) Prove that if n is an odd perfect number then n has the following form n = p m
+
where p is prime has form 4k + 1, s is positive integers has form 4h + 1, and m ∈ Z ,
m is not divisible by p.
+ n(n+1)
(b) Find all n ∈ Z , n > 1 such that n − 1 and 2
is perfect number.
Problem 771 (USA TSTST 2016). Decide whether or not there exists a nonconstant
polynomial Q(x) with integer coefficients with the following property: for every positive
integer n > 2, the numbers
Q(0), Q(1), Q(2), . . . , Q(n − 1)
produce at most 0.499n distinct residues when taken modulo n.
Problem 772 (USA TSTST 2016). Suppose that n and k are positive integers such
that
1 = φ(φ(. . . φ( n) . . . ))
Í ÎÌ Ï
k times
k
Prove that n ≤ 3 .
√
Problem 773 (USA TST 2016). Let 3 = 1.b1 b2 b3 . . .(2) be the binary representation
√
of 3. Prove that for any positive integer n, at least one of the digits bn , bn+1 , . . . , b2n
equals 1.
Problem 774 (Venezuela Final Round Fourth Year 2106). Find all pairs of prime
numbers (p, q), with p < q, such that the numbers p + 2q, 2p + q and p + q − 22 are also
primes.
Problem 775 (Zhautykov Olympiad 2016). a1 , a2 , ..., a100 are permutation of 1, 2, ..., 100.
S1 = a1 , S2 = a1 + a2 , ..., S100 = a1 + a2 + ... + a100 Find the maximum number of perfect
squares from Si .
Problem 776 (Zhautykov Olympiad 2016). We call a positive integer q a convenient
denominator for a real number α if
∣ ∣
p 1
α− q <
10q
for some integer p. Prove that if two irrational numbers α and β have the same set of
convenient denominators then either α + β or α − β is an integer. This PDF was created
for Amazon.
418
GLOSSARY
n
n n−i i
= ∑ ( i )a b
i=0
n
n i n−i
= ∑ ( i )a b
i=0
23, 59