Notes and Problems in Number Theory Volu
Notes and Problems in Number Theory Volu
in Number Theory
Volume II
p
p6 | a lcm (p − 1)! + 1 = 0
(k) k
φ φ
pkak
nn m = 1
n
m = p a1 p a2 · · ·
p−1 p
=
2
τ (n) =
a 1
1
∏ik=1 (a c
i + 1) =
b y
gc d σ ax
+
µ
(dn . . . d2 d1 d0 )b
Taha Sochi
Preface
This is the second volume of my book “Notes and Problems in Number Theory”. It is important to note
the following points (which are largely about this volume):
• We take all the results and materials in the previous volume of this book for granted. Therefore, the
reader should consult the previous volume when necessary. For this purpose (and to help the reader) we
refer frequently to the previous volume.
• We focus in this volume on the type of problems that develop the basic and most essential skills which
are required for dealing with number theory problems.
• We introduced some new topics in the first chapter (i.e. Introduction), while the remaining chapters
are largely dedicated to solved problems from the main topics of elementary number theory (which are
introduced in V1 or in the Introduction chapter of the present volume). We also introduced the subject
of cryptography and computing in number theory in the last two chapters. So in brief, the materials in
this volume are largely a mix of applications to the materials of V1 and some theoretical background of
new topics as well as applications to the new topics. This is to ensure the continuity and graduality and
reduce the gradient of the learning curve.
• For the sake of originality, we deliberately reduced the amount of solved problems which have been
previously investigated by others (especially the widely circulating problems) to the bare minimum. In
fact, even when we investigate problems of this type we mostly follow novel or improved approach or/and
presentation.
• As in my previous books, my topmost priority in the structure and presentation is clarity and graduality
so that the readers have the best chance of understanding the content with minimum effort and with
maximum enjoyment. For this purpose (as well as for other obvious purposes) the book is full of cross
references (which are hyperlinked in the electronic versions although the hyperlinks are not highlighted
with color or other marking techniques to avoid distortion and ugliness). As indicated earlier, we also
refer frequently to the previous volume.
• The readers who want to benefit maximally from this book should try solving the Problems in this book
before reading their solutions. They should resist the temptation to read the solutions immediately or
just after a few attempts. Mathematical knowledge and skill cannot be acquired by just reading without
practice.
• As indicated, the last chapter of the present volume is dedicated to computing in number theory and
hence computer codes (in C++ language) represent the main part of the solutions of the Problems of the
last chapter. These codes are available from my webpage on ResearchGate. We recommend inspecting
these codes carefully and trying to figure out the algorithms behind them. These codes (as well as the
algorithms behind them) are mostly very simple and hence they do not require specialized knowledge
in computing or in C++. However, they can be very useful in acquiring the essential knowledge and
developing the basic skills in dealing with essential topics in number theory by computational methods
and tools.
• The book can be used as a text or as a reference for an introductory course on number theory and
may also be used for general reading in mathematics (especially by those who have the hobby of problem
solving). The book may also be adopted as a source of pedagogical materials which can supplement, for
instance, tutorial sessions (e.g. in undergraduate courses on mathematics or computing or cryptography
or related subjects).
Taha Sochi
London, May 2024
1
Contents
Preface 1
Table of Contents 2
Nomenclature 4
1 Introduction 6
1.1 Continued Fractions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
1.2 Pell’s Equation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
1.3 The Order of Integer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
1.4 Primitive Root . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
1.5 The Index of Integer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
1.6 Quadratic Residue . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
1.7 The Quadratic Congruence Theorem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
1.8 Legendre’s Symbol . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
1.9 Euler’s Criterion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
1.10 Quadratic Reciprocity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
1.11 Jacobi’s Symbol . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
1.12 Mobius Inversion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
2 Miscellaneous 39
4 Representation of Numbers 50
5 Diophantine Equations 55
5.1 General Issues about Diophantine Equations . . . . . . . . . . . . . . . . . . . . . . . . . . 55
5.2 Polynomial Diophantine Equations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
5.3 Exponential Diophantine Equations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
5.4 Mixed Polynomial-Exponential Diophantine Equations . . . . . . . . . . . . . . . . . . . . 73
5.5 Diophantine Equations Involving Roots . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
5.6 Diophantine Equations Involving Fractions . . . . . . . . . . . . . . . . . . . . . . . . . . 78
5.7 Diophantine Equations Involving Roots and Fractions . . . . . . . . . . . . . . . . . . . . 81
5.8 Diophantine Equations Involving Factorials . . . . . . . . . . . . . . . . . . . . . . . . . . 82
5.9 Trigonometric Diophantine Equations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84
6 Diophantine Systems 85
6.1 General Issues about Diophantine Systems . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
6.2 Systems of Diophantine Equations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
6.3 Solving Systems of Diophantine Equations Graphically . . . . . . . . . . . . . . . . . . . . 91
6.4 Final Thought about how to Solve Diophantine Problems . . . . . . . . . . . . . . . . . . 93
7 Inequalities 96
7.1 General Issues about Inequalities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96
7.2 Univariate Inequalities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
7.3 Multivariate Inequalities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
2
8 Congruence Equations 101
8.1 General Issues about Congruence Equations . . . . . . . . . . . . . . . . . . . . . . . . . . 101
8.2 Univariate Congruence Equations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104
8.3 Multivariate Congruence Equations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109
15 Divisibility 149
17 Cryptography 167
Index 174
3
Nomenclature
In the following list, we define the common symbols, notations and abbreviations which are used in the
book as a quick reference for the reader.
∀ for all
×, · multiplication sign
{· · · } set
! factorial
∈ in (or belong to)
∋ (backward) in (or belong to)
∈
/ not in
[A; B] continued fraction symbol
⌊a⌋ floor function (the greatest integer less than or equal to a)
⌈a⌉ ceiling function (the smallest integer greater than or equal to a)
|a| absolute value of a
a negation of a
C the set of complex numbers
n
Cm binomial coefficient (number of combinations of m in n with no repetition)
Cnn1 ,n2 ,...,nk multinomial coefficient
E the set of even numbers
Eq., Eqs. Equation, Equations
Fk Fermat number (i.e. k th Fermat number where k = 0, 1, . . .)
gcd(m, n) greatest common divisor of m and n
iff if and only if
Ik,r n index of integer n relative to primitive root r (modulo k)
lcm(m, n) least common multiple of m and n
LHS, RHS left hand side, right hand side
m|n m divides n
m6 | n m does not divide n
m↑n tetration of m to n
(m)n the number m in base n
k
m=n m and n are congruent modulo k
k
m 6= n m and n are not congruent modulo k
m, n, k, . . . integers
m∗ modular multiplicative inverse of m
m∗k modular multiplicative inverse of m modulo k
max(a, b) the maximum of a and b
min(a, b) the minimum of a and b
mod modulo (or modulus)
Mp Mersenne prime
b
n factorial power of n
N the set of natural numbers (i.e. 1, 2, 3, . . .)
N0 the set of non-negative integers (i.e. 0, 1, 2, 3, . . .)
n
Jacobi’s symbol
N
n
p Legendre’s symbol
4
O the set of odd numbers
Ok n the order of integer n (modulo k)
p prime number
P the set of prime numbers
Pe even perfect number
n
Pm number of permutations of m in n (with no repetition)
Q the set of rational numbers
r, r1 , r2 , r3 position vectors (in 3D space)
R the set of real numbers
s(n) the restricted divisor function
Sc complete residue system
Sr reduced residue system
Srk reduced residue system modulo k
Un the n-digit repunit number
V1 volume 1 (of this book)
x, y, z variables (mostly integers)
Z the set of integers
∆ discriminant of quadratic polynomial
µ(n) the Mobius function
Π the product symbol (for repeated multiplication)
σ(n) the divisor function
Σ the summation symbol
τ (n) the tau function
φ(n) the totient (or phi or Euler) function
5
Chapter 1
Introduction
In this chapter we briefly investigate some new topics in number theory which we did not investigate (at
least sufficiently) in V1 and which are needed for our future investigations (in this and upcoming volumes).
1
As we see, this pattern of 1 + will repeat itself for ever and hence we can symbolize this
1
2+
.
2 + ..
succinctly as: √
2 = 1; 2
where 1 represents the integer part while 2 represents the fractional part (noting that the bar indicates
that 2 is repeated infinitely).
6
1.1 Continued Fractions 7
√Regarding the use of continued fraction to approximate the number that is expressed in this form (i.e.
2 in this case), we can say that we can truncate the ladder of continued fraction at any step on the ladder
.
by ignoring the last fraction (i.e. . . ) at that step and hence we get a rational
√ fraction approximation to
the given number as illustrated in the following (using our example of 2):
√ 1 3
2≃1+= = 1.5
2 2
√ 1 2 7
2≃1+ = 1 + = = 1.4
1 5 5
2+
2
√ 1 1 5 17
2≃1+ =1+ =1+ = ≃ 1.42
1 2 + 52 12 12
2+
1
2+
2
It is obvious that we get better and better approximations as we go further down on this fraction
√ ladder
(as can be seen in the above example where we get persistently better approximations to 2 as we go
further down on the ladder). In other words, the successive rational fractions obtained from successive
stepping down on this ladder converge persistently towards the given number.
Finally, it is useful to take notice of the following remarks:
• Rational numbers are represented by finite (or terminating) continued fraction ladder, while irrational
numbers require infinitely long (or infinitely deep or non-terminating) continued fraction ladder.
• As indicated above, the continued fraction expression is symbolized by [A; B] where A is the integer
part (which is a single integer) while B is the (continued) fraction part which can be a single integer (e.g.
1.2 = [1; 5]) or a number of integers separated by commas (e.g. 1.23 = [1; 4, 2, 1, 7]) where these integers
are the successive integer parts in the ladder. Now, we have 3 main cases with regard to the fraction part
B:
Case 1: the given number is rational and hence B is a single integer like 1.2 = [1; 5] or B is a block of
finitely-many integers like 1.23 = [1; 4, 2, 1, 7].
Case 2: the given number is irrational and B is a single integer or a block of integers which
√ is repeated
cyclically. In this case we put a bar on the top of B to indicate this cyclic behavior, e.g. 2 = 1; 2 and
√
3 = 1; 1, 2 .
Case 3: the given number is irrational and B is a block of integers with no cyclic pattern (within the
number of acquired steps or for ever). In this case the block of integers is trailed with an ellipsis (i.e.
three dots . . .), e.g. π = [3; 7, 15, 1, 292, . . .].
Problems
√
1. Obtain the continued fraction of 2 using this time the technique of substitution.
Solution: In the technique of substitution we obtain the fraction ladder by recursive substitution of the
first step in the ladder for each occurrence of the given number in this ladder (as will be demonstrated
in the following), that is:
√ √ 2−1 1
2=1+ 2−1=1+ √ =1+ √
2+1 1+ 2
√ 1
So, the first step of the ladder is 2 = 1 + √ . What we do next is to substitute this expression of
1+ 2
√ 1 √
2 i.e. 1 + √ recursively for each occurrence of 2 in each successive step in the ladder, that
1+ 2
1.1 Continued Fractions 8
is:
√ 1 1 1
2=1+ √ = 1 + !=1+
1+ 2 1 1
1+ 1+ √ 2+ √
1+ 2 1+ 2
√ 1 1 1
2=1+ =1+ =1+
1 1 1
2+ √ 2+ ! 2+
1+ 2 1 1
1+ 1+ √ 2+ √
1+ 2 1+ 2
1 √
As we see, this pattern of 1 + will repeat itself for ever (as seen previously) because 2=
1
2+
.
2 + ..
1 1
1+ √ (as seen above) and hence when we substitute the expression 1 + √ recursively for the
1+ 2 1+ 2
√ .
2 in the denominator we must always get 2 + . . .
2. Obtain the continued fraction form of the following numbers and hence get a number of successive
rational fraction approximations from these forms:
√ √
(a) 1.2. (b) 1.23. (c) 5. (d) 3. (e) π.
Solution:
(a) We have 1.2 = 6/5 and hence:
6 1
=1+
5 5
Hence, 1.2 = [1; 5]. The first “approximation” is 6/5 which is exact.
(b) We have 1.23 = 123/100 and hence:
123 23 1 1 1 1 1
= 1+ =1+ =1+ =1+ =1+ =1+
100 100 100 8 1 1 1
4+ 4+ 4+ 4+
23 23 23 7 1
2+ 2+
8 8 8
7
1 1 1 1
= 1+ =1+ =1+ =1+
1 1 1 1
4+ 4+ 4+ 4+
1 1 1 1
2+ 2+ 2+ 2+
1 1 1 1
1+ 1+ 1+ 1+
7 7 7+0 7
1
As we see, the fraction part of 7/1 is zero and hence this ladder is terminating (as expected since 1.23
is rational). Thus, 1.23 = [1; 4, 2, 1, 7]. The first 3 rational fraction approximations are:
1 1 1
1+ = 1.25 1+ ≃ 1.222 1+ ≃ 1.231
4 1 1
4+ 4+
2 1
2+
1
As we see, these approximations persistently converge towards 1.23.
1.1 Continued Fractions 9
(c) We have:
√ √ 1 1 1 1
5 = 2+ 5−2=2+ =2+ √ =2+ √ =2+
1 5+2 4+ 5−2 1
√ 4+
5−2 1
√
5−2
1 1 1
= 2+ =2+ =2+
1 1 1
4+ √ 4+ √ 4+
5+2 4+ 5−2 .
4 + ..
√
As we see, this pattern of repetitive (or periodic) 4 should continue for ever. Hence, 5 = 2; 4 . The
first 3 rational fraction approximations are:
1 1 1
2+ = 2.25 2+ ≃ 2.235 2+ ≃ 2.236
4 1 1
4+ 4+
4 1
4+
4
√
As we see, these approximations persistently converge towards 5 ≃ 2.2361.
(d) We have:
√ √ 1 1 1 1
3 = 1+ 3−1=1+ =1+ √ √
=1+ =1+ √
1 3+1 2+ 3−1 3−1
√ 1+
3−1 2 2 2
1 1 1 1
= 1+ =1+ =1+ =1+
1 1 1 1
1+ 1+ √ 1+ √ 1+ √
2 2( 3 + 1) 3+1 2+ 3−1
√
3−1 2
1
= 1+
1
1+
1
2+
1
√
3−1
√
This pattern of repeated (1, 2) should continue for ever. Hence, 3 = 1; 1, 2 . The first 3 rational
fraction approximations are:
1 1 1
1+ =2 1+ ≃ 1.667 1+ = 1.75
1 1 1
1+ 1+
2 1
2+
1
√
As we see, these approximations persistently converge towards 3 ≃ 1.7321.
(e) We have:
1 1 1 1
π = 3+π−3=3+ =3+ =3+ =3+
1 1 7.062513 . . . 7 + 0.062513 ...
π−3 0.141592 . . .
1.2 Pell’s Equation 10
1 1 1
= 3+ =3+ =3+
1 1 1
7+ 7+ 7+
1 15.996594 . . . 15 + 0.996594 ...
0.062513 . . .
1 1 1
= 3+ =3+ =3+
1 1 1
7+ 7+ 7+
1 1 1
15 + 15 + 15 +
1 1.003417231 1 + 0.003417231
0.996594 . . .
1 1
= 3+ =3+
1 1
7+ 7+
1 1
15 + 15 +
1 1
1+ 1+
1 .
292 + . .
0.003417231
Hence, π = [3; 7, 15, 1, 292, . . .]. The first 3 rational fraction approximations are:
1 1 1
3+ ≃ 3.142857143 3+ ≃ 3.141509434 3+ ≃ 3.14159292
7 1 1
7+ 7+
15 1
15 +
1
As we see, these approximations persistently converge towards π ≃ 3.141592654.
x2 − dy 2 = 1 (1)
where x and y are non-zero integers (also see footnote [3] ) and d is a positive non-square integer (noting
that if d is a square integer then the equation has no solution because the difference between two non-zero
squares cannot be 1). Pell’s equation has infinitely many solutions. The method for finding these solutions
is to find the fundamental solution (which is the minimal solution in N), i.e. x = x1 and y = y1 where
x1 is the least natural number that solves (with the corresponding y, i.e. y1 ) this equation.[2] All natural
solutions are then generated by the formula:
√ √ n
x n + y n d = x 1 + y1 d (n ∈ N) (2)
All other solutions are then obtained by sign alteration noting that x and y are squared and hence each
one can be negative as well as positive (i.e. we have 4 solutions for each natural solution).
It is important to note the following about Pell’s equation:
• The existence of solution[3] of Pell’s equation is guaranteed.
[1] This section is no more than an introduction to the subject of Pell’s equation and the methods of its solution. This subject
will be extended and elaborated gradually. √
[2] The fundamental solution (x , y ) may also be defined as the solution that minimizes x + y
1 1 1 1 d in comparison to any
other solution. It is noteworthy that the fundamental solution is unique (and hence there should be no difference).
[3] We mean by “solution” the “non-trivial” solution noting that the “trivial” solution (x, y) = (1, 0) always exists. This should
explain why we imposed the condition that x and y are non-zero integers (i.e. to make this statement substantial and
extra informative).
1.2 Pell’s Equation 11
• Based on what we said, obtaining a solution to Pell’s equation is essentially about (searching for and)
finding the fundamental solution (noting that all the rest is usually trivial). So, how to obtain the
fundamental solution? In simple cases we may find the fundamental solution by guess or by inspection,
e.g. by searching by computer for the lowest (combination of) x and y in N that solve the given Pell
equation. However, in more general circumstances (and more complicated cases) we may need a more
regular and systematic technical approach for this search. The commonly-used such approach is the one
based on the technique of continued fraction (noting that this approach √ generally works; see § 1.1). The
essence of this method is to use the continued fraction expansion of d where we try successive rational
fraction approximations on the continued fraction ladder until we find a solution to the given equation,
[4]
i.e. the first found solution in this successive stepping down on the ladder is the fundamental solution. √
th
This is based on the fact that if√ak /bk (k = 1, 2, . . .) is the k rational fraction approximation of d on
the continued fraction ladder of d then x1 = ak and y1 = bk for some k (i.e. the smallest k that satisfies
a2k − db2k = 1). So, to find (x1 , y1 ) we simply try a1 /b1 , a2 /b2 , . . . successively until we find the ak /bk
that solves the given Pell equation (and hence x1 = ak and y1 = bk ). This issue will be clarified further
(practically) in the following Problems.
• Pell’s equation is generalized to the form x2 − dy 2 = c where 0 6= 1 6= c ∈ Z.[5] However, we will not
investigate this issue in this volume (although we plan to investigate this, as well as other details about
Pell’s equation, more thoroughly in the future).
• General quadratic Diophantine equation in two variables may be transformed to Pell’s equation form
to be solved as a Pell equation (where the solution of the original equation is obtained by reversing
the transformation). Some examples of this transformation technique will be given in the following
Problems (as well as in the upcoming chapters; see for instance Problem 2 of § 5.2). However, it should be
noticed that the existence of solution to the transformed Pell equation does not guarantee the existence of
solution to the original equation (as will be seen in some of the upcoming Problems) because the reverse
transformation may not produce integer solutions (totally or partially).
• Considering what we have said, although Pell’s equation may seem very restrictive, it is possible (in
many cases of quadratic Diophantine equation in two variables) to transform the equation to a standard
Pell equation (by using algebraic manipulation and scaling) and hence solve it by the Pell’s equation
techniques (as will be shown in the future). Anyway, if it is not possible to transform it to a standard
Pell equation then it is usually possible to transform it to a generalized Pell equation and hence it may
become possible to solve it as a generalized Pell equation.[6]
• When tackling a Pell equation it is recommended to search for the fundamental solution by inspection
before trying sophisticated processes and techniques like continued fraction technique. For example,
a few-seconds inspection to the Pell equation x2 − 5y 2 = 1 should lead to the fundamental solution
(x1 , y1 ) = (9, 4) and hence to all other solutions using the aforementioned formulations and instructions.
Also, basic computational effort (e.g. through the use of a spreadsheet or a simple code) can be more
economic in the search for the fundamental solution.[7]
Problems
1. Put the following equations in a standard Pell equation form and determine if these equations have
solutions or not:
(a) 4x2 − 6y 2 + 12x + 108y − 478 = 0. (b) 9x2 − 325y 2 − 42x − 130y + 35 = 0.
Solution:
(a) We have:
[4] In fact, there are detailed rules about how to get the fundamental solution (and the other solutions). However, we do not
want to get involved in these details at this stage and level.
[5] We should note that whether 0 6= 1 6= c ∈ Z or N ∋ c > 1 seems to follow different conventions (noting that this may
(i.e. when the reverse transformation does not produce an integer solution).
[7] See the Pell.cpp code which is in the “Codes” directory (noting that this code is very simple and limited in applicability
(4x2 + 12x) − (6y 2 − 108y) − 478 = 0 → (4x2 + 12x + 9) − (6y 2 − 108y) − 478 − 9 = 0 →
2 2 2 2
(2x + 3) − (6y − 108y) − 487 = 0 → (2x + 3) − (6y − 108y + 486) − 1 = 0 →
(2x + 3)2 − 6(y 2 − 18y + 81) − 1 = 0 → (2x + 3)2 − 6(y − 9)2 = 1
As we see, the last equation is in a standard Pell equation form, i.e. X 2 − 6Y 2 = 1 where X = 2x + 3
and Y = y − 9. Now, if we solve this Pell equation we can easily obtain the fundamental solution
(X, Y ) = (5, 2) as well as all other solutions such as (X, Y ) = (±5, ±2) (±49, ±20) and (±485, ±198).
We can also see that the reverse transformation i.e. x = (X − 3)/2 and y = (Y + 9) produces integer
solutions to the original equation, e.g. (x, y) = (1, 11), (1, 7), (−4, 7), (−4, 11), (23, 29), (241, 207), etc.
(b) We have:
(9x2 − 42x) − (325y 2 + 130y) + 35 = 0 → (9x2 − 42x + 49) − (325y 2 + 130y) + 35 − 49 = 0 →
(3x − 7)2 − (325y 2 + 130y) − 14 = 0 → (3x − 7)2 − (325y 2 + 130y + 13) − 1 = 0 →
2 2 2 2
(3x − 7) − 13(25y + 10y + 1) = 1 → (3x − 7) − 13(5y + 1) = 1
As we see, the last equation is in a standard Pell equation form, i.e. X 2 − 13Y 2 = 1 where X = 3x − 7
and Y = 5y + 1. Now, if we solve this Pell equation we can easily obtain the fundamental solution
(X, Y ) = (649, 180) as well as all other solutions (asdescribed above). However, the original equation
has no solution because the reverse transformation i.e. x = (X + 7)/3 and y = (Y − 1)/5 does not
produce integer solutions.
2. Find the first 4 natural solutions of the following Pell equations:
(a) x2 − 2y 2 = 1. (b) x2 − 3y 2 = 1. (c) x2 − 17y 2 = 1. (d) x2 − 7y 2 = 1.
Solution:
(a) By inspection we can see that the fundamental solution is: (x1 , y1 ) = (3, 2). Hence, the first 4
natural solutions are (see Eq. 2):
(x1 , y1 ) = (3, 2) (x2 , y2 ) = (17, 12) (x3 , y3 ) = (99, 70) (x4 , y4 ) = (577, 408)
(b) By inspection we can see that the fundamental solution is: (x1 , y1 ) = (2, 1). Hence, the first 4 nat-
ural solutions are:
(x1 , y1 ) = (2, 1) (x2 , y2 ) = (7, 4) (x3 , y3 ) = (26, 15) (x4 , y4 ) = (97, 56)
√
(c) We have 17 = 4; 8 . The first rational fraction approximation on the continued fraction ladder
√
of 17 is:
1 33
4+ =
8 8
Now, 332 − 17 × 82 = 1 and thus (x1 , y1 ) = (33, 8). Hence, the first 4 natural solutions are:
(x1 , y1 ) = (33, 8) (x2 , y2 ) = (2177, 528) (x3 , y3 ) = (143649, 34840) (x4 , y4 ) = (9478657, 2298912)
√
(d) We have 7 = 2; 1, 1, 1, 4 . The first 4 rational fraction approximations on the continued fraction
√
ladder of 7 are:[8]
3 5 8 37
[2; 1] = [2; 1, 1] = [2; 1, 1, 1] = [2; 1, 1, 1, 4] =
1 2 3 14
The first approximation that satisfies the given equation is the third (since 82 − 7 × 32 = 1) and thus
(x1 , y1 ) = (8, 3). Hence, the first 4 natural solutions are:
(x1 , y1 ) = (8, 3) (x2 , y2 ) = (127, 48) (x3 , y3 ) = (2024, 765) (x4 , y4 ) = (32257, 12192)
2
3. Show that there are infinitely many triangular numbers (i.e. numbers of the form n 2+n where n ∈ N)
which are perfect squares.
2
Solution: For a triangular number to be a perfect square we must have n 2+n = m2 where m ∈ N), i.e.
√
use [2; 1] to represent 2 + 11 (i.e. the first rational fraction approximation on the continued fraction ladder of
[8] We 7).
The similar symbols (such as [2; 1, 1]) have similar interpretation.
1.3 The Order of Integer 13
n2 + n − 2m2 = 0. This is a quadratic equation in n and hence it has a solution if its discriminant ∆
is a perfect square, i.e.
∆ = 12 − 4(−2m2 ) = k 2 → k 2 − 8m2 = 1 (k ∈ N)
As we see, the latter equation is a Pell equation and hence it has infinitely many solutions, e.g. (k, m) =
(3, 1), (17, 6), (99, 35), (577, 204) corresponding to n = 1, 8, 49, 288 (and hence to triangular square
numbers 1, 36, 1225, 41616). Accordingly, there are infinitely many triangular numbers which are
perfect squares.
k
Regarding the only if part, if nb = 1 where Ok n6 | b then b = aOk n + r where a ∈ N0 and 0 < r < Ok n.
Therefore, we must have:
k a k
1 = nb = naOk n+r = nOk n × nr = 1a × nr = nr
k
i.e. nr = 1 which is a contradiction because 0 < r < Ok n while Ok n is supposed to be the least positive
k
integer such that nOk n = 1.
k Ok n
2. Show that na = nb iff a = b (where n and k are coprime and a, b ∈ N0 ).
Solution: Let us assume (with no loss of generality) that a ≥ b.
O n
k
Regarding the if part, if a = b then a = sOk n + b (for some s ∈ N0 ) and hence:
s k
na = nsOk n+b = nOk n × nb = 1s × nb = nb
k
Regarding the only if part, if na = nb then we have:
k k k
na = nb → na−b nb = nb → na−b = 1
where canceling nb in the last step is because nb and k are coprime since n and k are coprime (see part
n of Problem 1 of 2.2 of V1, as well as point 7 in the preamble of § 2.7 of V1). Now, from Problem 1
k O n
we conclude that Ok n|(a − b), i.e. a = b.
[9] The“order of an integer” is actually the multiplicative order (which should remind those with knowledge of group theory
of the order in the multiplicative group). However, for simplicity (and because we have no rival or competitor so far on
this terminology) we label this as the “order of an integer”.
1.3 The Order of Integer 14
where step 4 is because a = Ok n. So, from Problem 1 we have Ok nb |α, i.e. c|α.
c k
Also, from the definition of Ok nb we have: nb = nbc = 1 and hence from Problem 1 we have a|(bc),
i.e. (gα)|(gβc) or α|(βc). Now, since α and β are coprime then α|c.
So, c|α and α|c and hence c = α (noting that c and α are positive), that is:
a
O k nb ≡ c = α =
g
Note: based on this proposition we have:
O11 5 5 5 O7 9 3 3
O11 57 = = = =5 O7 96 = = = =1
gcd (O11 5, 7) gcd (5, 7) 1 gcd (O7 9, 6) gcd (3, 6) 3
9. Show that Ok n = Ok n∗ where n∗ is the modular multiplicative inverse of n modulo k (assuming n has
a modular inverse).
Solution: If ρ ≡ Ok n then we have:
k k
1 = 1ρ = (nn∗ )ρ = nρ (n∗ )ρ = 1 × (n∗ )ρ = (n∗ )ρ
Hence, from Problem 1 we get Ok n∗ |ρ and hence Ok n∗ ≤ ρ, i.e. Ok n∗ ≤ Ok n. Now, noting that
modular multiplicative inversion is a symmetric relation (see point 5 in the preamble of § 2.7.1 of V1)
we must also have Ok n ≤ Ok n∗ . Hence, Ok n = Ok n∗ .
10. Let n1 , n2 be integers which are coprime to k ∈ N. Show that Ok (n1 n2 ) (Ok n1 × Ok n2 ). Moreover, if
Ok n1 and Ok n2 are relatively prime then Ok (n1 n2 ) = Ok n1 × Ok n2 .
Solution: Let a ≡ Ok n1 , b ≡ Ok n2 and c ≡ Ok (n1 n2 ). Now:
b a k
(n1 n2 )ab = nab ab a
1 n2 = (n1 ) nb2 = 1b 1a = 1
Hence, from Problem 1 we get b|(ac) and thus b|c (noting that we are assuming now that a and b are
relatively prime).
We can similarly show that a|c (noting that this can also be deduced from the symmetry).
Now, since a|c and b|c then (ab)|c because a and b are relatively prime (see point 20 in the preamble of
§ 1.9 of V1).
So in brief, c|(ab) and (ab)|c and hence c = ab (noting that a, b, c > 0), i.e. if Ok n1 and Ok n2 are
relatively prime then Ok (n1 n2 ) = Ok n1 × Ok n2 .
11. Show that if Ok n = (k − 1) then k is prime (where N ∋ k > 1).
Solution: According to Problem 3 we have (k − 1)|φ(k) which implies (k − 1) ≤ φ(k). However, for all
k > 1 we have φ(k) ≤ (k − 1) (see point 7 in the preamble of § 2.6.4 of V1). Hence, φ(k) = (k − 1), i.e.
k is prime (see Problem 7 of § 10).
residue system modulo k) is a group under modular multiplication (modulo k). So, primitive root is an
element in Srk whose order (or period; see § 1.3) is φ(k) and hence the sequence of its natural powers
generates all the elements in Srk . So, we can say: ρ ∈ Srk is a primitive root iff the order of ρ is equal
to φ(k), i.e. Ok ρ = φ(k).[10]
2. Based on what have been said, when k has a primitive root (say ρ) then Srk can be written as:
Srk = {ρ1 , ρ2 , . . . , ρφ(k) }.[11] Accordingly, multiplication of two elements of Srk in modulo k will
become addition of their indices in modulo φ(k).
3. As seen above, some (modular) integers (like 8) have no primitive root. In brief, only the following
(modular) integers have primitive roots: 2, 4, pa and 2pa (where p is an odd prime and a ∈ N). This
issue will be investigated further in the future.
4. Referring to the proposition of Problem 4 of § 1.3 (as well as point 1 above), if ρ is a primitive root
(modulo k) then we have:
Ok ρ φ(k)
O k ρb = =
gcd (Ok ρ, b) gcd φ(k), b
This means that ρb is a primitive root (modulo k) iff gcd φ(k), b = 1.
5. Every prime has at least one primitive root.
Problems
1. Referring to point 1 in the preamble, find the order of all the elements of Sr12 (i.e. the reduced residue
system modulo 12) and hence determine the primitive roots of 12.
Solution: Sr12 = {1, 5, 7, 11} and hence φ(12) = 4. We have:
12
• 11,2,... = 1, 1, . . . and hence the order of 1 is 1.
12
• 51,2,... = 5, 1, . . . and hence the order of 5 is 2.
12
• 71,2,... = 7, 1, . . . and hence the order of 7 is 2.
12
• 111,2,... = 11, 1, . . . and hence the order of 11 is 2.
Therefore, 12 has no primitive root.
2. Repeat Problem 1 for Sr9 .
Solution: Sr9 = {1, 2, 4, 5, 7, 8} and hence φ(9) = 6. We have:
9
• 11,2,... = 1, 1, . . . and hence the order of 1 is 1.
9
• 21,2,3,4,5,6,... = 2, 4, 8, 7, 5, 1, . . . and hence the order of 2 is 6.
9
• 41,2,3,... = 4, 7, 1, . . . and hence the order of 4 is 3.
9
• 51,2,3,4,5,6,... = 5, 7, 8, 4, 2, 1, . . . and hence the order of 5 is 6.
9
• 71,2,3,... = 7, 4, 1, . . . and hence the order of 7 is 3.
9
• 81,2,... = 8, 1, . . . and hence the order of 8 is 2.
Therefore, the primitive roots of 9 are 2 and 5.
3. Repeat Problem 1 for Sr5 .
Solution: Sr5 = {1, 2, 3, 4} and hence φ(5) = 4. We have:
5
• 11,2,... = 1, 1, . . . and hence the order of 1 is 1.
5
• 21,2,3,4,... = 2, 4, 3, 1, . . . and hence the order of 2 is 4.
5
• 31,2,3,4,... = 3, 4, 2, 1, . . . and hence the order of 3 is 4.
5
• 41,2,... = 4, 1, . . . and hence the order of 4 is 2.
Therefore, the primitive roots of 5 are 2 and 3.
p
4. Show that if r is a primitive root of p (where p is an odd prime) then r(p−1)/2 = −1.
Solution: From Fermat’s little theorem we have:
p p p
rp−1 = 1 → rp−1 − 1 = 0 → (r(p−1)/2 − 1)(r(p−1)/2 + 1) = 0
[10] Morerigorously and generally, Ok n = φ(k) iff n is a primitive root modulo k (where n and k are coprime). In fact, this
may be used as a definition for “primitive root”.
[11] It k
is useful to note that ρφ(k) = 1 according to Euler’s theorem (which can be regarded, in this context, as a definition
of primitive root taking into account other related concepts and definitions as well as the restriction on the order of ρ).
1.4 Primitive Root 17
p
where the factorization in the last step is because (p − 1) is even. Now, r(p−1)/2 − 1 6= 0 because r is
p p
supposedly a primitive root (noting that r(p−1)/2 − 1 = 0 which implies r(p−1)/2 = 1 means that the
p
order of r is less than p − 1 in contradiction to being a primitive root). Hence, r(p−1)/2 + 1 = 0, i.e.
p
r(p−1)/2 = −1.
5. Show that if k has a primitive root then it must have φ φ(k) distinct primitive roots.
Solution: {ρ1 , ρ2 , . . . , ρφ(k) } is a reduced residue system (modulo k) when ρ is a primitive root of k
(see points 1 and 2 in the preamble). So, when we say “k has a primitive root” we are assuming that we
have an element ρ in the reduced residue system whose powers i.e. ρ1 , ρ2 , . . . , ρφ(k) generate all the
elements in this system. Accordingly, any primitive root of k (i.e. any element that generates the entire
system) must be among these ρi i = 1, 2, . . . , φ(k) because these ρi represent the entire system. Now,
from point 4 in the preamble ρb is a primitive root (modulo
k) iff gcd φ(k), b = 1, i.e. and b are
φ(k)
coprime. The number of positive integers b ≤ φ(k) which are coprime to φ(k) is φ φ(k) and hence
the number of primitive roots among these distinct elements i.e. ρ1 , ρ2 , . . . , ρφ(k) must be φ φ(k) .
Note: referring to Problems 2 and 3, we have:
φ φ(9) = φ 6 = 2 and φ φ(5) = φ 4 = 2
This should serve as a simple check that we did not make a gross mistake.
6. How many primitive roots the following numbers have:
(a) 113. (b) 254. (c) 311.
Solution: All these numbers have a primitive root (noting that 113 and 311 are primes while 254 is 2
timesa prime; seepoint 3 in the preamble) and hence we can use the proposition of Problem 5.
(a) φ φ(113) = φ 112 = 48 and hence 113 has 48 primitive roots.
(b) φ φ(254) = φ 126 = 36 and hence 254 has 36 primitive roots.
(c) φ φ(311) = φ 310 = 120 and hence 311 has 120 primitive roots.
7. Show that the product of two distinct primitive roots (modulo an odd prime) is not a primitive root
(of that prime).
Solution: Let r and ρ be two distinct primitive roots modulo p (where p is an odd prime). Now, from
Problem 4 we have:
p p p
r(p−1)/2 = −1 and ρ(p−1)/2 = −1 → (rρ)(p−1)/2 = 1
Hence, rρ cannot be a primitive root of p because its order is less than p − 1.
8. Determine the number of primitive roots of all N ∋ k > 1.
Solution: Referring
to point 3 in the preamble (as well as Problem 5):
• 2 has φφ(2) = φ1 = 1 primitive root (which is 1).
• 4 has φ φ(4)
a = φ 2 =a 1 primitive root (which is 3).
• pa has φ φ(p
) =
φ p − p a−1
primitive
roots.
• 2pa has φ φ(2pa ) = φ φ(pa ) = φ pa − pa−1 primitive roots (see part a of Problem 13 of § 10).
• All other k have no primitive root.
9. Show that if r is a primitive root (modulo k) then its modular multiplicative inverse r∗ is also a primitive
root (modulo k).
Solution: According to Problem 9 of § 1.3, r and r∗ have the same order (modulo k) and hence if r is
a primitive root then r∗ must also be a primitive root.
10. Show that if r is a primitive root of k then −r is not necessarily a primitive root of k.
Solution: For example, r = 2 is a primitive root of k = 9 while r = −2 is not a primitive root of k = 9.
On the other hand, both r = 2 and r = −2 are primitive roots of k = 5.
11. Show that if r is a primitive root of a prime p = 4k + 1 (k ∈ N) then −r is also a primitive root of p.
Solution: We have:
p
(−r)p−1 = rp−1 = rφ(p) = 1
where the last step is from Euler’s theorem (noting that r is a primitive root of p and hence they
are coprime). So, from Problem 3 of § 1.3 we have Op (−r)|(p − 1), i.e. Op (−r) ≤ (p − 1). Now, if
Op (−r) < (p − 1) then we have two cases to consider:
1.4 Primitive Root 18
• Op (−r) is even say Op (−r) = 2a for some a ∈ N and hence:
p p
(−r)2a = 1 → r2a = 1
which means that the order of r is less than (p − 1) in contradiction to the presumption that r is a
primitive root.
• Op (−r) is odd say Op (−r) = 2a − 1 for some a ∈ N and hence:
p p
(−r)2a−1 = 1 → r2(2a−1) = 1
So, from Problem 1 of § 1.3 we have:
Op r 2(2a − 1) → (p − 1)| 2(2a − 1) → (4k)| 2(2a − 1) → (2k)|(2a − 1)
However, this is impossible because 2k is even while (2a − 1) is odd (noting that no odd number is
divisible by an even number).
So, it is not possible to have Op (−r) < (p − 1) and hence we must have Op (−r) = (p − 1), i.e. −r is
also a primitive root of p.
12. Find all the primitive roots of the following moduli:
(a) 22. (b) 49. (c) 17932.
Solution:
(a) 22 = 2 × 11 and hence it shouldhave primitive roots (see point 3 in the preamble). The number of
these primitive roots is: φ 111 − 110 = φ(10) = 4 (see Problem 8). Now, if we test the natural numbers
> 1 which are coprime to 22 (i.e. 3, 5, 7, 9, 13, 15, 17, 19, 21) we will find out that only 7, 13, 17, 19 have
order (mod 22) of φ(22) = 10. Accordingly, 7, 13, 17, 19 are the primitive roots of 22.
(b) 49 = 72 and hence it should have primitive roots (see point 3 in the preamble). The number of
these primitive roots is: φ 72 − 71 = φ(42) = 12 (see Problem 8). Now, if we test the natural numbers
> 1 which are coprime to 49 we will find out that only 3, 5, 10, 12, 17, 24, 26, 33, 38, 40, 45, 47 have order
(mod 49) of φ(49) = 42. Accordingly, 3, 5, 10, 12, 17, 24, 26, 33, 38, 40, 45, 47 are the primitive roots of
49.
(c) 17932 = 22 × 4483 and hence it has no primitive root (see point 3 in the preamble).
13. Find all integers n such that O31 n = 5.
Solution: The smallest primitive root of modulo 31 is 3 and hence O31 3 = φ(31) = 30 (see point 1 in
the preamble). We also note that since 3 is a primitive root then any integer (coprime to 31) can be
31
expressed as 3a (mod 31) for some a ∈ {1, 2, . . . , 30}. So, let n = 3a and hence we are looking for all
values of a such that O31 3a = 5. Now, from Problem 4 of § 1.3 we have:
O31 3 30
O31 3a = =
gcd (O31 3, a) gcd (30, a)
So, to find all values of a such that O31 3a = 5 we need to find all values of a such that gcd (30, a) = 6.
Now, gcd (30, a) = 6 (among the integers a ∈ {1, 2, . . . , 30}) are 6, 12, 18, 24. Accordingly, O31 n = 5 for
31 31
36 , 312 , 318 , 324 = 16, 8, 4, 2. So, O31 n = 5 for all n = 2, 4, 8, 16.
14. Show that if p is a prime ≥ 5 then its primitive roots occur in incongruent pairs (r, r∗ ) where r∗ is the
modular multiplicative inverse of r (modulo p).
Solution: Based on the given assumptions we have:
p
• n = ±1 cannot be primitive roots of p (because their order is 1 and 2 while the order of a primitive
root must be p − 1 which is ≥ 4). Hence, any primitive root r must be in the range 1 < r < (p − 1)
(mod p).
• From part (f) of Problem 2 of § 2.7.1 of V1, the multiplicative inverse of any 1 < r < (p − 1) must be
p
incongruent to r (i.e. r 6= r∗ ).
• From part (h) of Problem 2 of § 2.7.1 of V1, each member of the set S = {1, 2, . . . , (p − 1)} must have
a multiplicative inverse in S (modulo p) noting that S contains an even number of elements.
• From Problem 9, the multiplicative inverse r∗ of any primitive root r is also a primitive root.
Accordingly, each primitive root (mod p) must have an incongruent multiplicative inverse which is also
a primitive root, i.e. the primitive roots of p occur in incongruent pairs (r, r∗ ).
1.5 The Index of Integer 19
Note: a simpler proof (though it may be less rigorous and illuminating) is to note that (where we use
Fermat’s little theorem):
p p
rp−1 = 1 → ra rp−1−a = 1 a = 1, . . . , p−3
2
Now, ra and rp−1−a are obviously incongruent modular multiplicative inverses (within some of the above
conditions). So, if ra is a primitive root then (by Problem 9) rp−1−a is also a primitive root. Similarly,
if rp−1−a is a primitive root then ra is also a primitive root. Hence, primitive roots occur in incongruent
pairs.
15. Let p be a prime ≥ 5. Show that the product of all the primitive roots of p is congruent to 1 (mod p).
Solution: According to Problem 14, the primitive roots of p occur in incongruent pairs (r, r∗ ) where
r∗ is the modular multiplicative inverse of r. Now, the product of each pair is congruent to 1 (mod p),
p
i.e. rr∗ = 1. Hence, the product of all the primitive roots of p is congruent to 1 (mod p).
[12] The
IndexOfInt.cpp code (see Problem 1 of § 18.1) can be used to calculate the indices of integers e.g. I53,2 (17) in this
Problem.
1.6 Quadratic Residue 20
(c) A primitive root of 17 is 3 and we have noting that φ(17) = 16 :
17 φ(17) 16
9x4 = 32 → I17,3 9x4 = I17,3 (32). → I17,3 (9) + 4I17,3 (x) = I17,3 (32) →
16 16 4
2 + 4I17,3 (x) = 6 → 4I17,3 (x) = 4 → I17,3 (x) = 1
16 φ(17) 17 17
So, I17,3 (x) = 1, 5, 9, 13 i.e. I17,3 (x) = 1, 5, 9, 13 which means x = 31 , 35 , 39 , 313 = 3, 5, 14, 12.
17
Hence, the solutions of the given congruence equation are x = 3, 5, 12, 14.
[13] This is for convenience and because each convention has an advantage in certain situations and contexts.
1.6 Quadratic Residue 21
[14] We note that we use 12 , 22 to represent the integers which are congruent to 1, 4 (mod p), i.e. 1 + kp and 4 + kp. This
laxity is for the sake of simplicity and to avoid some complications in the presentation.
[15] In fact, the examples given in the present Problem (and the given solutions) should also clarify the proposition of Problem
2 and remove any ambiguity or confusion about the proof given in Problem 2. We advise the reader to inspect the pattern
in these solutions and take note of it as this should improve the understanding of Problem 2.
1.6 Quadratic Residue 22
k [ φ(k)
2 ] k φ(k) k
xφ(k) = 1 → x2 =1 → n 2 =1
6. Show that a primitive root (modulo k > 2) cannot be a quadratic residue (modulo k).
Solution: This can be concluded from the proposition of Problem 5 because the order of a quadratic
φ(k) k
residue n (modulo k) is less than φ(k) since n 2 = 1, while the order of a primitive root (modulo k)
is φ(k) (see point 1 in the preamble of § 1.4).
k
We may also argue that if r is a primitive root (modulo k) then r = r1 . On the other hand, any
k
quadratic residue n must be an even power of r i.e. n = r2s = (rs )2 where s ∈ N so that the
k
congruence x2 = n can have a solution. Hence, a primitive root cannot be a quadratic residue.
Yes, there is one exception which is 1 (modulo 2) since 1 is a primitive root (mod 2) and 1 is a quadratic
residue (mod 2), and hence we imposed k > 2. Also see Problem 6 of § 1.9.
7. Let r be a primitive root of an odd prime p. Show that the quadratic residues (mod p) are the even
powers of r while the quadratic non-residues (mod p) are the odd powers of r.
Solution: Any x ∈ {1, 2, . . . .p − 1} should be equal (mod p) to rs for some s ∈ N. Now, if n is a
quadratic residue (mod p) then from Problem 2 we must have n = x2 = (rs )2 = r2s , i.e. n is an even
power of r. So, the quadratic non-residues must be the (remaining) odd powers of r (also see Problem
6).
8. Show that if r is a primitive root of an odd prime p then:
Y p 2 Y p 2
QR = r(p −1)/4 and QnR = r(p−1) /4
Q Q
where QR is the product of all quadratic residues (mod p) and QnR is the product of all quadratic
non-residues (mod p).
Solution: The quadratic residues are the even powers of r while the quadratic non-residues are the
odd powers of r (see Problem 7). Hence:
Y p P(p−1)/2 (p2 −1)/8 2
QR = r2 × r4 × · · · × r2(p−1)/2 = r2 k=1 k
= r2 = r(p −1)/4
φ(12) 12
[16] Itis worth noting that the converse of this statement is not true in general. For instance, 5 2 = 54/2 = 52 = 1 but 5
is not a quadratic residue (modulo 12).
1.7 The Quadratic Congruence Theorem 23
where we used the arithmetic series formula in step 3 (see Eq. 15 in V1).
Similarly: Y p P(p−1)/2 2
QnR = r1 × r3 × · · · × rp−2 = r k=1 (2k−1) = r(p−1) /4
Pn
where we used the formula k=1 (2k − 1) = n2 in step 3.
p
1. m p = np where m, n ∈ Z and p is an odd prime with n and p being coprime and m = n.
2. If p is an odd prime then:
−1
= (−1)(p−1)/2 (6)
p
3. If p is an odd prime then:
( 8
2 (p2 −1)/8 +1 (p = ±1)
= (−1) = 8 (7)
p −1 (p = ±3)
[19] Totally(or completely) multiplicative function is defined as an arithmetic function (see § 1.1 of V1) such that f (1) = 1
and f (mn) = f (m)f (n) for all m, n ∈ N.
1.8 Legendre’s Symbol 25
5. Show that for any prime p ≥ 7 we must have at least one pair of consecutive quadratic non-residues.
Solution: If p = 7 then we have 5 and 6 (which are consecutive quadratic non-residues of 7). So, in
the following we consider the cases of p > 7.
We note first that 1, 4, 9 (i.e. 12 , 22 , 32 ) are quadratic residues of p (see Problem 2 of § 1.6). Now, if
we have a pair of consecutive quadratic non-residues among 1, 2, 3, 4, 5, 6, 7, 8, 9 then we got what we
want. If not then we must have an alternation in quadratic residues and quadratic non-residues in such a
way that prevents the occurrence of consecutive quadratic non-residues among 1, 2, 3, 4, 5, 6, 7, 8, 9. This
means that at least one of 2, 3 must be a quadratic residue and at least two of 5, 6, 7, 8 must be quadratic
residues. So, in total we must have at least six quadratic residues among 1, 2, 3, 4, 5, 6, 7, 8, 9. Now, if we
remember that quadratic residues and quadratic non-residues are equal in number (see Problem 2 of §
1.6) then we will not have enough quadratic residues after 9 to have a similar alternation that prevents
the occurrence of consecutive quadratic non-residues after 9, i.e. we must have at least one pair of
consecutive quadratic non-residues after 9. So in brief, we must have a pair of consecutive quadratic
non-residues among 1, 2, 3, 4, 5, 6, 7, 8, 9 or after 9.
Note: the obvious conclusion of this Problem and the previous Problem is that for p ≥ 7 we must
always have pairs of consecutive quadratic residues and consecutive quadratic
non-residues.
6863 1137
6. Determine the value of the following Legendre symbols: 7883 and 5821 .
7883
Solution: The congruence
x2 = 6863 has no solution (i.e. 6863 is a quadratic non-residue mod 7883)
6863
and hence 7883 = −1.
5821 1137
The congruence x2 = 1137 is solvable (i.e. 1137 is a quadratic residue mod 5821) and hence 5821 = 1.
n
7. Determine the value of the Legendre symbol: 11 for all n ∈ Z.
Solution: Referring to part (b) of Problem 3 of § 1.6:
n
11
• 11 = +1 for n = 1, 3, 4, 5, 9.
n
11
• 11 = −1 for n = 2, 6, 7, 8, 10.
n
11
• 11 = 0 for n = 0.
8. Evaluate the following Legendre symbols:
(a) 122
19 . (b) 225
41 . (c) −183
61 . (d) −20101 .
Solution: In this Problem we use the rules of Legendre’s symbol (as well as the general rules such as
those of modular arithmetic and quadratic residues).[20]
(a) We have:
122 8 19
= (122 = 8)
19 19
3
2
=
19
2 2 2
= (Eq. 8)
19 19 19
2 2
= = ±1
19 19
19
= −1 (2 6= 12 , 22 , . . . , 92 ; see Problem 2 of § 1.6)
19 19
A simpler approach is to note that 122 = 8 6= 12 , 22 , . . . , 92 and hence we need no more than two steps.
(b) We have:
2
225 3 × 52
=
41 41
[20] Wenote that in some of the following solutions we do extra work for pedagogical purposes (otherwise some solutions
can be obtained in less steps). We also note that there are various ways for obtaining these results and hence what we
present in the following solutions is just a sample of these various ways.
1.8 Legendre’s Symbol 26
3252
= (Eq. 8)
4141
2 2
3 5
= (Eq. 9)
41 41
=1×1=1 (±1)2 = 1 noting that 3 and 5 are coprime to 41
A simpler approach is to use Eq. 9 from the beginning (noting that 225 = 152 and 15 and 41 are
coprime).
(c) 61|(−183) and hence this Legendre symbol is zero.
(d) We have:
−20 81 101
= (−20 = 81)
101 101
2
9
=
101
2
9
= (Eq. 9)
101
=1 (±1)2 = 1 noting that 9 and 101 are coprime
9. Use property 2 (in the preamble) to determine the Legendre symbol −1 p for all odd primes according
to their modularity in modulo 4.
Solution: Every odd prime must be either of the form (4k + 1) or of the form (4k − 1) where k ∈ N
(see Problem 16 of § 2.2 of V1). Now, if p = 4k + 1 then from property 2 we have:
−1
= (−1)(p−1)/2 = (−1)(4k+1−1)/2 = (−1)2k = +1
p
Solution: All these relations are proved in Problem 9 of § 1.11 for Jacobi symbol and hence they should
apply to Legendre symbol as well (noting that Legendre symbol is a special case of Jacobi symbol; see
point 9 of § 1.11). We should also note that some of these relations are trivial to prove since they
are no
more
than
a special case of relations which are proved
forLegendre
symbol independently, e.g.
m2 m m mn m n
p = p p is a special case of the relation p = p p which we proved in Problem 4
of § 1.9.[21]
13. Show that mn is a quadratic residue of p (where p is an odd prime) iff m and n are either both quadratic
residues of p or both quadratic non-residues of p.
Solution: We note first that mn is coprime to p iff m and n are both coprime to p. From property 4
we have:
mn m n
=
p p p
So, mn p = 1 iff either m
p = 1 and n
p = 1 or m
p = −1 and n
p = −1, i.e. mn is a quadratic
residue of p iff m and n are either both quadratic residues of p or both quadratic non-residues of p.
14. Show that n and n∗ are either both quadratic residues of p or both quadratic non-residues of p (where
n∗ is the multiplicative inverse of n and p is an odd prime).
p
Solution: We have nn∗ = 1. Now, 1 is a quadratic residue of p (see Problem 2 of § 1.6) and hence
by the proposition of Problem 13, n and n∗ are either both quadratic residues of p or both quadratic
non-residues of p.
15. State Gauss lemma and use it to calculate the following Legendre symbols:
13
(a) 17 . (b) 2131 .
Solution: Gauss lemma states: if m is an integer coprime to the odd prime p, and n is the number of
least positive residues (modulo p) of the integers m, 2m, . . . , (p−1)m
2 which are greater than p/2, then:
m
= (−1)n
p
[21] In m
fact, the relation of part (a) is self evident because p
= ±1.
1.9 Euler’s Criterion 28
p
(p − 1)! + n(p−1)/2 = 0 (quadratic congruence theorem; see § 1.7)
p
−(p − 1)! = n(p−1)/2
p
+1 = n(p−1)/2 (Wilson’s theorem)
n p (p−1)/2
=n (given)
p
We may also argue that in this case n is a quadratic residue (mod p) and hence we have x ∈ Z such that:
p (p−1)/2 p (p−1)/2 p
x2 = n → x2 =n → n(p−1)/2 = xp−1
p
Now, x2 = n (noting that p6 | n) implies p6 | x2 and hence p6 | x (i.e. p
and x are coprime). Therefore,
p−1 p (p−1)/2 p n
from Fermat’s little theorem we have x = 1, i.e. n = 1 = p as required.
• np = −1: in this case n is a quadratic non-residue (mod p) and hence we have:
p
(p − 1)! − n(p−1)/2 = 0 (quadratic congruence theorem; see § 1.7)
p
(p − 1)! = n(p−1)/2
p
−1 = n(p−1)/2 (Wilson’s theorem)
n p (p−1)/2
=n (given)
p
As we see, in both cases Eq. 10 is valid (and this completes the proof).
2. Prove property 2 of § 1.8.
Solution: According to Euler’s criterion we have:
−1 p −1
= (−1)(p−1)/2 → p − (−1)(p−1)/2
p p
Now, −1 p and (−1)(p−1)/2 can be only +1 or −1 (and hence the dividend can only be 0 or 2 or −2).
Moreover,
p is an odd prime. Hence, this divisibility statement is valid only if the dividend is 0, i.e.
−1 (p−1)/2
p = (−1) .
3. Prove property 3 of § 1.8.
Solution: We have:
p p p p p
p − 1 = 1 (−1)1 2 = 2 (−1)2 p − 3 = 3 (−1)3 4 = 4 (−1)4 ··· A = p−12 (−1)
(p−1)/2
4 4
where A = p− p−12 =
2p−p+1
2 = p+1 p−1
2 if p = −1 and A = 2 if p = 1. Now, if we multiply these (p−1)/2
congruences side by side (see rule 10 in the preamble of § 2.7 of V1) then we get:
P(p−1)/2
p p−1 i
(p − 1) × 2 × (p − 3) × 4 × . . . × A = ! (−1) i=1 (11)
2
Now, the LHS is equal to 2 × 4 × . . . × (p − 1).[22] Moreover, from the arithmetic series formula we have
[22] This is just rearrangement of the terms in this product, that is:
p+1 p+1 p+1
(p − 1) × 2 × (p − 3) × 4 × . . . × = 2 × 4 × ... × × . . . × (p − 3) × (p − 1) A=
2 2 2
1.9 Euler’s Criterion 29
P(p−1)/2
i=1 i = (p2 − 1)/8. Hence, Eq. 11 becomes:
p p−1 2
2 × 4 × . . . × (p − 1) = ! (−1)(p −1)/8 (12)
2
Now, an odd prime can only be of the following forms: p = 8k ± 1 and p = 8k ± 3 where k ∈ N (because
otherwise it will be even). So, if p = 8k ±1 then (p2 −1)/8 = 8k 2 ±2k (which is even), while if p = 8k ±3
then (p2 − 1)/8 = 8k 2 ± 6k + 1 (which is odd). Hence:
( 8
2 (p2 −1)/8 +1 (p = ±1)
= (−1) = 8
p −1 (p = ±3)
mn m p n
= (Eq. 10)
p p p
Now, if we note that each of mn
p , mp and np is equal either to +1 or to −1 (noting that mn, m, n
are coprime to p) then we have the following 8 (comprehensive) cases:
p p p p
+1 = (+1)(+1) +1 = (+1)(−1) +1 = (−1)(+1) +1 = (−1)(−1)
p p p p
−1 = (+1)(+1) −1 = (+1)(−1) −1 = (−1)(+1) −1 = (−1)(−1)
As we see, the 2nd , 3rd , 5th , 8th cases are impossible (noting that p is an odd prime and hence p6 | 2). So,
the only possible cases are the other four and this should establish Eq. 8 and complete the proof.
5. Repeat Problem 7 of § 1.8 using this time Euler’s criterion (i.e. Eq. 10).
Solution: p = 11 and (p − 1)/2 = 5 and we have:
11 11 11 11 11 11 11 11 11 11
15 = 1 25 = −1 35 = 1 45 = 1 55 = 1 65 = −1 75 = −1 85 = −1 95 = 1 105 = −1
n
11 n
11 5 11
Hence, 11 = +1 for n = 1, 3, 4, 5, 9 and 11 = −1 for n = 2, 6, 7, 8, 10. Also, 0 = 0 and hence
n
11
11 = 0 for n = 0. These results are identical to the results of Problem 7 of § 1.8.
6. Use Euler’s criterion to show that a quadratic residue of an odd prime p cannot be a primitive root of
p.
p p
Solution: If n is a quadratic reside then by Euler’s criterion we have n(p−1)/2 = 1, i.e. nφ(p)/2 = 1.
This means that Op n < φ(p) and hence n cannot be a primitive root (see point 1 of § 1.4). Also see
Problem 6 of § 1.6.
Note: it is important to note that this proposition means that an integer cannot be a quadratic residue
and a primitive root (of an odd prime) at the same time. This does not mean that a non-quadratic
residue must be a primitive root. For instance, 6 is a quadratic non-residue (mod 7) and it is not a
primitive root (mod 7). So in brief, a quadratic residue cannot be a primitive root (and similarly a
primitive root cannot be a quadratic residue), but a quadratic non-residue can be a primitive root (such
as 3 in mod 7) and can be not a primitive root (such as 6 in mod 7). Also see Problem 7.
7. Show that if p is an odd prime then there are p−1
2 − φ(p − 1) quadratic non-residues (mod p) which are
not primitive roots (mod p).
Solution: According to Problem 6, a quadratic residue cannot be a primitive root. So, primitive roots
must be among the p−1 2 quadratic non-residues (see
Problem
2 of § 1.6). Also, according to Problem
8 of § 1.4 the number of primitive roots of p is φ φ(p) = φ(p − 1). Hence, the number of quadratic
non-residues which are not primitive roots is p−1
2 − φ(p − 1).
7
29
which implies 29 = 1 since 7 = 1. Therefore, 7 is a quadratic residue (mod 29).
11
(b) We have 23 = 1 and 1 is a quadratic
residue of 11 (see Problem 2 of § 1.6) and hence 23 is a
quadratic residue (mod 11), i.e. 2311 = 1. Moreover, from the law of quadratic reciprocity we have:
11 23
= (−1)(11−1)(23−1)/4 = (−1)55 = −1
23 11
11
which implies 23 = −1 since 23
11 = 1. Therefore, 11 is a quadratic non-residue (mod 23).
2. Let p and q be odd primes. Use the law of quadratic reciprocity to correlate the solvability of the
p q
congruence x2 = q to the solvability of the congruence x2 = p according to the modularity of p and q
in modulo 4.
Solution: Every odd prime must be either of the form (4k + 1) or of the form (4k − 1) where k ∈ N
(see Problem 16 of § 2.2 of V1). Now, if p = 4k ± 1 and q = 4κ ± 1 then we have 4 cases:
• p = 4k + 1 and q = 4κ + 1 and hence (by the law of quadratic reciprocity):
p q
= (−1)(p−1)(q−1)/4 = (−1)(4k+1−1)(4κ+1−1)/4 = (−1)4kκ = 1
q p
• p = 4k + 1 and q = 4κ − 1 and hence:
p q
= (−1)(p−1)(q−1)/4 = (−1)(4k+1−1)(4κ−1−1)/4 = (−1)4kκ−2k = 1
q p
• p = 4k − 1 and q = 4κ + 1 and hence:
p q
= (−1)(p−1)(q−1)/4 = (−1)(4k−1−1)(4κ+1−1)/4 = (−1)4kκ−2κ = 1
q p
• p = 4k − 1 and q = 4κ − 1 and hence:
p q
= (−1)(p−1)(q−1)/4 = (−1)(4k−1−1)(4κ−1−1)/4 = (−1)4kκ−2k−2κ+1 = −1
q p
As we see, pq q
p = 1 when p = 4k + 1 or/and q = 4κ + 1 while p
q
q
p = −1 when both p = 4k − 1
and q = 4κ − 1. This means:
p
⋆ When p = 4k + 1 or/and q = 4κ + 1 then either both the aforementioned congruences (i.e. x2 = q
q
and x2 = p) are solvable or both are non-solvable.
⋆ When p = 4k−1 and q = 4κ−1 then one of these congruences is solvable and the other is non-solvable.
6521 4
Note: for instance, knowing that x2 = 5701 is solvable and 5701 = 1 we can immediately conclude
5701 6367 4
that x2 = 6521 is also solvable. Similarly, knowing that x2 = 5701 is non-solvable and 5701 = 1 we
5701
can immediately conclude that x2 = 6367 is also non-solvable.
6043 4 4
On the other hand, knowing that x2 = 5711 is non-solvable and 5711 = 6043 = −1 we can immediately
5711
conclude that x2 = 6043 is solvable.
1. The Jacobi symbol takes only the values +1 and −1 (since the Legendre symbol takes only these values;
see Eq. 15).
2. Following the style of Legendre’s symbol, we define Jacobi’s symbol to be zero when n and N are not
coprime (also see point 6 in the preamble of § 1.8).
3. If mn ∈ Z is coprime to N (or each of m, n ∈ Z is coprime to N ) then:[23]
mn m n
= (N is odd positive integer) (16)
N N N
4. If M N is coprime to n ∈ Z (or each of M, N is coprime to n ∈ Z) then:
n n n
= (M, N are odd positive integers) (17)
MN M N
N
5. If m, n ∈ Z are coprime to N and m = n then:
m n
= (N is odd positive integer) (18)
N N
6. If M, N are odd coprime positive integers then:
M N
= (−1)(M −1)(N −1)/4 (19)
N M
This means that the law of quadratic reciprocity (or rather an analogue or generalization of it) applies
to Jacobi’s symbols as to Legendre’s symbols (see § 1.10).
7. The significance of Jacobi’s symbol is that:
• If m is a quadratic residue (mod N ) then m N = 1. However, the converse is not true in general, i.e.
if mN = 1 then it is not necessary that m is a quadratic
residue (mod N ). For example, 10
237 = 1 and
14
10 is a quadratic
residue (mod 237), while 237 = 1 and 14 is not a quadratic residue (mod 237).
• If m N = −1 then m is a quadratic non-residue (mod N ). In fact, this point is essentially the
contraposition of the previous point (noting that Jacobi’s symbol is either +1 or −1 if we exclude the
case of m and N not being coprime).
8. Point 7 highlights an important difference between Legendre’s symbol and Jacobi’s symbol, i.e. for
Legendre’s symbol np = +1 iff n is a quadratic residue, while for Jacobi’s symbol N n
= +1 if n is a
quadratic residue. Practically, this means that if we know that n is a quadratic residue (non-residue)
then we can conclude that np = +1 (−1) and vice verse. On the other hand, if we know that n is a
n
n
quadratic residue then we can conclude that N = +1 and if we know that N = −1 then we can
n
conclude that n is a quadratic non-residue but if we know that N = +1 then we cannot conclude
that n isa quadratic
residue and if we know that n is a quadratic non-residue then we cannot conclude
n
that N = −1 .
9. Jacobi’s symbol reduces to Legendre’s symbol when N is an odd prime. Accordingly, Legendre’s symbol
is a special case of Jacobi’s symbol and hence the attributes (represented in algebraic relations) of
Jacobi’s symbol should generally apply to Legendre’s symbol (as long as we observe the restriction
imposed on the relation between the value of these symbols and quadratic residue which we discussed
in points 7 and 8). Therefore, the proofs related to Jacobi’s symbol are also proofs to Legendre’s symbol
(as long as quadratic residues are not involved and the proofs are not dependent on corresponding proofs
related to Legendre’s symbol).
Problems
1. Calculate the following Jacobi symbols:
21
45
66
49
(a) 6137 . (b) 98237 . (c) 414507281407 . (d) 343 .
[23] This (as well as some of the next points) applies even without the condition of coprimality (but we ignore this trivial
case).
1.11 Jacobi’s Symbol 33
Solution:
(a) 6137 = 171 × 192 and hence:
1 2
21 21 21
= = (+1)(−1)2 = +1
6137 17 19
(b) 98237 = 1931 × 5091 and hence:
1 1
45 45 45
= = (−1)1 (+1)1 = −1
98237 193 509
66
(c) 414507281407 is prime and hence this is a Legendre symbol. Thus 414507281407 = −1.
49
(d) 49 and 343 are not coprime and hence 343 =
0.
13
2. Calculate the following Jacobi symbol: 166182225 .
Solution: We can calculate this in a straightforward (and rather lengthy) way (as we did in Problem 1)
by using Eq. 15. However, we can exploit the properties and algebraic relations of Jacobi and Legendre
symbols (which we investigated earlier) to make some (rather essential) simplifications, that is:
13 166182225 1
= = = +1
166182225 13 13
where in step 1 we used Eq. 19 noting that (13 − 1)(166182225 − 1)/4 = 498546672 which is even and
13
hence (−1)(M −1)(N −1)/4 = 1 , and used property 1 of § 1.8 in step 2 (noting that 166182225 = 1).
3. Justify point 3 in the preamble of this section.
Solution: We note first that the coprimality of mn to N and the coprimality of each of m, n to N are
equivalent. Now, if N = pa1 1 pa2 2 . . . pakk then we have (see Eq. 15):
" k # " k #
m n Y m ai Y n ai
= ×
N N i=1
pi i=1
pi
Yk a a i
m i n
= ×
i=1
p i p i
Yk ai
m n
= ×
i=1
pi pi
Yk a
mn i
=
i=1
pi
mn
=
N
where we used property 4 of § 1.8 in line 4, and used Eq. 15 in line 5.
4. Justify point 4 in the preamble of this section.
Solution: We note first that the coprimality of M N to n and the coprimality of each of M, N to n are
equivalent. Now, if M = pa1 1 pa2 2 . . . pakk and N = q1b1 q2b2 . . . qsbs then M N = pa1 1 pa2 2 . . . pakk q1b1 q2b2 . . . qsbs
and hence (see Eq. 15):
n a 1 a 2 a k b 1 b 2 b s
n n n n n n
= × × ··· × × × × ··· ×
MN p1 p2 pk q1 q2 qs
a1 a2 a k " b 1 b 2 b s #
n n n n n n
= × × ··· × × × × ··· ×
p1 p2 pk q1 q2 qs
n n
=
M N
1.11 Jacobi’s Symbol 34
6. Prove (the two parts of) point 7 in the preamble of this section.
Solution: We have two parts to prove:
• If m is a quadratic residue (mod N ) then m N = 1: let N = pa1 1 pa2 2 . . . pakk noting that all pi
(i = 1, 2, . . . , k) are odd primes because N is odd (according to the definition of Jacobi’s symbol). Now,
N
since m is a quadratic residue (mod N ) then x2 = m is solvable, i.e. there is x ∈ Z (call it X) such that:
a a a
p1 1 p2 2 ...pkk pi
X2 = m → X 2 = m (i = 1, 2, . . . , k)
where this can be more easily understood
in terms of divisibility.[25] This means that m is a quadratic
m
residue (mod pi ) and hence pi = 1 (noting that we are using here Legendre’s symbol not Jacobi’s
symbol because pi is prime). Hence, from Eq. 15 we get m N = 1 since all m
pi are 1.
We prove that the converse is not true by the method of proof by example (see § 1.5.4 of V1) since we
have many
examples (e.g. the example given in the preamble) where the converse does not hold true.
• If mN = −1 then m is a quadratic non-residue (mod N ): as indicated in the preamble, this part is
essentially the contraposition of the previous part and hence it is true by contraposition, i.e. it does
not require another (or independent) proof (see § 1.1 of V1 as well as § 1.5.4 of V1).
7. Show that if N is an odd positive integer then:
−1
= (−1)(N −1)/2
N
Solution: If N = pa1 1 pa2 2 . . . pakk then we have:
Y k a
−1 i Y h ia i Y
k k Pk
−1
= = (−1)(pi −1)/2 = (−1)ai (pi −1)/2 = (−1) i=1 ai (pi −1)/2 (20)
N i=1
pi i=1 i=1
where we used Eq. 15 in step 1 and used property 2 of § 1.8 in step 2 (noting that N is odd and hence
each pi is an odd prime).
We also have:
ai
X
a 4
pai i = [1 + (pi − 1)] i = 1 + ai (pi − 1) + Cjai (pi − 1)j = 1 + ai (pi − 1) (21)
j=2
where in step 2 we used the binomial theorem while in step 3 we used the fact that (pi − 1) is even and
hence (pi − 1)j is divisible by 4 for j ≥ 2. Thus:
k
X
4 4
N = pa1 1 pa2 2 . . . pakk = 1 + a1 (p1 − 1) 1 + a2 (p2 − 1) . . . 1 + ak (pk − 1) = 1 + ai (pi − 1)
i=1
N a
[24] This is because m = n means N (which is equal to pa 1 a2 k
1 p2 . . . pk ) divides m − n and hence each pi must divide m − n,
pi
i.e. m = n.
a a a
p1 1 p2 2 ...pkk a
[25] The congruence X 2 = m is equivalent to (pa 1 a2 k 2 2
1 p2 . . . pk )|(X − m), and this implies pi |(X − m) which is
p
equivalent to X 2 =i m.
1.11 Jacobi’s Symbol 35
where step 2 is from Eq. 21 while step 3 is because all non-linear terms are 0 (mod 4) since (pi − 1) is
even. Hence (see rule 9 of § 2.7 of V1):
k
X k
4 N − 1 2 X ai (pi − 1)
N −1= ai (pi − 1) → =
i=1
2 i=1
2
Pk Pk
ai (pi −1)/2
i.e. (N − 1)/2 and i=1 ai (pi − 1)/2 have the same parity and hence (−1) i=1 = (−1)(N −1)/2 .
So, from Eq. 20 we conclude:
−1
= (−1)(N −1)/2
N
8. Show that if N is an odd positive integer then:
2 2
= (−1)(N −1)/8
N
Solution: If N is prime then this is no more than property 3 of § 1.8 (which we proved in Problem
3 of § 1.9). So, let assume that N is a composite whose prime factorization is N = pa1 1 pa2 2 . . . pakk .
Accordingly:
Y k a
2 i Yh ia i Y
k k Pk
2 (p2i −1)/8 2 2
= = (−1) = (−1)ai (pi −1)/8 = (−1) i=1 ai (pi −1)/8 (22)
N i=1
p i i=1 i=1
where in step 2 we used the binomial theorem while in step 3 we used the fact that (p2i − 1) is divisible
by 8 and hence (p2i − 1)j is divisible by 64 for j ≥ 2.[26] Thus:
2 a1 2 a 2 ak
N 2 = [pa1 1 pa2 2 . . . pakk ] = p21 p2 . . . p2k
k
X
64 64
= 1 + a1 (p21 − 1) 1 + a2 (p22 − 1) . . . 1 + ak (p2k − 1) = 1 + ai (p2i − 1)
i=1
where step 3 is from Eq. 23 while step 4 is because all non-linear terms are 0 (mod 64) since (p2i − 1)
is divisible by 8. Hence (see rule 9 of § 2.7 of V1 noting that since 8 divides p2i − 1 then it must divide
N 2 − 1):
Xk k
64 N 2 − 1 8 X ai (p2i − 1)
N2 − 1 = ai (p2i − 1) → =
i=1
8 i=1
8
P Pk 2
k
This implies that (N 2 −1)/8 and i=1 ai (p2i −1)/8 have the same parity[27] and hence (−1) i=1 ai (pi −1)/8 =
2
(−1)(N −1)/8 . So, from Eq. 22 we conclude:
2 2
= (−1)(N −1)/8
N
[26] As
P(p−1)/2
we noted earlier, from the arithmetic series formula we have i=1 i = (p2 − 1)/8 and hence (p2 − 1)/8 is an integer
which implies 8|(p − 1). Alternatively, any odd prime is of the form 4k ± 1 (k ∈ N) and hence (p2 − 1)/8 = 2k2 ± k
2
Now, if (N 2 − 1)/8 and ki=1 ai (p2i − 1)/8 have opposite parity then their difference will be odd and hence it cannot be
P
divisible by 8 which is even.
1.11 Jacobi’s Symbol 36
Problems
1. Prove the Mobius inversion formula which is given by:
X n
f (n) = µ(d) F (n ∈ N)
d
d|n
P
where µ is the Mobius function and F is the summatory function of f , i.e. F (n) = d|n f (d).[28]
Solution: We have:
X n X X X X
µ(d) F = µ(d) f (δ) = µ(d) f (δ) (25)
d
d|n d|n δ|(n/d) d|n δ|(n/d)
where we used the definition of summatory function (which is given above) in the first step. Now, let
us analyze the double sum in the last step of this equation. This double sum means that we take all
the (product) combinations of µ(d) and f (δ) where d represents all the divisors of n while δ represents
all the divisors of n/d. In other words, we need to loop over all the divisors (i.e. d) of n in combination
with all the divisors of n/d (i.e. δ). However, if we note that “all the divisors of n” are the same as
“all the divisors of n/d” (noting that d is looping over all the divisors of n from 1 to n inclusive) then
this double loop (representing the double sum) can be done equivalently (although the order of the
generated combinations generally differs) by taking all the (product) combinations of µ(δ) and f (d)
and hence we can continue Eq. 25 as follows:
X n X X X X X X
µ(d) F = µ(d) f (δ) = µ(d) f (δ) = µ(δ) f (d)
d
d|n d|n δ|(n/d) d|n δ|(n/d) d|n δ|(n/d)
X X
= f (d) µ(δ)
d|n δ|(n/d)
P
Now, µ(δ) = 0 (see Problem 3 of § 2.6.5 of V1) except when n/d = 1 (i.e. d = n) and hence:
δ|(n/d)
X X X X h i X
f (d) µ(δ) = f (n) µ(δ) = f (n) µ(δ)
d|n δ|(n/d) n|n δ|(n/n) δ|1
[28] For more details about the “summatory function”, see Problem 15 of § 10.
1.12 Mobius Inversion 38
" #
h i X
= f (n) µ(1) = f (n) × 1 = f (n)
1
since both d and n/d represent all the divisors of n since each divisor d is matched by a corresponding
divisor n/d noting that d × (n/d) = n (see Problem 19 of § 1.9 of V1).
2. Verify the Mobius inversion formula with regard to:
(a) The divisor function σ(n). (b) The tau function τ (n).
Solution:
(a) σ(n) is the summatory function of f (d) = d. Hence:
X n X n X X X X X X
µ(d) F = µ(d) σ = µ(d) f (δ) = µ(d) δ= µ(d) δ
d d
d|n d|n d|n δ|(n/d) d|n δ|(n/d) d|n δ|(n/d)
X X X X X
= µ(δ) d = d µ(δ) = n × 1 = n × 1 = n = f (n)
d|n δ|(n/d) d|n δ|(n/d) n|n
where step 2 is from Eq. 45 of V1 (with n = pa ; also see Problem 1 of § 2.6.4 of V1), while step 3 is
because the divisors of pa are p0 , p1 , . . . , pa . Now, we have:
X a X a a X a a
X
p p
φ(pa ) = µ(d) F = µ(pk ) F k = µ(pk ) F (pa−k ) = µ(pk ) pa−k
a
d p
d|p k=0 k=0 k=0
0 a−0 1 a−1 2 a−2 a a−a
= µ(p ) p + µ(p ) p + µ(p ) p + · · · + µ(p ) p
a a−1 a a−1
= p −p + 0 + ··· + 0 = p − p
where:
step 1 is from the Mobius inversion formula,
step 2 is because the divisors
of pa areP
p0 , p1 , . . . , pa , P
a−k a−k
step 4 is from Eq. 26 i.e. F (p ) ≡ d|pa−k φ(d) = i=0 φ(pi ) = pa−k , and
step 6 is because µ(p0 ) = µ(1) = 1 and µ(p1 ) = (−1)1 = −1 while µ(p2 ) = . . . = µ(pa ) = 0 (since they
are not square free).
Chapter 2
Miscellaneous
1. Determine the parity of am + bn + ck for all a, b, c ∈ Z and all m, n, k ∈ N0 .
Solution: We note first that we consider 00 as undefined and hence any case of 00 is not considered in
the following. Now, let represent the parity of a, b, c (as well as the parity of am + bn + ck ) with e for
even and o for odd. Also, let represent m, n, k with 0 when m, n, k is 0 and ignore its symbol otherwise
(e.g. e0 o0 e represents the case when a, b, c is even, odd, even with m = n = 0 and k 6= 0 noting that
e0 o0 e represents sum not product). Accordingly, the parity of am +bn +ck is given by the following table:
e0 e0 e0 = o e 0 e0 o0 = o e 0 o0 e0 = o e 0 o0 o0 = o o 0 e0 e0 = o o 0 e0 o 0 = o o 0 o0 e0 = o o 0 o0 o0 = o
e0 e0 e = e e0 e0 o = o e0 o0 e = e e0 o0 o = o o0 e0 e = e o 0 e0 o = o o0 o0 e = e o0 o0 o = o
e0 ee0 = e e0 eo0 = e e0 oe0 = o e0 oo0 = o o0 ee0 = e o0 eo0 = e o0 oe0 = o o0 oo0 = o
ee0 e0 = e ee0 o0 = e eo0 e0 = e eo0 o0 = e oe0 e0 = o oe0 o0 = o oo0 e0 = o oo0 o0 = o
e0 ee = o e0 eo = e e0 oe = e e0 oo = o o0 ee = o o0 eo = e o0 oe = e o0 oo = o
ee0 e = o ee0 o = e eo0 e = o eo0 o = e oe0 e = e oe0 o = o oo0 e = e oo0 o = o
eee0 = o eeo0 = o eoe0 = e eoo0 = e oee0 = e oeo0 = e ooe0 = o ooo0 = o
eee = e eeo = o eoe = o eoo = e oee = o oeo = e ooe = e ooo = o
2. Find all n ∈ Z such that P1 = P2 = P3 = P4 = P5 where:
Solution: If P1 = P2 = P3 = P4 = P5 then:
P1 = P2 & P 1 = P3 & P1 = P4 & P1 = P5
So, it is a problem of solving a system of univariate equations (see § 3.3 of V1). On solving the following
system:
P1 − P2 = 0 P1 − P3 = 0 P1 − P4 = 0 P1 − P5 = 0
we get: n = −9, 13, 46. So, we have P1 = P2 = P3 = P4 = P5 for these values of n.
3. Determine the sign of the polynomial f (n) = −n5 + 58n4 + 462n3 − 4913n2 − 4972n − 5376 for all n ∈ Z.
Solution: If we factorize f (n) to its simplest factors (i.e. linear and non factorizable quadratic) then
we get:
f (n) = (n + 12)(7 − n)(n − 64)(n2 + n + 1)
We can now build the following sign table:
n= < −12 −12 7 64 > 64
n + 12 − 0 + + + + +
7−n + + + 0 − − −
n − 64 − − − − − 0 +
n2 + n + 1 + + + + + + +
f (n) + 0 − 0 + 0 −
39
2 MISCELLANEOUS 40
As we see, the sign of f (n) is given in the last row, i.e. f (n) is positive for n < −12 and 7 < n < 64,
f (n) is negative for −12 < n < 7 and n > 64, and f (n) = 0 for n = −12, 7, 64.
4. Find a formula for the number of sets Ns of (distinct) natural numbers of size k (≥ 2) whose sum of
elements is equal to a given natural number Nn .
Solution: We have at least three methods to tackle this Problem: the use of generating function, the
use of recursive formula and the use of combinatorics argument. In the following, we discuss the first
method andPonly give the result of the second method.[29] Pk
k
For Nn < i=1 i we have zero set, and hence in the following we assume Nn ≥ i=1 i. Now, let
Pk
N0 = i=1 i and Nn = N0 + n (where n = 0, 1, 2, . . .). The generating function fg of the sequence of
Ns for a given k is given by:
1
fg (z, k) = Qk
j
j=1 (1 − z )
For example:
1 1
fg (z, 2) = fg (z, 3) =
(1 − z) (1 − z 2 ) (1 − z) (1 − z 2 ) (1 − z 3 )
Accordingly, the number of sets Ns (k, Nn ) (i.e. Ns as a function of k and Nn ) are given by the
coefficients cn of the series expansion of the generating function fg (z, k) at z = 0 (i.e. Taylor series).
For instance, the Taylor series of fg (z, 3) is given by:
and hence (noting that for k = 3 we have N0 = 1 + 2 + 3 = 6 and thus N4 = 10 and N9 = 15) we have:
Regarding the recursive formula we say the following: for Nn = N0 , N1 , . . . , Nk−1 we have
Ns (k, Nn ) = Ns (k − 1, Nn )
(where we should note the difference in the meaning of Nn on the two sides because of the dependency
of Nn on k) while for Nn > Nk−1 we have:
5. Referring to Problem 4, find all the sets of (distinct) natural numbers of:
(a) Size 4 with sum 15. (b) Size 7 with sum 32. (c) Size 8 with sum 35.
Solution:
(a) We have: k = 4, N0 = 1 + 2 + 3 + 4 = 10 and Nn = 15 and hence n = Nn − N0 = 15 − 10 = 5. The
coefficient c5 of the Taylor series of fg (z, 4) is 6 and hence Ns (4, 15) = c5 = 6. These 6 sets are:
{1,2,3,9} {1,2,4,8} {1,2,5,7} {1,3,4,7} {1,3,5,6} {2,3,4,6}
(b) We have: k = 7, N0 = 1+2+3+4+5+6+7 = 28 and Nn = 32 and hence n = Nn −N0 = 32−28 = 4.
The coefficient c4 of the Taylor series of fg (z, 7) is 5 and hence Ns (7, 32) = c4 = 5. These 5 sets are:
{1,2,3,4,5,6,11} {1,2,3,4,5,7,10} {1,2,3,4,5,8,9} {1,2,3,4,6,7,9} {1,2,3,5,6,7,8}
(c) We have: k = 8, N0 = 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 = 36 and Nn = 35. Since Nn < N0 we have zero
set, i.e. Ns (8, 35) = 0.
[29] The combinatorics method is rather messy and requires lengthy explanation and hence we leave it (noting that we may
discuss it in the future). We refer the reader to the literature about the topics of sequence representation and generation
using the generating function and z-transform techniques (noting that these topics are out of scope of our book which is
about number theory).
2 MISCELLANEOUS 41
6. Find all the partitions of the following set into two disjoint subsets such that the product of the members
of one subset is equal to the product of the members of the other subset:
{49, 27, 3125, 32, 243, 8, 343, 9, 16807, 25, 125, 4}
Solution: We prime-factorize these numbers so that we can group and partition them in a way that
ensures that the number of prime factors (i.e. of any given prime number) in each subset is the same
as the number of prime factors in the other subset, that is:
{72 , 33 , 55 , 25 , 35 , 23 , 73 , 32 , 75 , 52 , 53 , 22 }
So we must have 22 , 23 (i.e. 4, 8) in one subset and 25 (i.e. 32) in the other, 32 , 33 (i.e. 9, 27) in one
subset and 35 (i.e. 243) in the other, 52 , 53 (i.e. 25, 125) in one subset and 55 (i.e. 3125) in the other,
and 72 , 73 (i.e. 49, 343) in one subset and 75 (i.e. 16807) in the other. So, we can do this partitioning
in 8 possible ways, i.e.
{4, 8, 9, 27, 25, 125, 49, 343}{32, 243, 3125, 16807} {4, 8, 9, 27, 25, 125, 16807}{32, 243, 3125, 49, 343}
{4, 8, 243, 25, 125, 49, 343}{32, 9, 27, 3125, 16807} {4, 8, 243, 25, 125, 16807}{32, 9, 27, 3125, 49, 343}
{4, 8, 9, 27, 3125, 49, 343}{32, 243, 25, 125, 16807} {4, 8, 9, 27, 3125, 16807}{32, 243, 25, 125, 49, 343}
{4, 8, 243, 3125, 49, 343}{32, 9, 27, 25, 125, 16807} {4, 8, 243, 3125, 16807}{32, 9, 27, 25, 125, 49, 343}
7. Find all natural numbers of the form n + 3n + 1 which terminate in 2021 (where n ∈ N0 ).
2
10000
Solution: These numbers are the solutions of the congruence equation n2 + 3n + 1 = 2021, i.e.
n = m + 10000k where m = 2732, 4140, 5857, 7265 and k ∈ N0 .
8. Propose a simple way for the prime factorization of factorials (which should be very useful, and possibly
the only practical way, for the prime factorization of very large factorials).
Solution: We propose using the formula of the highest power of a prime p that divides n! (see Eq. 83
in V1) where p represents all the primes which are less than or equal to n. These calculations can be
easily done using a spreadsheet or a few lines of computer code. For example, let us find the prime
factorization of 123!.
On using the aforementioned formula (with p representing all the 30 primes which are less than 123,
i.e. 2, 3, 5, . . . , 107, 109, 113) we obtain the following prime factorization:
123! = 2117 × 359 × 528 × 719 × 1112 × 139 × 177 × 196 × 235 × 294 × 313 × 373 × 413 × 432 × 472 × 532 ×
592 × 612 × 67 × 71 × 73 × 79 × 83 × 89 × 97 × 101 × 103 × 107 × 109 × 113.
9. Propose a simple way for calculating the number of digits of factorials (which should be very useful,
and possibly the only practical way, for calculating the number of digits of very large factorials).
Solution: The simplest way is to use the rules of logarithms, that is:
n
! n
Y X
log10 (n!) = log10 k = log10 (k)
k=1 k=1
where the latter sum can be easily calculated using a spreadsheet or a few lines of computer code.
Hence, the number of digits in n! is: $ n %
X
log10 (k) + 1
k=1
For example, the number of digits of 1000! is:
$1000 %
X
log10 (k) + 1 = ⌊2567.604644⌋ + 1 = 2568
k=1
11. What is the number of digits in Prn and Crn (where Prn is the number of permutations and Crn is the
binomial coefficient).
Solution: Regarding Prn we have:
n!
Prn = = n × (n − 1) × · · · × (n − r + 1)
(n − r)!
723
For example, the number of digits of P288 is:
$ 723
% $ 723 %
X X
log10 (k) + 1 = log10 (k) + 1 = ⌊794.448⌋ + 1 = 795
k=723−288+1 k=436
n! n × (n − 1) × · · · × (n − r + 1)
Crn = =
r!(n − r)! r!
2109
For example, the number of digits of C1562 is:
$ 2109 1562
%
X X
log10 (k) − log10 (k) + 1 = ⌊4834.723 − 4312.157741⌋ + 1 = ⌊522.566⌋ + 1 = 523
k=548 k=1
12. Find every 10-digit integer the sum of its digits is equal to the product of its digits.
Solution: Let S be the sum of digits and P the product of digits. We have 3 main cases:
• S = P = 0: since P = 0 then at least one of the digits must be 0 and hence all the digits must be 0
so that S = 0. So, we have only one possibility which is 0000000000.
• S = P = 16: we have 1111111144 and its permutations which are 45 in total.[30]
• S = P 6= 0, 16: we have no 10-digit integer that satisfies this condition because no factorization of P
(noting that 1 ≤ S ≤ 90 excluding 16) can satisfy the condition S = P .
So, we have 45 permutations of 1111111144 as well as 0000000000, i.e. 46 such integers. Now, if we
consider the negatives of the 45 permutations of 1111111144 then we should have 91 such integers.
13. Identify (or characterize) the integers which have the following number of positive divisors (exactly):
(a) Infinitely many. (b) Zero. (c) One. (d) Two. (e) Three. (f ) Four. (g) Five.
Solution:
(a) Only 0 (because 0 can be divided by any other integer).
(b) None (because any integer can be divided at least by 1).
[30] The 10!
permutations of eight 1’s and two 4’s are given by the multinomial coefficient 2! 8!
= 45.
2 MISCELLANEOUS 43
(c) Only ±1 (because if a|b and b 6= 0 then |a| ≤ |b| and hence ±1 can be divided only by 1 noting that
any other non-zero integer can be divided by 1 and by its absolute value).
(d) Primes (because by definition a prime number can be divided only by 1 and itself).
(e) Squares of primes (because the divisors of p2 where p ∈ P are only 1, p and p2 ).
(f ) Cubes of primes (because the divisors of p3 where p ∈ P are only 1, p, p2 and p3 ). Also, composite
numbers of the form p1 p2 where p1 , p2 ∈ P and p1 6= p2 (because the divisors of p1 p2 are only 1, p1 , p2
and p1 p2 ).
(g) Fourth powers of primes (because the divisors of p4 where p ∈ P are only 1, p, p2 , p3 and p4 ).
14. Find all x, y ∈ Z such that xy = y x .
Solution: An obvious solution is x = y. So, in the following we search for solutions where x 6= y.
In Problem 5 of § 7.3 we find that xy > y x for all 2 < x < y. We also find that xy < y x when
(x, y) = (1, y) where N ∋ y > 1. So, assuming x, y ∈ N and x < y, the only possibility for xy = y x
is for x = 2, that is: 2y = y 2 whose only solution (assuming x 6= y) is y = 4. So, another solution
to xy = y x is (x, y) = (2, 4). Now, if we lift the restriction that x < y (noting the symmetry in
x, y) as well as the restriction that x, y ∈ N (noting that 2 and 4 are even) then we get three more
solutions, i.e. (x, y) = (4, 2), (−2, −4), (−4, −2). So in brief, the solutions of xy = y x (where k ∈ Z) are:
(x, y) = (k, k) (x, y) = (2, 4) (x, y) = (4, 2) (x, y) = (−2, −4) (x, y) = (−4, −2)
15. Conduct an initial check on the following integers to see if they can be perfect numbers or not:
(a) 348923082239. (b) 5762859329434. (c) 116398323238.
Solution:
(a) All known perfect numbers (up to very large integers) are even and hence this cannot be a perfect
number because it is odd.
(b) All even perfect numbers end in 6 or 8 (see point 6 of § 2.8 of V1) and hence this cannot be a
perfect number because it ends in 4.
(c) All even perfect numbers (excluding 6) end in 16, 28, 36, 56, 76, or 96 (see point 7 of § 2.8 of V1)
and hence this cannot be a perfect number because it ends in 38.
16. Show that xy = yz = xz iff x = y = z (where Z ∋ x, y, z 6= 0).[31]
Solution: Regrading the if part, if x = y = z then xy = 1, yz = 1 and xz = 1 and hence xy = yz = xz = 1.
Regrading the only if part, we prove this part by contraposition where we first consider the case of
x, y, z ∈ N. So, let assume that the triple equality x = y = z does not hold. This means that one of
the variables x, y, z must be greater than another one of these variables. So, let assume (without loss of
generality since it is a matter of labeling) that x is the greater variable. Hence, (with a proper labeling
of y and z) we have one of the following three cases:
• x = y > z and hence xy 6= yz since xy = 1 while yz > 1.
• x > y = z and hence xy 6= yz since xy > 1 while yz = 1.
• x > y > z and hence xy 6= xz since xy > 1 while xz < 1.
So, in all cases the triple equality xy = yz = xz does not hold if the triple equality x = y = z does
not hold, and hence by contraposition the triple equality x = y = z does hold if the triple equality
x y z x y z
y = z = x does hold, i.e. if y = z = x then x = y = z.
We finally need to extend from x, y, z ∈ N to Z ∋ x, y, z 6= 0. Now, we have four cases:
• All x, y, z are greater than 0: this is the case of x, y, z ∈ N which is already considered.
• All x, y, z are less than 0: this is equivalent to the previous case because the minus sign will be
canceled (or rather it has no effect because the ratio of two positive numbers is the same as the ratio
of their negatives).
• Only one of x, y, z is less than 0: so assume (with no loss of generality) that x < 0 and hence xy and
z y
x are negative while z is positive and hence they cannot be equal.
• Only one of x, y, z is greater than 0: so assume (with no loss of generality) that x > 0 and hence xy
and xz are negative while yz is positive and hence they cannot be equal.
Hence, the proposition applies to all Z ∋ x, y, z 6= 0 and not only to x, y, z ∈ N.
[31] The purpose of such “trivial” questions is to learn systematic investigation and analysis.
Chapter 3
Primes, Composites and Coprimes
1. Find all prime numbers of the following forms:
(a) n3 + 3n2 + 5n + 6 (n ∈ Z). (b) 3n ± 1 (n ∈ N0 ). (c) 4n+2 + 2n (n ∈ N0 ).
Solution:
3
(a) This expression is divisible by 3 for all n ∈ Z (noting that n3 + 3n2 + 5n + 6 = 0 identically). Hence,
it is composite except if it is equal to 0 (which is neither composite nor prime) or 3 (which is prime).
So, if this expression is to be prime then we must have n3 + 3n2 + 5n + 6 = 3 for some n ∈ Z. This
equation has a solution n = −1 and hence 3 is the only prime number of this form (corresponding to
n = −1).
(b) 3n ± 1 is even for all n ∈ N0 and hence it is prime only when it is equal to 2 (corresponding to
n = 0 for 3n + 1 and to n = 1 for 3n − 1).
(c) 4n+2 + 2n is even and greater than 2 for all n ∈ N0 except when n = 0 where it is equal to 17.
Hence, 17 is the only prime number of this form (corresponding to n = 0).
2. Find all prime numbers of the following forms: aa, abab, abcabc, abcdabcd, abcdeabcde, abcdef abcdef
(where a, b, c, d, e, f are digits and a 6= 0).
Solution: All integers of the form aa are divisible by 11 and hence they are all composite except 11
itself. Regarding the other forms we have:
abab = 101 × ab abcabc = 1001 × abc abcdabcd = 10001 × abcd
abcdeabcde = 100001 × abcde abcdef abcdef = 1000001 × abcdef
Hence, they are all composite. So, the only prime of the given forms is 11.
3. Let n = 9m + 6 (m ∈ N) and τ (n) = 4 (where τ is the tau function). Show that 3m + 2 is prime.
Solution: We have:[32]
k
Y
τ (n) = (ai + 1) = 4 = 2 × 2
i=1
i.e. k = 2 and a1 = a2 = 1. This means that n is square free with two prime factors, that is:
n = 9m + 6 = 3(3m + 2) = 3p where p = 3m + 2 is prime.
4. Investigate the prime numbers of the following form:
n times
z }| {
p = m . . . mm (m, n ∈ N, n > 1)
where mm means concatenation not multiplication
Solution: If k is the number of digits of m then we can write:
p = 10k(n−1) m + · · · + 10k m + 100 m = m(10k(n−1) + · · · + 10k + 100 )
This is obviously composite if m > 1 since (10k(n−1) + · · · + 10k + 100 ) > 1 (noting that n > 1). Hence,
to have a prime we must have m = 1 and thus p = (10n−1 + · · · + 101 + 100 ) = 1 . . . 11. Now, for n = 2
we have 1 . . . 11 = 11 which is prime. Regarding n > 2, if n is even then 1 . . . 11 is divisible by 11 (see
rule 33 of § 1.9 of V1), while if n is a natural multiple of 3 then 1 . . . 11 is divisible by 3 (see rule 25 of
§ 1.9 of V1) and hence they cannot be prime. In fact, the primality of the natural numbers of the form
1 . . . 11 is a research issue. Those who are interested in further details should refer to the problem of
repunit numbers (i.e. repeated unit numbers such as 11, 111, 1111) in the literature noting that there
are several known repunit primes (other than 11).
[32] We note that n = p3 is not a possibility because p3 = 9m + 6 (i.e. 3m + 2 = 9) has no solution.
44
3 PRIMES, COMPOSITES AND COPRIMES 45
Now, a prime number p can be factorized as a product of three integer factors only in 3 different ways,
i.e.
p = (1)(−1)(−p) = (1)(1)(p) = (−1)(−1)(p)
So, if f = p then we have 3 cases to consider:
First case: f = (1)(−1)(−p) and hence one of the factors (m − n), (3m − 2n), (2m − 3n) must be equal
to 1 and another factor of these must be equal to −1. So, if we consider the 6 systems of simultaneous
equations obtained from equating (m − n), (3m − 2n), (2m − 3n) to 1 combined with the equations
obtained from equating (m − n), (3m − 2n), (2m − 3n) to −1 (noting that a single factor cannot be
[33] We should note that if “composite” is restricted (by definition) to natural numbers (see § 2.2. of V1) then we should
exclude all the negatives. We may also add: n5 + 1 is prime for n = 1 and neither prime nor composite for n = −2, −1, 0
(noting the sign of −31 in the case of n = −2).
[34] If we consider −5 as well (by ignoring the sign) then we can also confirm that this expression is not equal to −5.
3 PRIMES, COMPOSITES AND COPRIMES 46
equal to 1 and −1 at the same time) then we can identify m and n values
that can possibly make
f = p.
These 6 systems with their solutions and the corresponding values of f in the form (m, n, f ) are given
in the following table:
m − n = 1 3m − 2n = 1 2m − 3n = 1
m − n = −1 (3, 4, 6) (−4, −3, 6)
3m − 2n = −1 (−3, −4, −6) (−1, −1, 0)
2m − 3n = −1 (4, 3, −6) (1, 1, 0)
As we see, f = 0, ±6 in this case and hence it is not prime.
Second case: f = (1)(1)(p) and hence if we follow the argument and procedure of the first case then
we get the following table (where NS means “No Solution”):
m − n = 1 3m − 2n = 1 2m − 3n = 1
m−n=1 (−1, −2, 4) (2, 1, 4)
3m − 2n = 1 NS
2m − 3n = 1
As we see, f = 4 in this case and hence it is not prime.
Third case: f = (−1)(−1)(p) and hence if we follow the argument and procedure of the first case then
we get the following table:
m − n = −1 3m − 2n = −1 2m − 3n = −1
m − n = −1 (1, 2, −4) (−2, −1, −4)
3m − 2n = −1 NS
2m − 3n = −1
As we see, f = −4 in this case and hence it is not prime.
So, in all cases f cannot represent a prime number and hence there are no prime numbers of the given
form.
8. Show that the gap between two successive prime numbers can be arbitrarily large.
Solution: It was shown in Problem 8 of § 6.15 of V1 that for any n ∈ N there are n consecutive
composite numbers. This implies that the gap between prime numbers can be arbitrarily large. So,
although there is a lower limit on the size of the gap between two successive prime numbers (i.e. 1 in
the case of twin primes noting the exception of 2, 3) there is no upper limit on the size of this gap.
9. Determine if the following pairs of polynomials are coprime for all n ∈ N, or coprime for none of n ∈ N,
or coprime for only some of n ∈ N:
(a) 2n2 − 1 and 5n2 − 3. (b) 4n3 − 1 and 7n4 + 5. (c) n5 + 10n4 − n = 0 and 3n9 − n.
Solution:
(a) By Bezout theorem we have:
gcd(2n2 − 1, 5n2 + 3) = 5(2n2 − 1) − 2(5n2 − 3) = 1
Thus, these polynomials are coprime for all n ∈ N.
(b) For example, these polynomials are coprime for n = 2 and not coprime for n = 1. Thus, these
polynomials are coprime for only some of n ∈ N.
(c) These polynomials are even for all n ∈ N and hence they are coprime for none of n ∈ N.
10. Find all p, q ∈ P such that 5p2 − 8pq + 11q 2 = 1175.
Solution: If we treat this equation as a quadratic in p with a discriminant ∆ then we have:
r
23500
∆ = 64q 2 − 20(11q 2 − 1175) = −156q 2 + 23500 ≥ 0 → q≤ ≃ 12.27
156
So, we need to consider only q = 2, 3, 5, 7, 11. On substituting these values in the given equation and
solving for p (accepting only prime values for p) we get: (p, q) = (2, 11) which is the only solution to
this Problem.
11. Find all p, q, r ∈ P such that:
(a) p(q − r) = 2(q + r). (b) p(q + r) = 5(q − r).
3 PRIMES, COMPOSITES AND COPRIMES 47
Solution:
(a) It is obvious that q 6= r because 2(q + r) > 0. Also, p 6= 2 because q − r 6= q + r (since it leads to
r = 0). So, p is an odd prime. Moreover, (q − r) must be even (because of the 2 on the RHS) and hence
both q and r are odd primes. So in brief, p, q, r are odd primes. Rewriting the equation as (noting that
q + r is even and p is odd):
2(q + r)
p=
q−r
we conclude that (q − r) is a multiple of 4. So, based on this equation we can write:
p(q − r) p 4 (pa1 1 . . . pakk )
q − r = 4 (pa1 1 . . . pakk ) q+r = = = 2p (pa1 1 . . . pakk )
2 2
Now:
• If we add these equations we get:
2q = 4 (pa1 1 . . . pakk ) + 2p (pa1 1 . . . pakk ) → q = (pa1 1 . . . pakk ) (2 + p) → pa1 1 . . . pakk = 1 →
q =2+p → p=q−2
where step 2 is because if q = pa1 1 . . . pakk (noting that q is prime) then 2 + p = 1 (i.e. p = −1) which is
impossible.
• If we subtract these equations we get:
2r = 2p (pa1 1 . . . pakk ) − 4 (pa1 1 . . . pakk ) → r = (pa1 1 . . . pakk ) (p − 2) → pa1 1 . . . pakk = 1 →
r =p−2 → p=r+2
a1 ak
where step 2 is because if r = p1 . . . pk (noting that r is prime) then p − 2 = 1 (i.e. p = 3) which is
impossible because q will be 5 (since p = q − 2) and hence r = 1 (which is nonsensical since r is prime).
So in brief, we have p = q − 2 and p = r + 2. Now, if we remember that 5 is the only prime number
that is shared by two different pairs of twin primes (see point 3 in the preamble of § 2.2.1 of V1), then
we can conclude that (p, q, r) = (5, 7, 3) which is the only solution to the given equation.
(b) If we write this equation as 5(q − r) = p(q + r) and compare it to the equation of part (a) noting
its unique solution then we can conclude that (p, q, r) = (2, 7, 3). However, let assume that we do not
have part (a) and its solution and hence we solve this equation from scratch.
It is obvious that q > r (since the LHS is > 0). Now, since (q + r) > (q − r) then p < 5 and hence we
have only two possibilities:
• p = 2 and hence we have 2(q + r) = 5(q − r) which simplifies to 3q = 7r. So, 3 divides r and hence
r = 3 (noting that r is prime) and q = 7. Thus, we have the solution (p, q, r) = (2, 7, 3).
• p = 3 and hence we have 3(q + r) = 5(q − r) which simplifies to q = 4r, i.e. q is composite and hence
it is unacceptable.
Accordingly, the only solution to the given equation is (p, q, r) = (2, 7, 3).
12. Find solutions to the following equation: p2 (q − r) = 12(q + r) where p, q, r ∈ P.
Solution: p 6= 2 because 4(q − r) < 12(q + r). p 6= 3 because 9(q − r) < 12(q + r). Hence, p is an odd
prime ≥ 5.
On comparing the two sides of the given equation we must have:
q − r = 12 (pa1 1 . . . pakk ) q + r = p2 (pa1 1 . . . pakk )
On adding and subtracting these equations we get:
(p2 + 12) (pa1 1 . . . pakk ) (p2 − 12) (pa1 1 . . . pakk )
q= r=
2 2
Now, since p is odd then p2 +12 and p2 −12 are odd (i.e. they are not divisible by 2) and hence 2 divides
pa1 1 . . . pakk . Moreover, since p2 + 12 and p2 − 12 are greater than 1 (since p ≥ 5) then pa1 1 . . . pakk must
be equal to 2 (noting that q and r are primes). Therefore, we must have q = p2 + 12 and r = p2 − 12.
On inspecting the low values of p we found the following solutions, i.e. (p, q, r):
(5,37,13) (7,61,37) (13,181,157) (19,373,349) (29,853,829) (41,1693,1669) (61,3733,3709)
3 PRIMES, COMPOSITES AND COPRIMES 48
13. Investigate the prime numbers of the following forms (where n ∈ N):
(a) n2 − 1. (b) n2 + 1. (c) n3 − 1. (d) n3 + 1. (e) n2 − 2.
Solution:
(a) n2 − 1 = (n − 1)(n + 1) which is composite for all n > 2. For n = 1 we have n2 − 1 = 0 (which is
not prime), while for n = 2 we have n2 − 1 = 3 (which is prime). So, the only prime of the form n2 − 1
is 3.
(b) There are many primes of the form n2 + 1 (e.g. 2, 5, 17) and it is conjectured that there are
infinitely many primes of this form.
(c) n3 − 1 = (n − 1)(n2 + n + 1) and hence it is composite for all n > 2. For n = 1 we have n3 − 1 = 0
(which is not prime), while for n = 2 we have n3 − 1 = 7 (which is prime). So, the only prime of the
form n3 − 1 is 7.
(d) The only prime of the form n3 + 1 is 2 (corresponding to n = 1) because n3 + 1 = (n + 1)(n2 − n + 1)
which is composite for all n > 1.
(e) If n is even then the only prime of this form is 2 (corresponding to n = 2) because n2 − 2 is even.
If n is odd then we have many primes of this form (e.g. 7, 23, 47) and it is conjectured that there are
infinitely many of them.
14. Show that any divisor of a Mersenne number Mp = 2p − 1 (where p is an odd prime) is of the form
2kp + 1 (where k ∈ N).
Solution: Let q be a prime number dividing Mp (and hence q is odd since Mp is odd). Now, by
Fermat’s little theorem we have q|(2q−1 − 1). Moreover:
Noting that q supposedly divides both 2p −1 and 2q−1 −1, q must divide their gcd which is 2gcd(p,q−1) −1
(see Problem 10 of § 2.4 of V1). Now, since q is an odd prime then gcd(p, q − 1) > 1 which implies
gcd(p, q − 1) = p, i.e. p is a factor of q − 1 and hence p|(q − 1). So, we can write q − 1 = sp where s must
be an even natural number because q − 1 is even (noting that q is an odd prime as indicated earlier and
because p divides q − 1). Hence, we can write q = 2kp + 1 (where k ∈ N). This means that any prime
divisor of Mp is of the form 2kp + 1. However, this should apply even to the composite divisors of Mp
because the composite divisor is a product of prime factors where each one of these prime factors is of
the form 2kp + 1 and hence their product must be of this form, e.g.
Note 1: the theorem of this Problem can be used to prove that there are infinitely many primes because
if there are only finitely many primes with p being the largest of them then Mp (which must be greater
than p) is composite. However, according to the theorem of this Problem any prime divisor of Mp must
be of the form 2kp + 1 which must be greater than p in contradiction to the claim that p is the largest
prime.[35]
Note 2: the theorem of this Problem is very useful for the search of Mersenne primes (or composites)
since it can be used to accelerate the search for Mersenne primes. The idea is that Mersenne numbers
which are composite are divisible only by factors of the form 2kp + 1. This restriction on the form
of divisors limits the possibilities of potential divisors substantially, i.e. if a Mersenne number is not
divisible by any factor of the form 2kp + 1 then it must be prime (otherwise it is composite). This will
be illustrated in Problem 15.
[35] Itis worth noting that we can find many proofs in the literature about the infinitude of primes, e.g. the proof of Euclid
which we discussed in Problem 12 of § 2.2 of V1 and the proof about the coprimality of Fermat numbers which we
discussed in Problem 7 of § 2.2.3 of V1 (as well as the proof indicated in the present note; also see Problem 18). These
proofs can be classified as direct proofs (i.e. they are intended to prove the infinitude of primes; e.g. the proof of Euclid)
and indirect proofs (i.e. they are intended to prove something else but their outcome implies the infinitude of primes;
e.g. the proof of Problem 7 of § 2.2.3 of V1 and the proof of the present note). In fact, some of the proofs of propositions
about the infinitude of primes of certain forms and types are also proofs of the infinitude of primes (assuming that these
proofs do not presume the infinitude of primes or based on such presumption).
3 PRIMES, COMPOSITES AND COPRIMES 49
15. Determine if the following Mersenne numbers are prime or composite: M17 and M23 . √
Solution: Regrading M17 , we need to test only the primes of the form 34k+1 which are < M17 ≃ 362,
i.e. p = 103, 137, 239, 307. None of these primes divides M17 and hence M17 is a Mersenne
√ prime.
Regrading M23 , we need to test only the primes of the form 46k + 1 which are < M23 ≃ 2896. The
first of these primes is 47 which divides M23 and hence M23 is a composite Mersenne number (with no
need for doing more tests).
16. Let m and n be coprime integers. Show that 2m + n and 3m + 2n are coprime.
Solution: Let A = 2m + n and B = 3m + 2n. Accordingly:
2A − B = m and 2B − 3A = n
Now, if we note that m and n are coprime and we use the rules of gcd (as given in the preamble of §
2.4 of V1) then we have:
50
4 REPRESENTATION OF NUMBERS 51
which means that f (n) is not a perfect square (as in the previous point).
So in brief, f (n) is a perfect square only for n = 0 and n = 1.
(b) If we follow the method of part (a) then we conclude that g(n) is a perfect cube only for n = 0
because:
(n − 1)3 < (n3 + 3n + 1) < n3 (for n < 0) & n3 < (n3 + 3n + 1) < (n + 1)3 (for n > 0)
noting that there is no perfect cube between two consecutive perfect cubes.
(c) Because h(n) is a perfect square, we have n2 + 3n − 1 = m2 (where m ∈ Z). Hence (noting that
N = 2n and M = 2m):
4n2 + 12n − 4 = 4m2 → 4n2 + 12n = 4m2 + 4 → N 2 + 6N = M 2 + 4 →
N 2 + 6N + 9 = M 2 + 13 → (N + 3)2 = M 2 + 13 → (N + 3)2 − M 2 = 13 →
(N + 3 − M )(N + 3 + M ) = 13 →
Noting that 13 = (−1)(−13) = (1)(13) and considering all the 4 possibilities (i.e. with regard to equat-
ing the factors on the two sides in both orders), we get 4 systems of equations in N and M . On solving
these systems we get: (N, M ) = (−10, −6), (−10, 6), (4,6), (4, −6). So, h(n) is a perfect square only
for n = −5 and n = 2 (corresponding to m2 = 9).
6. Find all x, y ∈ N0 such that x2 + 4y and y 2 + 4x are both perfect squares.
Solution: We have four cases to consider:
• x = y = 0 and hence (x, y) = (0, 0).
• x = 0 and y 6= 0, i.e. 4y and y 2 are perfect squares. Noting that 4 is a perfect square, any y = k 2
(k ∈ Z) is a valid solution. Hence, (x, y) = (0, k 2 ).
• x 6= 0 and y = 0: from the previous point (noting the symmetry) we have (x, y) = (k 2 , 0).
• x > 0 and y > 0 and hence:[36]
(x + 1)2 ≤ (x2 + 4y) → (x2 + 2x + 1) ≤ (x2 + 4y) → (2x + 1) ≤ 4y
Now, 2x+1 is odd while 4y is even and hence the equality is not possible. Accordingly, we must have:[37]
(x + 2)2 ≤ (x2 + 4y) → (x2 + 4x + 4) ≤ (x2 + 4y) → (x + 1) ≤ y
By a similar argument (or by symmetry) we must also have (y + 1) ≤ x. However, this contradicts
(x + 1) ≤ y because (x + 1) ≤ y implies x < y while (y + 1) ≤ x implies y < x. This contradiction
means that we have no solution in this case.
So in brief, x2 + 4y and y 2 + 4x are both perfect squares only for (x, y) = (0, k 2 ) and (x, y) = (k 2 , 0)
where k ∈ Z.
7. Let A ≡ x2 + y + z, B ≡ x + y 2 + z and C ≡ x + y + z 2 (where x, y, z ∈ Z). Show that A, B, C cannot
be perfect squares simultaneously if:
(a) All of x, y, z are > 0. (b) One of x, y, z is < 0 and the other two are > 0.
(c) Exactly one of x, y, z is 0.
Solution: We note first that no perfect square can lie between consecutive squares, i.e. the squares of
two consecutive integers. For example, if k is an integer then there is no perfect square between k 2 and
(k + 1)2 or between k 2 and (k − 1)2 .
(a) This is because x2 and (x + 1)2 are consecutive squares and hence if A is a perfect square then it
cannot lie between them. This similarly applies to B with regard to y 2 and (y + 1)2 and to C with
regard to z 2 and (z + 1)2 . Now, if we note that A, B, C are greater than x2 , y 2 , z 2 (respectively) then
we must have:
(x + 1)2 ≤ (x2 + y + z) → (2x + 1) ≤ (y + z)
[36] In this argument we are using the fact that no perfect square can lie between consecutive squares, i.e. the squares of two
consecutive integers. For example, if k is an integer then there is no perfect square between k2 and (k + 1)2 or between
k2 and (k − 1)2 . In brief, x2 < (x2 + 4y), moreover (x2 + 4y) cannot be between x2 and (x + 1)2 and hence we must
have (x + 1)2 ≤ (x2 + 4y).
[37] Again, we are using the fact that no perfect square can lie between consecutive squares, i.e. (x + 1)2 < (x2 + 4y),
moreover (x2 + 4y) cannot be between (x + 1)2 and (x + 2)2 and hence we must have (x + 2)2 ≤ (x2 + 4y).
4 REPRESENTATION OF NUMBERS 52
(y + 1)2 ≤ (x + y 2 + z) → (2y + 1) ≤ (x + z)
2 2
(z + 1) ≤ (x + y + z ) → (2z + 1) ≤ (x + y)
Now, if we add the three inequalities on the right (side by side) we obtain:
which is nonsensical. So, we conclude that A, B, C cannot be perfect squares simultaneously if all of
x, y, z are > 0.
(b) Noting the symmetry in the variables, it is sufficient to consider the case of x < 0 and y, z > 0.
Moreover, we can assume (with no loss of generality) that y ≤ z. Now, we have three cases:
• |x| < y and hence:
On adding the three inequalities on the right (side by side) and simplifying we obtain −4x + 3 ≤ 0
which is nonsensical noting that x < 0.
• y ≤ |x| ≤ z and hence:
Now, the first inequality minus the second inequality plus the third inequality lead to 2y ≤ 0 which is
nonsensical noting that y > 0.
• |x| > z and hence:
On adding the three inequalities on the right (side by side) we obtain 1 ≤ 0 which is nonsensical.
So, we conclude that A, B, C cannot be perfect squares simultaneously if one of x, y, z is < 0 and the
other two are > 0.
(c) Let us assume that only x = 0 (noting that the cases of only y = 0 and only z = 0 can be obtained
from the case of only x = 0 due to the symmetry of A, B, C in the variables x, y, z). This means that
(y + z), (y 2 + z) and (y + z 2 ) are perfect squares. Now, y and z cannot be both < 0 because (y + z) is
supposedly a perfect square. So, we must have either y, z > 0 or one of y, z is > 0 and the other is < 0.
Accordingly:
• y, z > 0 and hence:
(y + 1)2 ≤ (y 2 + z) → (2y + 1) ≤ z
2
(z + 1) ≤ (y + z 2 ) → (2z + 1) ≤ y
On adding the two inequalities on the right (side by side) and simplifying we obtain (y + z + 2) ≤ 0
which is nonsensical noting that y, z > 0.
• y > 0 and z < 0 and hence:
(y 2 + z) ≤ (y − 1)2 → z ≤ (−2y + 1)
(z − 1)2 ≤ (y + z 2 ) → (−2z + 1) ≤ y
4 REPRESENTATION OF NUMBERS 53
On adding the two inequalities on the right (side by side) and simplifying we obtain −z ≤ −y which is
nonsensical noting that y > 0 and z < 0.
• y < 0 and z > 0: this is similar to the previous case (noting the symmetry).
So, we conclude that A, B, C cannot be perfect squares simultaneously if exactly one of x, y, z is 0.
8. Let A ≡ x2 + y + z, B ≡ x + y 2 + z and C ≡ x + y + z 2 (where x, y, z ∈ Z). Investigate (with regard to
the sign of x, y, z) the possibility of A, B, C being perfect squares simultaneously.
Solution: We have eight cases:
• All of x, y, z are 0: this is possible because 0 is a perfect square.
• Two of x, y, z are 0 and the other is positive: this is possible, i.e. (x, y, z) = (k 2 , 0, 0), (0, k 2 , 0),
(0, 0, k 2 ) where k ∈ Z.
• Two of x, y, z are 0 and the other is negative: this is impossible because (where we exploit the
symmetry to generalize the argument) if x < 0 and y = z = 0 then A is a perfect square but B and C
cannot be perfect squares because they are negative.
• Exactly one of x, y, z is 0: this is impossible (see part c of Problem 7).
• All of x, y, z are < 0: this is possible, e.g. (x, y, z) = (−3, −4, −4), (−2, −2, −2).
• Two of x, y, z are < 0 and the other is > 0: this is possible, e.g. (x, y, z) = (2, −2, −2).
• One of x, y, z is < 0 and the other two are > 0: this is impossible (see part b of Problem 7).
• All of x, y, z are > 0: this is impossible (see part a of Problem 7).
9. Find all a, b ∈ Z such that (a + b), (a2 + b), (a + b2 ) are all perfect squares.
Solution: According to part (c) of Problem 7 these cannot be perfect squares simultaneously if ab 6= 0.
So, the only possibility of these being perfect squares simultaneously is when ab = 0, i.e. (a, b) = (k 2 , 0)
and (a, b) = (0, k 2 ) where k ∈ Z.
10. Find all n ∈ Z such that 4n4 + 8n3 + 12n2 + 8n + 4 is a perfect square.
Solution: We have:
4n4 + 8n3 + 12n2 + 8n + 4 = 4 n4 + 2n3 + 3n2 + 2n + 1
= 4 n4 + 2n3 + 2n2 + n2 + 2n + 1
h 2 i
= 4 n2 + 2n2 (n + 1) + (n + 1)2
2 2 2
= 4 n2 + (n + 1) = 22 n2 + n + 1 = 2 n2 + n + 1
The solution of the last inequality is n < −2 and n > 0. This means that n3 + 2n2 + n + 1 cannot be a
perfect cube if n < −2 or n > 0 because it is between two perfect cubes, and hence n3 + 2n2 + n + 1 can
possibly be a perfect cube only for n = −2, −1, 0. On testing these values we find that n3 + 2n2 + n + 1
is a perfect cube for all these values, (i.e. n = −2, −1, 0) and hence these are the solutions to our
Problem.
12. Find every integer n that has the following forms simultaneously: n = 5 + 14k, n = 3 + 23s and
n = 7 + 33t (where k, s, t ∈ Z).
Solution: We are required to solve the following system of simultaneous congruence equations:
14 23 33
n=5 n=3 n=7
4 REPRESENTATION OF NUMBERS 54
10626
The solution of this system (which can be obtained by the Chinese remainder theorem) is n = 2119.
So, every n = 2119 + 10626u (where u ∈ Z) meets the stated requirement.
13. Find all n ∈ N0 such that the following expressions are perfect cubes:
(a) n! + 5. (b) n! + 7. (c) n! − 14.
Solution:
7
(a) This is equivalent to solving the Diophantine equation m3 = n! + 5. Now, for n > 6 we have n! = 0
7 7
and hence m3 = 5. However, m3 = 5 has no solution. So, if there is any solution then we must have
0 ≤ n ≤ 6. On testing these values of n we find that only n = 5 is a solution. So, n! + 5 is a perfect
cube only for n = 5.
9
(b) This is equivalent to solving the Diophantine equation m3 = n! + 7. Now, for n > 8 we have n! = 0
9 9
and hence m3 = 7. However, m3 = 7 has no solution. So, if there is any solution then we must have
0 ≤ n ≤ 8. On testing these values of n we find that only n = 0, 1 are solutions. So, n! + 7 is a perfect
cube only for n = 0, 1.
4
(c) This is equivalent to solving the Diophantine equation m3 = n! − 14. Now, for n > 3 we have n! = 0
4 4
and hence m3 = −14. However, m3 = −14 has no solution. So, if there is any solution then we must
have 0 ≤ n ≤ 3. On testing these values of n we find that only n = 3 is a solution. So, n! − 14 is a
perfect cube only for n = 3.
14. Show that (n5 − 4) cannot be a perfect square for any n ∈ Z.
Solution: For n < 2 we have (n5 −4) < 0 and hence it cannot be a perfect square. Regarding n ≥ 2, we
note that being a perfect square is equivalent to m2 = n5 − 4 for some m ∈ Z. However, this equation
has no solution.[38] Hence, (n5 − 4) cannot be a perfect square for any n ∈ Z.
15. Find all the natural numbers which can be expressed as n3 + 5n − 1807 and end in 1121.
Solution: These numbers are the solutions of the following congruence equation:
10000
n3 + 5n − 1807 = 1121
The solutions of this equation are n = 32 + 10000k where k ∈ N0 (see § 3.2.1 of V1).
16. Show that every N ∋ n > 2 can be written as n = pk or as n = 4k (where p is an odd prime and k ∈ N).
Solution: If n is odd then n = pk (for some odd p ∈ P and k ∈ N).
If n is even then n = 2s (where s ∈ N). Now, if s is even then s = 2k and hence n = 4k, while if s is
odd then s = tp (where t ∈ N) and hence n = kp (where k = 2t). So, is all cases we can write n as
n = pk or as n = 4k.
17. Show that the sum of two odd squares cannot be a perfect square.
Solution: If m = 2s + 1 and n = 2t + 1 (where s, t ∈ Z) then:
4
m2 + n2 = 4s2 + 4s + 1 + 4t2 + 4t + 1 = 2
and hence it cannot be a perfect square because the residue of a square (mod 4) is either 0 or 1.
18. Show that any square of an odd number can be written as 8k + 1 where k ∈ N0 .
Solution: An odd number n can be written as n = 2s + 1 (where s ∈ Z) and hence:
[38] For 11
example, m2 = n5 − 4 has no solution and hence m2 = n5 − 4 has no solution (see § 2.7.6 of V1).
Chapter 5
Diophantine Equations
This chapter is essentially a continuation to our investigation of Diophantine equations (e.g. their types
and the methods of their solution) which we started in the first volume of this book. So, we mostly build
(and elaborate) on the material of the first volume about Diophantine equations.
[39] Infact, narrowing the domain of solution does not only make the search for solution easier (by excluding certain
possibilities) but can lead to a clue or an insight about the solution or its nature.
55
5.1 General Issues about Diophantine Equations 56
(i.e. the left hand side cannot be greater than 6). Also, the equation 13x2 + 6y 2 + 5z 4 = 0 (where
x, y, z ∈ Z) has the obvious (and only) trivial solution (i.e. x = y = z = 0) because any sum of (positive
multiples of) even natural powers of integers must be a positive natural number unless all the integers
are 0.
4 4 2
• Simple divisibility checks: for example, it is fairly obvious that the equation x +y −x − y 2 = 34
(where x, y ∈ Z) has no solution because the left hand side is divisible by 4 noting that x − x2 =
4
(x2 − x)(x2 + x) where both factors are even and this similarly applies to y 4 − y 2 while the right hand
side is not divisible by 4.
• Simple modularity checks: we mean by this using modular arithmetic rules and techniques to
inspect and test the solvability of the given Diophantine equation (where we largely exploit and benefit
from the rules that we outlined in § 2.7.6 of V1). For example, it should be fairly obvious (to someone
with modest experience in solving Diophantine equations) that the Diophantine equation 20x2 + 21y 2 =
22 (where x, y ∈ Z) has no solution because by a simple modularity inspection (i.e. via reducing the
5
equation in modulo 5) we find that this equation implies y 2 = 2 which obviously has no solution (because
2 is a quadratic non-residue of 5) and hence the original Diophantine equation is not solvable.[40]
Also see Problem 7 of § 6.1 as well as § 6.4.
(b) It is obvious that x = y = 0 is a solution. So, in the following we consider non-trivial solutions. We
convert this equation to a Pell equation form (see § 1.2) by transforming x, that is:
[40] It is worth noting that we can consider parity checks (which we investigated in the first point) as an example of simple
modularity (or modular arithmetic) checks. In fact, we can consider parity checks as the simplest modularity checks
(since parity checks are based on the modular arithmetic of 2 which is the least modulo in modular arithmetic). However,
parity checks (unlike common modularity checks) are not limited to explicit modularity inspection and checks, and hence
from this perspective we may consider parity checks as more general than simple modularity checks.
[41] In fact, if we exclude z = 0 then we can make a more specific statement, i.e. any cube can be expressed as a difference
(g) If we write this equation as x2 y − xy 2 = 13 then we can see that the LHS is always even while the
RHS is odd and hence this equation has no solution.
(h) The square of an integer is congruent (mod 4) either to 0 or to 1 and hence the LHS is congruent
(mod 4) to 0 or 1 or 2. Now, if we note that 43275 is congruent (mod 4) to 3 then it should be obvious
that this congruence has no solution.
(i) Let us write this equation as x2 − 18 = y 5 . Now, the residues of x2 − 18 (mod 11) are: 4, 5, 8,
2, 9, 7, 7, 9, 2, 8, 5 while the residues of y 5 (mod 11) are: 0, 1, 10, 1, 1, 1, 10, 10, 10, 1, 10. Hence,
11
x2 − 18 6= y 5 which implies that the equation has no solution (see § 2.7.6 of V1).
3. Solve the following Diophantine equations (where x, y ∈ Z):
(a) x3 + y 3 − x − y = 0. (b) x3 + y 3 + x + y = 0. (c) x3 + x2 − y 3 − y 2 = 0.
(d) x3 + y 3 + x2 + y 2 = 0. (e) x3 + y 3 − x2 − y 2 = 0. (f ) x2 − xy + 6x − y + 2 = 0.
Solution:
(a) We have:
(x3 + y 3 ) − (x + y) = 0 → (x + y)(x2 − xy + y 2 ) − (x + y) = 0 →
2 2
(x + y)(x − xy + y − 1) = 0
So, either x + y = 0 or x2 − xy + y 2 − 1 = 0. Hence, we have two cases:
• x + y = 0 and hence y = −x.
• x2 − xy + y 2 − 1 = 0 which is equivalent to (x − y)2 + xy − 1 = 0. Accordingly:
If (x − y)2 = 0 then x = y and hence xy = x2 = y 2 = 1, i.e. x = y = −1 or x = y = 1.
If (x − y)2 = 1 then xy = 0, i.e. x = y = 0 (which is inconsistent) or x = 0 (and hence y = ±1) or
y = 0 (and hence x = ±1).
If (x − y)2 > 1 then if we write the equation x2 − xy + y 2 − 1 = 0 as x2 + y 2 = xy + 1 then x and y
must have the same sign because otherwise the LHS will be greater than 1 (noting that the difference
between x and y must be greater than 1 in magnitude) while the RHS will not exceed 1. Now, if we
write the equation (x − y)2 + xy − 1 = 0 as (x − y)2 − 1 = −xy then the LHS must be positive while the
RHS must be non-positive (noting that x and y presumably have the same sign). So, this contradiction
should lead to the conclusion that there is no solution for (x − y)2 > 1, and hence we have no other
solutions.
So in brief, the solutions are (where k ∈ Z):
(x, y) = (k, −k) (x, y) = (−1, −1) (x, y) = (1, 1) (x, y) = (0, ±1) (x, y) = (±1, 0)
(b) We have:
(x3 + y 3 ) + (x + y) = 0 → (x + y)(x2 − xy + y 2 ) + (x + y) = 0 →
(x + y)(x2 − xy + y 2 + 1) = 0
So, either x + y = 0 or x2 − xy + y 2 + 1 = 0. Hence, we have two cases:
• x + y = 0 and hence y = −x.
• x2 − xy + y 2 + 1 = 0 which is equivalent to (x − y)2 + xy + 1 = 0. Accordingly:
If (x − y)2 = 0 then x = y and hence xy = x2 = y 2 = −1 which is impossible.
If (x − y)2 = 1 then x − y = ±1, i.e. x = y − 1 or x = y + 1 which lead to y 2 − y + 2 = 0 or y 2 + y + 2 = 0.
These equations have no integer solution.
If (x − y)2 > 1 then if we write the equation x2 − xy + y 2 + 1 = 0 as x2 + y 2 + 1 = xy then x and y must
have the same sign because otherwise the LHS will be positive while the RHS cannot be positive. Now,
if we write the equation (x − y)2 + xy + 1 = 0 as (x − y)2 + 1 = −xy then the LHS must be positive
while the RHS must be non-positive (noting that x and y presumably have the same sign). So, this
contradiction should lead to the conclusion that there is no solution for (x − y)2 > 1.
So in brief, the only solution is: (x, y) = (k, −k) where k ∈ Z.
(c) If we write the equation as (x3 − y 3 ) + (x2 − y 2 ) = 0 then it is obvious that x = y is a solution. So,
let us consider the other case, i.e. x 6= y:
If x = 0 then y 3 + y 2 = y 2 (y + 1) = 0, i.e. (x, y) = (0, −1).
5.2 Polynomial Diophantine Equations 60
= (x + y)(2x + y) 3x(20x2 + 9xy + y 2 ) + y(20x2 + 9xy + y 2 )
= (x + y)(2x + y)(3x + y) 20x2 + 9xy + y 2
= (x + y)(2x + y)(3x + y) 20x2 + (4 + 5)xy + y 2
= (x + y)(2x + y)(3x + y) (20x2 + 4xy) + (5xy + y 2 )
= (x + y)(2x + y)(3x + y) [4x(5x + y) + y(5x + y)]
= (x + y)(2x + y)(3x + y)(4x + y)(5x + y)
As we see:
If x = y = 0 then f = 0.
If x = 0 and y 6= 0 then f = y 5 6= 0.
If x 6= 0 and y = 0 then f = 120x5 6= 0.
If x 6= 0 and y 6= 0 and one of these five factors is zero (e.g. when y = −x) then f = 0.
If x 6= 0 and y 6= 0 and none of these five factors is zero then f 6= 0 is a product of 5 distinct factors.
So in brief, either f = 0, or f = y 5 6= 0, or f = 120x5 6= 0, or f = abcde where a, b, c, d, e are distinct
non-zero integers.
(a) It is obvious that 21 6= 0, 21 6= y 5 and 21 6= 120x5 . Moreover, if we consider all the possible
factorizations of 21 into distinct integer factors then we have:
21 = (1)(21) = (−1)(−21)
= (3)(7) = (−3)(−7)
= (1)(−1)(−21)
= (1)(3)(7) = (−1)(−3)(7) = (−1)(3)(−7) = (1)(−3)(−7)
= (1)(−1)(−3)(7) = (1)(−1)(3)(−7)
As we see, 21 can be factorized only in 2 or 3 or 4 distinct integer factors and hence it cannot be equal
to abcde. Therefore, f cannot be equal to 21.
(b) It is obvious that 27 6= 0, 27 6= y 5 (noting that 27 = 33 ) and 27 6= 120x5 . Moreover, if we consider
all the possible factorizations of 27 into distinct integer factors then we have:
27 = (1)(27) = (−1)(−27)
= (3)(9) = (−3)(−9)
= (1)(−1)(−27)
= (1)(3)(9) = (−1)(−3)(9) = (−1)(3)(−9) = (1)(−3)(−9)
= (1)(−1)(−3)(9) = (1)(−1)(3)(−9)
As we see, 27 can be factorized only in 2 or 3 or 4 distinct integer factors and hence it cannot be equal
to abcde. Therefore, f cannot be equal to 27.
(c) 181 is prime and hence it is obvious that 181 6= 0, 181 6= y 5 and 181 6= 120x5 . Moreover, any prime
number p can be factorized as a product of only two or three distinct integer factors, i.e. p = (1)(p) or
p = (−1)(−p) or p = (1)(−1)(−p). Hence, 181 cannot be equal to abcde. Therefore, f cannot be equal
to 181.
(d) 45 6= 0, 45 6= y 5 and 45 6= 120x5 . However, in principle 45 can be equal to abcde because 45 can be
factorized into 5 distinct integers, that is:
45 = (1)(−1)(3)(−3)(5)
Now, (x + y) must be equal to one of these five numeric factors while (2x + y) must be equal to one
of the remaining four numeric factors. So, if we consider all the 20 systems of simultaneous equations
obtained from the five possibilities of x+y = (1), (−1), (3), (−3), (5) with the four remaining possibilities
of 2x+y = (1), (−1), (3), (−3), (5) then we can identify x and y values that can potentially make f = 45.
5.2 Polynomial Diophantine Equations 64
These 20 systems with their solutions and the corresponding values of f in the form (x, y, f ) are given
in the following table:
x+y =1 x + y = −1 x+y =3 x + y = −3 x+y =5
2x + y = 1 (2, −3, −105) (−2, 5, −45) (4, −7, −1755) (−4, 9, −1155)
2x + y = −1 (−2, 3, 105) (−4, 7, 1755) (2, −5, 45) (−6, 11, 8645)
2x + y = 3 (2, −1, 945) (4, −5, −3465) (6, −9, −25515) (−2, 7, 45)
2x + y = −3 (−4, 5, 3465) (−2, 1, −945) (−6, 9, 25515) (−8, 13, 84645)
2x + y = 5 (4, −3, 9945) (6, −7, −21505) (2, 1, 10395) (8, −11, −118755)
As we see, f can take the value 45, i.e. when (x, y) = (2, −5) and when (x, y) = (−2, 7). So, there are
x, y ∈ Z that make f = 45.
(e) From the table of part (d) we can see that f can take the value −105, e.g. when (x, y) = (2, −3).
So, there are x, y ∈ Z that make f = −105.
(f ) 63 6= 0, 63 6= y 5 and 63 6= 120x5 . However, in principle 63 can be equal to abcde because 63 can be
factorized into 5 distinct integers, that is:
63 = (1)(−1)(3)(−3)(7)
Now, if we follow the procedure of part (d) by building a similar table (where x + y = 5 and 2x + y = 5
are replaced by x + y = 7 and 2x + y = 7) then we find that f cannot take the value 63. So, there are
no x, y ∈ Z that make f = 63 (despite the fact that 63 can be factorized into 5 distinct integers, i.e.
the possibility of factorization is a necessary but not sufficient condition for f to take the given integer
value).
8. Show that if (a, b, c) is a primitive Pythagorean triple then exactly one of a, b, c is divisible by 3, exactly
one of a, b, c is divisible by 4, and exactly one of a, b, c is divisible by 5.
3 3 3
Solution: Regarding the divisibility by 3, we have x2 (x = 0, 1, 2) = 0, 1, 1. Thus, either c2 = 0
3 3
and hence a2 = 0 and b2 = 0 (which is impossible because this means that all the three numbers are
3
divisible by 3 in contradiction to being primitive) or c2 = 1 and hence one of a, b must be congruent
(mod 3) to 0 and the other must be congruent (mod 3) to 1 or to 2, i.e. exactly one of a, b, c (i.e. a or
b) is divisible by 3.
Regarding the divisibility by 4, it was shown (in Problem 3 of § 4.1.4 of V1) that if (a, b, c) is a
primitive Pythagorean triple, then there are coprimes m, n ∈ N of opposite parity with m > n such
that (a, b, c) is given by Euclid’s formula, i.e. (a, b, c) = (2mn, m2 − n2 , m2 + n2 ). This means that a
is divisible by 4. Moreover, it was shown (in Problem 2 of § 4.1.4 of V1) that if (a, b, c) is a primitive
Pythagorean triple then a and b have opposite parity (and hence c is odd). This means that only a is
divisible by 4, i.e. exactly one of a, b, c is divisible by 4.
5 5
Regarding the divisibility by 5, we have x2 (x = 0, 1, 2, 3, 4) = 0, 1, 4, 4, 1. Now:
5
If c2 = 0 then one of a2 , b2 must be congruent (mod 5) to 1 and the other must be congruent (mod 5)
5 5
to 4 (noting that a2 = 0 and b2 = 0 is not possible because this contradicts being primitive) and hence
exactly one of a, b, c (i.e. c) is divisible by 5.
5
If c2 = 1 then one of a2 , b2 must be congruent (mod 5) to 0 and the other must be congruent (mod 5)
to 1 and hence exactly one of a, b, c (i.e. a or b) is divisible by 5.
5
If c2 = 4 then one of a2 , b2 must be congruent (mod 5) to 0 and the other must be congruent (mod 5)
to 4 and hence exactly one of a, b, c (i.e. a or b) is divisible by 5.
So, in all cases exactly one of a, b, c is divisible by 5.
9. Find all the solutions of the Diophantine equation: ax + xy + by = c where a, b, c, x, y ∈ Z and ab 6= 0.
Solution: We have ax + xy + by = c and hence ax + xy + by + ab = ab + c, i.e. (x + b)(y + a) = ab + c.
Now, if we consider all the possible 2-factor factorizations of (ab + c) in both orders and equate one
factor to (x + b) and the other factor to (y + a) then we get all the possible solutions.
For example, if a = b = 1 and c = 7 then we have x + xy + y = 7 and hence x + xy + y + 1 = 8, i.e.
5.2 Polynomial Diophantine Equations 65
(x + 1)(y + 1) = 8. Thus:
On considering these eight possibilities we get the following eight (x, y) solutions:
(−2, −9) (−9, −2) (0, 7) (7, 0) (−3, −5) (−5, −3) (1, 3) (3, 1)
10. Solve the following Diophantine equations in two variables (where x, y ∈ Z):
(a) x2 − 6xy − 3x + 9y + 5 = 0. (b) 3x3 y − 3x2 + 22x2 y − 7x + 21xy − 3y + 1 = 0.
(c) 7x2 − x2 y 2 + 13 = 0. (d) x2 − xy + 6x − y + 2 = 0.
Solution: The common feature of these equations is that we can separate the two variables in a way
that changes the problem from being a Diophantine equation problem to a polynomial divisibility prob-
lem. This essentially converts the problem from being a two-variable Diophantine equation problem to
a one-variable divisibility problem (which is generally easier to solve).
(a) We have:
x2 −3x+5
x2 − 6xy − 3x + 9y + 5 = 0 → x2 − 3x + 5 = 6xy − 9y → y= 6x−9
Now, the solutions of the divisibility problem (6x − 9)|(x2 − 3x + 5) are x = −4, 1, 2, 7 (see § 6.4 of V1).
Hence, the solutions of the given Diophantine equation are: (x, y) = (−4, −1), (1, −1), (2, 1), (7, 1).
(b) We have:
3x3 y − 3x2 + 22x2 y − 7x + 21xy − 3y + 1 = 0 → 3x3 y + 22x2 y + 21xy − 3y = 3x2 + 7x − 1 →
3x2 +7x−1
y= 3x3 +22x2 +21x−3
Now, the solution of the divisibility problem (3x3 + 22x2 + 21x − 3)|(3x2 + 7x − 1) is x = −1 (see § 6.4
of V1). Hence, the solution of the given Diophantine equation is: (x, y) = (−1, 1).
(c) If we write this equation as x2 = y213−7 then we must have (y 2 − 7)|13, i.e. y 2 − 7 = ±1, ±13.
However, there is no integer solution to any of these four equations. Hence, the given equation has no
solution.
(d) This equation was solved in Problem 3 by treating it as a quadratic in x. In the present Problem
we will solve it as a divisibility problem, that is:
x2 − xy + 6x − y + 2 = 0 → x2 − 4 − xy + 6x − y + 6 = 0 → x2 − 4 = xy − 6x + y − 6 →
x2 −4
x2 − 4 = (y − 6)(x + 1) → y−6= x+1
Now, the solutions of the divisibility problem (x + 1)|(x2 − 4) are x = −4, −2, 0, 2 (see § 6.4 of V1).
Hence, the solutions of the given Diophantine equation are: (x, y) = (−4, 2), (−2, 6), (0, 2), (2, 6).
11. Solve the following Diophantine equations in two variables (where x, y ∈ Z):
(a) x2 − y 2 − 12x − 3y + 1 = 0. (b) x3 − x2 − y − 1 = 0.
(c) x4 − y 3 + 2y 2 + 3x + 9 = 0. (d) x3 − 2y 2 − 7x2 + 6y − 11 = 0.
Solution: The common feature of these equations is that we can separate the two variables and hence
this Problem is like Problem 10. However, unlike Problem 10 we do not have the luxury of converting a
two-variable Diophantine equation problem to a one-variable divisibility problem because we have two
equal polynomial expressions in two separate variables. So, we usually need to invent and employ some
algebraic (and possibly non-algebraic) tricks (or techniques or considerations). Some of these tricks (or
techniques or considerations) are considered in the following solutions.
(a) We have:
x2 − y 2 − 12x − 3y + 1 = 0 → x2 − 12x = y 2 + 3y − 1 →
x2 − 12x + 36 = y 2 + 3y + 35 → (x − 6)2 = y 2 + 3y + 35 →
(2x − 12)2 = (2y)2 + 12y + 140 → (2x − 12)2 = (2y + 3)2 + 131 →
2 2
X − Y = 131 → (X − Y )(X + Y ) = 131
5.2 Polynomial Diophantine Equations 66
On solving the four 2-equation systems representing these 4 possibilities we get the following solutions:
i.e. (2x − 3)2 + (4y + 1)2 = (3z)2 . However, the sum of two odd squares cannot be a perfect square (see
Problem 17 of § 4). Hence, this equation has no solution.
13. Find a natural number n such that the Diophantine equation 3x + 5y = n has exactly 5 solutions in
natural numbers (i.e. x, y ∈ N).
Solution: The simplest approach is to tackle this Problem computationally by searching for the values
of n that produce exactly 5 natural solutions. If we do this then we will find (for example) that
n = 68, 71, 73, 74, 76, 77, 90 solve this Problem. For instance, 3x + 5y = 90 has the following five natural
solutions: (x, y) = (5, 15), (10, 12), (15, 9), (20, 6), (25, 3).
5.2 Polynomial Diophantine Equations 67
14. Find all quadruples of integers whose sum is equal to their product.
Solution: This is a 4-variable Diophantine equation problem, i.e. x + y + z + w = xyzw where
x, y, z, w ∈ Z. Now:
• If xyzw = 0 then we have the following solutions: (x, y, z, w) = (0, k, s, −k − s), (k, 0, s, −k − s),
(k, s, 0, −k − s), (k, s, −k − s, 0) where k, s ∈ Z.
• If xyzw 6= 0 then let assume for the time being that |x| ≤ |y| ≤ |z| ≤ |w|. Now, if |x| > 1 or |y| > 1
then |x + y + z + w| < |xyzw|, e.g.
Hence, we must have z = ±2. Now, if we test the 8 combinations of these values of x, y, z (considering
the conditions xyzw 6= 0 and |x| ≤ |y| ≤ |z| ≤ |w| as well as x, y, z, w ∈ Z) then we find only 3 solutions
which are: (x, y, z, w) = (1, 1, 2, 4), (1, −1, −2, −2), (−1, 1, −2, −2). Now, if we lift the condition
|x| ≤ |y| ≤ |z| ≤ |w| (noting the symmetry in x, y, z, w) by permuting x, y, z, w (and hence permuting
the values in these 3 solutions) then we get 24 solutions in total (i.e. 12 + 12 noting that the last two
solutions produce the same permutations).
15. Show that the product of every Pythagorean triple is divisible by 60.
Solution: Non-primitive Pythagorean triples are scaled-up versions of primitive Pythagorean triples
(because any non-primitive triple can be reduced to primitive by dividing by the common factor)[43]
and hence it is enough to prove this proposition for primitive Pythagorean triples. Now, from the result
of Problem 8 we can conclude that every Pythagorean triple has factors of 3, 4 and 5 and hence their
product must have a factor of 3 × 4 × 5 = 60, i.e. every Pythagorean triple is divisible by 60.
16. Show that the Diophantine equation x2 −y 2 +z 2 = w has a solution (x, y, z) for any w (where x, y, z, w ∈
Z).
Solution: w is either odd or even. Now, 2n + 1 = (n + 1)2 − n2 + 02 (where n ∈ Z) can represent any
odd number, while 2n + 2 = (n + 1)2 − n2 + 12 can represent any even number. So, if we choose z = 0
when w is odd and choose z = 1 (or z = −1) when w is even then we can find x = n + 1 and y = n (for
some n ∈ Z) that satisfy x2 − y 2 + z 2 = w. The obvious implication of this result is that any integer
can be expressed as a sum of two squares (of integers) minus a square (of an integer).
17. Solve the following Diophantine equations (where x, y ∈ Z):
(a) x2 + xy + 2y + 2 = 0. (b) 4x2 + 4x − 15 − y 3 = 0. (c) x3 − 4y 4 + 2 = 0. (d) x2 + 4x = y 2 .
Solution:
(a) This is a quadratic equation in x whose discriminant is y 2 − 8y − 8. So, if this equation has a
solution then this discriminant must be a perfect square, i.e. y 2 − 8y − 8 = m2 (where m ∈ Z). Hence:
y 2 − 8y = m2 + 8 → y 2 − 8y + 16 = m2 + 24 → (y − 4)2 = m2 + 24 →
(y − 4)2 − m2 = 24 → (y − 4 − m)(y − 4 + m) = 24
Now, 24 = (−1)(−24) = (1)(24) = (−2)(−12) = (2)(12) = (−3)(−8) = (3)(8) = (−4)(−6) = (4)(6).
So, if we consider equating these 8 factorizations (in both orders) to the factors on the LHS then
we obtain 16 systems of simultaneous equations. On solving these systems of equations we find the
following integer solutions for y (noting that we ignore the non-integer solutions): y = −3, 11, −1, 9
(corresponding to m2 = 25, 25, 1, 1). Thus, the solutions (x, y) of the given Diophantine equation are:
(−1, −3) (4, −3) (−3, 11) (−8, 11) (0, −1) (1, −1) (−4, 9) (−5, 9)
(b) We have:
[43] It
should be obvious that all non-primitive Pythagorean triples can be obtained from the primitive Pythagorean triples
by multiplying the three numbers of the primitive triples by a natural number k > 1, and hence non-primitive triples
can be reduced (or scaled down) to their primitive form by dividing them by this common factor k.
5.2 Polynomial Diophantine Equations 68
Now, if we consider these 4 factorization possibilities in both orders then we have 8 systems of simulta-
neous equations (e.g. a − b = −1 and a2 + ab + b2 = −8). Of these 8 systems the only solvable system
in integers is a − b = 2 and a2 + ab + b2 = 4 which leads to (a, b) = (0, −2) and (a, b) = (2, 0). However,
neither of these solutions leads to an acceptable solution for x and y and hence the given Diophantine
equation has no solution.
4
(c) If we reduce this equation modulo 4 we get x3 + 2 = 0 which has no solution and hence the given
Diophantine equation has no solution (see § 2.7.6 of V1).
(d) We have x2 + 4x − y 2 = 0 which is a quadratic in x and hence:
p
−4 ± 16 + 4y 2 p
x= = −2 ± 4 + y 2
2
Now, we have two cases:
• y = 0 and hence x = 0, −4.
• y 6= 0 and hence we have no solution. This is because 4 + y 2 must be a perfect square which is
impossible because y 2 is a perfect square and hence 4 + y 2 cannot be a perfect square because the
difference between two (non-trivial) perfect squares cannot be 4.[44]
So in brief, the given equation has only two solutions: (x, y) = (0, 0) and (x, y) = (−4, 0).
18. Find the necessary and sufficient conditions for the following Diophantine equation to have a solution:
Solution: Regarding the necessary condition, if this is solvable then by reducing it in modulo p we
p p
get x2 + c = 0, i.e. x2 = −c. This means that −c must be a quadratic residue (mod p).
Regarding the sufficient condition, we will show that this condition is also sufficient. If −c is a
p
quadratic residue (mod p) then x2 + c = 0 must be solvable, i.e. we must have some x ∈ Z such that
p
x2 + c = 0. This means that x2 + c = ∓py (for some y ∈ Z), i.e. x2 ± py + c = 0 has an integer solution
(x, y) which means x2 ± py + c = 0 is solvable.
So in brief, the necessary and sufficient condition for the given Diophantine equation to have a solution
is that −c is a quadratic residue (mod p).
19. Find all x, y, z ∈ Z that satisfy the following equation: xy + xz + yz = xyz.
Solution: We have 3 main cases to consider:
• xyz = 0 and hence (x, y, z) = (0, 0, k) or (0, k, 0) or (k, 0, 0) where k ∈ Z.
• xyz 6= 0 and all x, y, z are positive (i.e. x, y, z ∈ N). If we divide the two sides by xyz we get
1 1 1
x + y + z = 1 whose solutions were obtained in Problem 7 of § 4.1.10 of V1.
• xyz 6= 0 and not all x, y, z are positive (i.e. at least some of them are negative). If we divide the two
sides by xyz we get x1 + y1 + z1 = 1 and hence at least one of x, y, z must be > 0 (because otherwise the
LHS will be < 0). In fact, we must have exactly two variables > 0 because otherwise the LHS will be
< 1. Now, we have two cases:
One of the positive variables is 1 and hence the other two variables (i.e. the other positive and the
negative) must be equal in magnitude and opposite in sign, i.e. (x, y, z) = (1, k, −k) or (k, 1, −k) or
(k, −k, 1).
Both positive variables are > 1 and hence the LHS will be < 1 (i.e. we have no solution). This is
[44] We note that the only solutions to the Diophantine equation m2 − n2 = 4 are (m, n) = (±2, 0).
5.3 Exponential Diophantine Equations 69
because the maximum value of the sum of the terms involving these variables is 1 (i.e. 1/2 + 1/2) and
hence the sum of the three terms must be less than 1.
So in brief, the solutions (x, y, z) are (where k ∈ Z):
(0, 0, k) (0, k, 0) (k, 0, 0) (2, 3, 6) (2, 6, 3) (3, 2, 6) (3, 6, 2) (6, 2, 3)
(6, 3, 2) (2, 4, 4) (4, 2, 4) (4, 4, 2) (3, 3, 3) (1, k, −k) (k, 1, −k) (k, −k, 1)
2 2 2
20. Find all x, y, z ∈ N such that x + y − z = 0 and 60|(xyz).
Solution: It is obvious that (x, y, z) is a Pythagorean triple and hence from the result of Problem 15
we conclude that the solutions to this Problem are all the Pythagorean triples.
21. Create a 2-variable polynomial Diophantine equation which has the following solutions: (x, y) = (3, 5),
(−11, 21), (1, 12).
Solution: A simple way for solving this type of problems is to use a “graphical approach”, e.g. we
assume that the equation is a parabola passing through these three points. So, if the parabola is rep-
resented by the equation y = ax2 +bx+c then we have the following system of linear equations in a, b, c:
5 = 9a + 3b + c 21 = 121a − 11b + c 12 = a + b + c
whose solution is (a, b, c) = (−11/56, −19/7, 835/56). On inserting these values in the equation
y = ax2 + bx + c and multiplying by 56 we get: 56y + 11x2 + 152x − 835 = 0. So, this Diophantine
equation meets the stated requirement.
(see part a of Problem 3 of § 4.1.7 of V1). So, the only solution is (x, y) = (2, 1).
So in brief, the given equation has only two solutions: (x, y) = (1, 0) and (2, 1).
(b) We have two cases:
• x is odd: if we reduce the equation in modulo 8 we get:
8 8 8 8
3 − 1 = 1 (if y = 0) 3 − 2 = 1 (if y = 1) 3 − 4 = 1 (if y = 2) 3 − 0 = 1 (if y > 2)
So, the only solution in this case is (x, y) = (1, 1).
• x is even: i.e. 32k − 2y = 1 (where x = 2k with k ∈ N noting that x = 0 is impossible). Accordingly:
32k − 1 = 2y → (3k − 1)(3k + 1) = 2y
i.e. 3k − 1 = 2m and 3k + 1 = 2n (where m, n ∈ N with m < n and m + n = y). Now, if we subtract the
first of the last two equations from the second we get 2 = 2n − 2m , i.e. 2 = 2m (2n−m − 1). The only
solution to the last equation is m = 1 and n = 2 and hence y = 3. So, the only solution in this case is
(x, y) = (2, 3).
So in brief, the given equation has only two solutions: (x, y) = (1, 1) and (2, 3).
4. Find all x, y ∈ N0 such that:
(a) 10x + 7 = 2y . (b) 4x − 7 = 9y . (c) 3x − 8 = 11y . (d) 5x − 9 = 2y .
(e) 4x − 3y = 7. (f ) 5x − 3y = 2. (g) 3x − 5y = 4.
Solution:
(a) We obviously have parity violation unless:
• x = 0 and y 6= 0 and hence we have 1 + 7 = 2y , i.e. (x, y) = (0, 3).
• x 6= 0 and y = 0 and hence we have 10x + 7 = 1 which has no solution.
So, the only solution to the given equation is (x, y) = (0, 3).
(b) This equation has no solution if xy = 0. Hence, in the following we assume xy 6= 0.
5
If we reduce the equation in modulo 5 we get (−1)x − 2 = (−1)y and hence x must be even (say x = 2k
where k ∈ N) and y must be odd. Hence:
42k − 7 = 9y → 42k − 7 = 32y → 42k − 32y = 7 → (4k − 3y )(4k + 3y ) = 7
Now, if we consider the factorization of 7 then we can easily conclude that the only possibility is
4k − 3y = 1 and 4k + 3y = 7, i.e. k = y = 1.
So, the only possible solution to the given equation is (x, y) = (2, 1).
(c) If xy = 0 then we have only one solution, i.e. (x, y) = (2, 0). So, in the following we assume xy 6= 0.
3
If we reduce the equation in modulo 3 we get 0 + 1 = (−1)y and hence y must be even, i.e. 3x − 8 = 112s
(where s ∈ N).
3
If we reduce the equation in modulo 4 we get (−1)x − 0 = (−1)2s and hence x must be even, i.e.
2k 2s
3 − 8 = 11 (where k ∈ N). Accordingly:
32k − 8 = 112s → 32k − 112s = 8 → (3k − 11s )(3k + 11s ) = 8
Now, if we consider the factorization of 8 then we can easily conclude that the only possibility is
3k − 11s = 2 and 3k + 11s = 4, i.e. k = 1 and s = 0 and hence (x, y) = (2, 0). However, we are currently
assuming xy 6= 0 (noting that this solution is obtained already).
So, the only solution to this equation is (x, y) = (2, 0).
(d) This equation has no solution if xy = 0. Hence, in the following we assume xy 6= 0.
3
If we reduce the equation in modulo 3 we get (−1)x − 0 = (−1)y and hence x and y must have the same
parity.
5 4 5
If we reduce the equation in modulo 5 we get 0 + 1 = 2y . Now, 2 y=0,1,2,3 = 1, 2, 4, 3 and hence we must
4
have y = 0 (say y = 4s where s ∈ N). But since x and y have the same parity then x must be even
(say x = 2k where k ∈ N). Accordingly:
52k − 9 = 24s → 52k − 9 = 42s → 52k − 42s = 9 → (5k − 4s )(5k + 4s ) = 9
Now, if we consider the factorization of 9 then we can easily conclude that the only possibility is
5k − 4s = 1 and 5k + 4s = 9, i.e. k = s = 1.
5.3 Exponential Diophantine Equations 71
So in brief, the given equation has only one solution, i.e. (x, y, z) = (1, 0, 1).
(g) We have two main cases to consider:
• xyz = 0: it is obvious that x = y = z = 0 is not a possibility. Similarly, exactly two of the three
variables are zero is not a possibility. Regarding the case of exactly one of the three variables is zero,
we have:
z = 0 and hence 3x + 4y = 1 which has no solution because the LHS is > 1.
y = 0 and hence 3x + 1 = 5z which is impossible because of parity violation.
3
x = 0 and hence 1 + 4y = 5z . Now, in modulo 3 we have 1 + 1 = 2z and hence z is odd (say z = 2t + 1
2 3
where t ∈ N0 ) noting that 2z=0,1 = 1, 2. So we have (see Eq. 12 in V1):
P2t P2t
1 + 4y = 52t+1 → 4y = 52t+1 − 1 → 4y = (5 − 1) k=0 5k → 4y = 4 k=0 5k
P2t k
Now, if y = 1 then we have 1 = k=0 5 and henceP t = 0, i.e. z = 1. So, we have the solution:
2t
(x, y, z) = (0, 1, 1). But if y > 1 then we have 4y−1 = k=0 5k . On reducing this equation in modulo
4 P2t
4 we get 0 = k=0 1 which is nonsensical because the sum on the RHS is odd. So, we have no more
solutions in this case.
3
• xyz 6= 0: if we reduce the equation 3x + 4y = 5z in modulo 3 we get 0 + 1 = (−1)z and hence z must
be even (say z = 2t where t ∈ N). Also, if we reduce the equation 3x + 4y = 5z in modulo 4 we get
4
(−1)x + 0 = 1 and hence x must be even. So in brief, both x and z are even. Accordingly:
3x + 4y = 5z → 3x + 22y = 52t → 52t − 22y = 3x → (5t − 2y )(5t + 2y ) = 3x
i.e. 5t − 2y = 3m and 5t + 2y = 3n (where m, n ∈ N0 with m < n and m + n = x). Now, if we add the
last two equations we get:
2(5t ) = 3m + 3n → 2(5t ) = 3m (1 + 3n−m )
Thus, m must be zero (because there is no factor on the LHS that can match a natural power of 3) and
hence we have:
5t − 2y = 1 and 5t + 2y = 3x
Now, if we reduce the equation 5t − 2y = 1 in modulo 3 we get:
3
(−1)t − (−1)y = 1
So, t must be odd and y must be even. Now:
If y = 2 then from the equation 5t − 2y = 1 we get t = 1 (i.e. z = 2) and hence x = 2. So, we have the
solution (x, y, z) = (2, 2, 2).
8
If y > 2 then if we reduce the equation 5t + 2y = 3x in modulo 8 we get 5t + 0 = 1 (since x is even
2 8 2 8
noting that 3x=0,1 = 1, 3) and hence t must be even (noting that 5t=0,1 = 1, 5). But this contradicts
what we found earlier that t is odd. So, this contradiction leads to the conclusion that y cannot be
greater than 2.
So in brief, the only solutions to the given equation are (x, y, z) = (0, 1, 1) and (2, 2, 2).
So in brief, the given Diophantine equation has only those four solutions.
(b) We have two cases to consider:
• y = 0 and hence (from part a) we get (x, y) = (0, 0) and (x, y) = (−1, 0).
4
• y > 0 and hence on reducing the equation x2 + x + 1 = 4y in modulo 4 we get x2 + x + 1 = 0 which
has no solution and hence the original equation has no solution.
So in brief, the given Diophantine equation has only those two solutions.[45]
(c) This is exactly like part (b) (but we reduce in modulo 5 instead of modulo 4) and hence the only
solutions are (x, y) = (0, 0) and (x, y) = (−1, 0).
2. Let x, y ∈ N0 . Show that 4x − 3y = z has no solution for z = 2, 4, 5, 6, 8, 9, 10, 11, 12.
Solution: We note first that if xy = 0 then there is no solution to 4x − 3y = z for any one of these
values of z (as direct test can easily reveal) and hence in the following we assume x, y > 0.
Now, (4x − 3y ) is odd for all x, y ∈ N and hence z cannot be 2, 4, 6, 8, 10, 12. Hence, 4x − 3y = z has
no solution for z = 2, 4, 6, 8, 10, 12.
3
Regarding 4x − 3y = 5, if we reduce this equation modulo 3 we get 1x = 2 which has no solution and
hence 4 − 3 = 5 has no solution (see § 2.7.6 of V1). This similarly applies to 4x − 3y = 11 and hence
x y
4x − 3y = 11 has no solution.
3
Regarding 4x − 3y = 9, if we reduce this equation modulo 3 we get 1x = 0 which has no solution and
hence 4x − 3y = 9 has no solution.
3. Solve the following Diophantine equations (where m, n ∈ N0 and k ∈ Z):
(a) 7m = 8n + 2k. (b) 7m = 8n + k.
Solution:
(a) We have 4 main cases:
• m = n = 0: the solution is (m, n, k) = (0, 0, 0).
• m = 0 and n > 0: there is no solution due to parity violation.
m
• m > 0 and n = 0: the solutions are (m, n, k) = m, 0, 7 2−1 , e.g. (1, 0, 3), (2, 0, 24), (3, 0, 171).
• m > 0 and n > 0: there is no solution due to parity violation.
(b) We have 4 main cases:
• m = n = 0: the solution is (m, n, k) = (0, 0, 0).
• m = 0 and n > 0: the solutions are (m, n, k) = (0, n, 1 − 8n ), e.g. (0, 1, −7), (0, 2, −63), (0, 3, −511).
• m > 0 and n = 0: the solutions are (m, n, k) = (m, 0, 7m − 1), e.g. (1, 0, 6), (2, 0, 48), (3, 0, 342).
• m > 0 and n > 0: the solutions are (m, n, k) = (m, n, 7m − 8n ), e.g. (1, 1, −1), (1, 2, −57), (2, 1, 41),
(2, 2, −15).
4. Find all x, y ∈ N0 and z ∈ Z such that:
(a) 2x − 3y = z 2 . (b) 2x + 3y = z 2 .
Solution:
(a) We consider and inspect the following cases:
• x = 0: the only solution (by inspection) is (x, y, z) = (0, 0, 0) because the LHS must be non-negative.
• x = 1: the only solutions (by inspection) are (x, y, z) = (1, 0, ±1) because the LHS must be non-
negative.
• x = 2: the only solutions (by inspection) are (x, y, z) = (2, 1, ±1) because the LHS must be non-
negative.
8 2 8
• x > 2: there is no solution. This is because in modulo 8 we have 2x = 0 and 3 y=0,1 = 1, 3. Accordingly:
8 8 8 8
2x − 3y = z 2 → 0 − 1 = z 2 or 0 − 3 = z 2 → 7 = z 2 or 5 = z 2
Noting that 7 and 5 are quadratic non-residues of 8 (see § 1.6) we conclude that there is no solution to
the given Diophantine equation for x > 2.
So in brief, the given Diophantine equation has only the above five solutions.
(b) We consider and inspect the following cases:
[45] In
fact, we can obtain this result more easily by noting that y must be zero (to avoid parity violation) and hence we
must have only those two solutions.
5.4 Mixed Polynomial-Exponential Diophantine Equations 75
• x = 0: the only solutions are (x, y, z) = (0, 1, ±2). This is because 3y = z 2 − 1 = (z − 1)(z + 1) which
implies (considering the factorization of 3y noting as well that y = 0 is not a possibility) that one of
the factors (z − 1) and (z + 1) must be of unity magnitude (noting that the difference between z − 1
and z + 1 is 2) and hence z = ±2 which leads to the given solutions.
3
• x = 1: there is no solution. This is because in modulo 3 we have 21 + 0 = z 2 which has no solution
since 2 is a quadratic non-residue of 3.
8 2 8
• x = 2: there is no solution. This is because in modulo 8 we have 22 + 3y = z 2 . However, 3 y=0,1 = 1, 3
8 8
and hence we have either 5 = z 2 or 7 = z 2 which have no solution because 5 and 7 are quadratic
non-residues of 8.
• x > 2: the only solutions are (x, y, z) = (3, 0, ±3) and (4, 2, ±5). This is because in modulo 8 we have
8 2 8 8
2x = 0 and 3 y=0,1 = 1, 3 while z 2 = 0, 1, 4 and this implies that if we have any solution then y = 2k
(where k ∈ N0 ). Accordingly, the given Diophantine equation becomes:
2x + 32k = z 2 → 2x = z 2 − 32k → 2x = (z − 3k )(z + 3k )
i.e. z − 3k = 2m and z + 3k = 2n (where m, n ∈ N with m < n and m + n = x).[46] Now, if we subtract
the first of the last two equations from the second we get:
2(3k ) = 2n − 2m → 3k = 2m−1 (2n−m − 1)
Now, 3k is odd and hence both 2m−1 and (2n−m − 1) must be odd, and this implies m = 1 and hence
3k = 2n−1 − 1. Accordingly:
If n = 1 then we have 3k = 21−1 − 1 = 0 which has no solution (noting that k ∈ N0 ).[47]
If n = 2 then we have 3k = 22−1 − 1 = 1 which has only one solution, i.e. k = 0. As a result, we have
x = m + n = 1 + 2 = 3 and y = 2k = 2(0) = 0 and hence (x, y, z) = (3, 0, ±3).
If n = 3 then we have 3k = 23−1 − 1 = 3 which has only one solution, i.e. k = 1. As a result, we have
x = m + n = 1 + 3 = 4 and y = 2k = 2(1) = 2 and hence (x, y, z) = (4, 2, ±5).
8 8 8
If n > 3 then we have 2n−1 = 0 and hence we get 3k = 0 − 1 = 7 which has no solution since the
8
residues of 3k (modulo 8) are either 1 or 3 and hence 3k 6= 7. This means that there is no solution to
the given Diophantine equation for n > 3 (i.e. x > 4).
So in brief, the given Diophantine equation has only the above six solutions.
5. Find all x, y ∈ N0 and z ∈ Z such that:
(a) 3x − 4y = z 2 . (b) 4x − 3y = z 2 . (c) 4x + 3y = z 2 . (d) 3x + 5y = z 2 .
Solution:
(a) For x = 0 the only solution (by inspection) is (x, y, z) = (0, 0, 0) because the LHS must be non-
negative.
For x > 0 there is no solution. This is because if we reduce the given equation in modulo 3 we get
3 3
−1 = z 2 (i.e. 2 = z 2 ) which has no solution because 2 is a quadratic non-residue of 3 (see § 1.6). So,
the only solution to the given equation is (x, y, z) = (0, 0, 0).
(b) For x = 0 the only solution (by inspection) is (x, y, z) = (0, 0, 0) because the LHS must be non-
negative.
For x = 1 the only solutions (by inspection) are (x, y, z) = (1, 1, ±1) because the LHS must be non-
negative.
For x > 1 there is no solution. This is because if we reduce the given equation in modulo 8 we get
8 8 8 8 2 8
0−1 = z 2 or 0−3 = z 2 (i.e. 7 = z 2 or 5 = z 2 ) since 3 y=0,1 = 1, 3. However, neither of these congruences
has a solution because 7 and 5 are quadratic non-residues of 8 (see § 1.6). So, the only solutions are
(x, y, z) = (0, 0, 0) and (1, 1, ±1).
(c) If we write this equation as 2X + 3y = z 2 (where X = 2x) then this equation is the same as the
[46] Although z ∈ Z we can make z ∈ N at this stage noting that z is squared and hence its sign does not matter; moreover
within the imposed conditions z cannot be 0. We should also note that 2x + 32k = z 2 implies that z is odd and hence
z − 3k 6= 1.
[47] In fact, we can also rule out this possibility by the condition m < n noting that m = 1.
5.5 Diophantine Equations Involving Roots 76
equation of part (b) of Problem 4 (with X replacing x). Now, if we note that X = 2x then we can
conclude (by using the solutions of part b of Problem 4) that the only solutions to the given equation
are (x, y, z) = (0, 1, ±2) and (2, 2, ±5).
(d) We have three cases to consider and inspect:
• x = 0: i.e. 5y = z 2 − 1 = (z − 1)(z + 1). Noting that the difference between (z − 1) and (z + 1) is 2,
we can see that no value of z can make these expressions non-negative powers of 5. Hence, we have no
solution in this case. 2
3 3
• x = 1: if we reduce the equation in modulo 3 we get 5y = z 2 . Now, 5 y=0,1 = 1, 2 and hence y must
be even (noting that 2 is not a quadratic residue of 3). So, the original equation becomes 3 + 52k = z 2
(where k ∈ N0 ), i.e. 3 = z 2 − 52k = (z − 5k )(z + 5k ). Therefore, one of the factors (z − 5k ) and
(z + 5k ) must be of magnitude 1 while the other must be of magnitude 3. Simple algebraic inspection
shows that we must have k = 0 (and hence y = 0) and z = ±2. So, the only solutions in this case are
(x, y, z) = (1, 0, ±2).
• x > 1: we note first that z must be even (because the LHS is even) and hence z 2 is a multiple of 4.
4 2 4
Now, if we reduce the equation in modulo 4 then we get 3x + 1 = 0. So, if we note that 3x=0,1 = 1, 3
then x must be odd (say x = 2s + 1 where s ∈ N). Hence, the given equation becomes 32s+1 + 5y = z 2 .
Now, EITHER:
y = 0 and hence:
32s+1 + 1 = z 2 → 32s+1 = z 2 − 1 → 32s+1 = (z − 1)(z + 1)
However, the difference between (z − 1) and (z + 1) is 2 and this implies that 32s+1 must be made of
a factor of magnitude 1 and another factor of magnitude 3, i.e. s = 0 which is impossible because we
are currently assuming x > 1 (i.e. s ∈ N) although we should note that this will lead to the previous
solutions, i.e. (x, y, z) = (1, 0, ±2). OR:
5
y > 0 and hence if we reduce the equation 32s+1 + 5y = z 2 in modulo 5 then we get 32s+1 = z 2 which
5
has no solution. This is because 32s+1 = 2, 3 (corresponding to s odd and s even) and hence we must
5
have z 2 = 2, 3 which has no solution because 2 and 3 are quadratic non-residues of 5. This means that
for x > 1 we have no solution.
So in brief, the given Diophantine equation has only the two solutions: (x, y, z) = (1, 0, ±2).
√
• y < 0 and hence if y = s3 (wheres ∈ Z) then x − |s| = 5, i.e. x = (5 + |s|)2 . So, the solutions in
this case are: (x, y) = [5 + |s|]2 , s3 .
So in brief, the solutions of the given equation are the union of the sets of solutions in these two cases.
(e) If x = k 3 (where k ∈ Z) then:
√ √ √ √
3
x + 3 y = 13 → k + 3 y = 13 → 3 y = 13 − k → y = (13 − k)3
So, the solutions are: (x, y) = (k 3 , [13 − k]3 ).
(f ) If we follow the approach of part (e) then we get: (x, y) = (k 3 , [k − 13]3 ).
√
(g) Let y = s (i.e. y = s2 ) where s ∈ N0 and hence s = 21 − 3x where (21 − 3x ) ≥ 0 and x ∈ N0 .
It is obvious that only x = 0, 1, 2 satisfy the condition (21 − 3x ) ≥ 0 and hence the solutions are:
(x, y) = (0, 400), (1, 324) and (2, 144).
√
(h) Let 3 y = s (i.e. y = s3 ) where s ∈ Z and hence s = 128 − 5x where x ∈ N0 . Therefore, the
solutions are: (x, y) = (k, [128 − 5k ]3 ) where k ∈ N0 .
2. Find all x, y, z ∈ Z that satisfy the following equations:
√ √ √ √ √ √ √ √ √
(a) x + y + z = 5. (b) x − y − z = 5. (c) x + y − z = 5.
√ √ √ √ √ √
(d) x + y + 3 z = 5. (e) x y + y x = z. (f ) 3x + 5y − 3 z = 7.
Solution:
(a) If we do what we did in part (a) of Problem 1 we get the following (x, y, z) solutions:
(0, 0, 25) (0, 1, 16) (0, 4, 9) (0, 9, 4) (0, 16, 1) (0, 25, 0) (1, 0, 16)
(1, 1, 9) (1, 4, 4) (1, 9, 1) (1, 16, 0) (4, 0, 9) (4, 1, 4) (4, 4, 1)
(4, 9, 0) (9, 0, 4) (9, 1, 1) (9, 4, 0) (16, 0, 1) (16, 1, 0) (25, 0, 0)
2 2 2 0
(b) Let x = k , y = s and z = t where k, s, t ∈ N . So, we can write the given equationas k −s−t = 5,
i.e. k = 5 + s + t. Accordingly, the solutions are given by: (x, y, z) = [5 + s + t]2 , s2 , t2 . For example,
given s = 2 and t = 7 we get the solution (x, y, z) = (196, 4, 49).
(c) We have 3 cases:
• x = z and hence y must be 25. Thus the solutions are: (x, y, z) = (k, 25, k) where k ∈ N0 .
• y = z and hence x must be 25. Thus the solutions are: (x, y, z) = (25, k, k) where k ∈ N0 .
• x 6= z and y 6= z and hence x, y, z are perfect squares. So, let x = k 2 , y = s2 and z = t2 (where
k, s, t ∈ N0 ) and hence we can write the given equation ask + s − t = 5, i.e. t = k + s − 5. Accordingly,
the solutions are given by: (x, y, z) = k 2 , s2 , [k + s − 5]2 . However, we need to impose the condition
that (k + s) ≥ 5. For example, given k = 2 and s = 7 we get the solution (x, y, z) = (4, 49, 16).
(d) We have two cases to consider:
• z ≥ 0 and hence if we do what we did in part (a) we get the following (x, y, z) solutions:
(0, 0, 125) (0, 1, 64) (0, 4, 27) (0, 9, 8) (0, 16, 1) (0, 25, 0) (1, 0, 64)
(1, 1, 27) (1, 4, 8) (1, 9, 1) (1, 16, 0) (4, 0, 27) (4, 1, 8) (4, 4, 1)
(4, 9, 0) (9, 0, 8) (9, 1, 1) (9, 4, 0) (16, 0, 1) (16, 1, 0) (25, 0, 0)
3
√ √ √ √
•√z < 0 and hence if z = t (where t ∈ Z) then x + y − |t| = 5, i.e. |t| = x + y − 5 where
√
( x + y) > 5. Therefore, the solutions in this case are: (x, y, z) = k 2 , s2 , [5 − k − s]3 where
k, s ∈ N0 and 5 < (k + s).
So in brief, the solutions of the given equation are the union of the sets of solutions in these two cases.[49]
(e) x and y are perfect squares and hence
let x = k 2 and y = s2 where k, s ∈ Z. Therefore, the solutions
2 2 2 2
are: (x, y,
√ z) = k , s , k |s| + s |k| .
(f ) Let 3 z = t (i.e. z = t3 ) where t ∈ Z and hence t = 3x + 5y − 7 where x, y ∈ N0 . Therefore, the
solutions are: (x, y, z) = (k, s, [3k + 5s − 7]3 ) where k, s ∈ N0 .
[49] We note that the solution in the second case applies even to the solutions of the first case (by keeping the condition
k, s ∈ N0 and dropping the condition 5 < k + s) and hence we could have considered only one case. However, we preferred
to deal with two separate cases to show the finitely many solutions in the case of z ≥ 0 and the infinitely many solutions
in the case of z < 0.
5.6 Diophantine Equations Involving Fractions 78
x2 y + x + y
=z
xy 2 + y + a
where x, y, z ∈ N and a is a specific natural number.
Solution: We have two categories of solutions for this equation:
(a) Solutions of general type, i.e. those solutions that can be inferred from the form of this equation.
We can easily identify two solutions of general type:
5.6 Diophantine Equations Involving Fractions 79
x2 y + x + y (az 2 )2 (az) + az 2 + az a3 z 5 + az 2 + az a3 z 4 + az + a
2
= 2 2
= 3 4 = 3 4 z=z
xy + y + a (az )(az) + az + a a z + az + a a z + az + a
(b) Solutions of special type, i.e. those solutions that depend (in their existence and nature) on the
specific a. For example, if a = 5 then (x, y, z) = (11, 2, 5) is also a solution to this equation while
if a = 13 then (x, y, z) = (47, 1, 37) and (49, 2, 23) are also solutions. These solutions should be
investigated within the specific problem (as determined by the specific value of a).
4. Investigate the solutions of the following equations:
(a) xy + xy = z (x, y, z ∈ Z). (b) x1 + y1 = z1 (x, y, z ∈ N).
Solution:
(a) It is obvious that y 6= 0 and x must be divisible by y. So, if y = s (where Z ∋ s 6= 0) then x = ks
(where k ∈ Z) and hence z = k +ks2 . So, the solution of the given equation is (x, y, z) = (ks, s, k +ks2 ).
(b) Let x = k and y = s where k, s ∈ N. Hence:
1
x + y1 = z1 → 1 1
k + s = z
1
→ k+s
ks = z
1
→ ks
z = k+s
Now, since z ∈ N then we must impose the condition that (k + s)|(ks). So, the general solution of the
ks
given equation is: (x, y, z) = k, s, k+s where k, s ∈ N and (k + s)|(ks). The following are some of the
specific solutions:
(2, 2, 1) (3, 6, 2) (4, 4, 2) (4, 12, 3) (5, 20, 4) (6, 3, 2) (6, 6, 3)
It is worth noting that the solution (x, y, z) = (2n, 2n, n) (which is a special case of the above general
solution) applies to all n ∈ N.
5. Find all the solutions of the equation xy + xy = a (where x, y ∈ Z) for a = 0, 1, 2.
Solution: This equation is the same as the equation of part (a) of Problem 4. So, all we need to do is
to find k, s ∈ Z such that k + ks2 = 0, 1, 2. Now:
• For a = 0 we have k + ks2 = k(1 + s2 ) = 0. So, k = 0 (noting that 1 + s2 6= 0) and hence the solution
of the given equation is (x, y) = (0, s) where Z ∋ s 6= 0.
• For a = 1 we have k + ks2 = 1 which has no solution for k = 0. For k 6= 0 we divide the equation by
k to obtain 1 + s2 = 1/k which implies that k|1 and hence k = ±1. Now:
If k = −1 then we have s2 + 2 = 0 which has no solution.
If k = 1 then we have s2 = 0 (i.e. s = 0) which is not acceptable.
So in brief, for a = 1 the given equation has no solution.[50]
• For a = 2 we have k + ks2 = 2 which has no solution for k = 0. For k 6= 0 we divide the equation by
k to obtain 1 + s2 = 2/k which implies that k|2 and hence k = ±1, ±2. Now:
For k = −1 we have s2 + 3 = 0 which has no solution.
For k = +1 we have s2 − 1 = 0 (i.e. s = ±1) and hence (x, y) = (1, 1) and (x, y) = (−1, −1).
For k = −2 we have s2 + 2 = 0 which has no solution.
For k = +2 we have s2 = 0 (i.e. s = 0) which is not acceptable.
So in brief, for a = 2 the given equation has only two solutions: (x, y) = (1, 1) and (x, y) = (−1, −1).
6. Find all x, y, z ∈ N such that: z = x1 + y1 + xy
2
.
Solution: If we multiply the two sides by xy we get xyz = x + y + 2. Now, we have two cases:
• z = 1 and hence xy = x + y + 2. Now, it is obvious that x = 1 or y = 1 is not a possibility (because
we get 0 = 3). So, we must have x > 1 and y > 1. However, if x > 1 and y > 1 then the LHS of
[50] Another (and simpler) approach to reach this conclusion is that x and y must have the same sign (because otherwise the
sum will be negative) and hence (whether x ≥ y or x < y) the LHS must be greater than 1 (noting that xy = 0 is not a
possibility), i.e. the equation has no solution.
5.6 Diophantine Equations Involving Fractions 80
xy = x + y + 2 becomes greater than its RHS if x > 4 or y > 4. So, all we need to do is to test
the (nine) combinations of x = 2, 3, 4 and y = 2, 3, 4 (to see which combinations satisfy the equation
xy = x + y + 2). On doing so we get only two solutions: (x, y, z) = (2, 4, 1) and (4, 2, 1).
• z > 1 and hence the LHS of xyz = x + y + 2 becomes greater than its RHS if x > 3 or y > 3. So, all
we need to do is to test the (nine) combinations of x = 1, 2, 3 and y = 1, 2, 3 (to obtain the values of
z corresponding to these combinations). On doing so we get only three solutions: (x, y, z) = (1, 1, 4),
(1, 3, 2) and (3, 1, 2).
So in brief, the given equation has only these five solutions.
7. Find all x, y, z ∈ N that satisfy the following equations:
(a) x3 + y7 = z. (b) x1 + y2 + z3 = 4.
Solution:
(a) The LHS cannot exceed 10 (i.e. when x = y = 1). Therefore, all we need to do is to solve the
equation: x3 + y7 = z for z = 1, 2, . . . , 10. Accordingly:
• x3 + y7 = 1: we must have x > 3 and y > 7 (because otherwise the LHS becomes > 1). We must also
have x < 25 and y < 29 (because otherwise the LHS becomes < 1). So, on testing these possibilities
(i.e. x = 4, 5, . . . , 24 and y = 8, 9, . . . , 28) we find the following four solutions: (x, y, z) = (4, 28, 1),
(6, 14, 1), (10, 10, 1) and (24, 8, 1).
• x3 + y7 = 2: by a similar argument to that in the previous point we must have 1 < x < 13 and 3 < y <
15, and hence on testing these possibilities we find the following four solutions: (x, y, z) = (2, 14, 2),
(3, 7, 2), (5, 5, 2) and (12, 4, 2).
• For z = 3, 6, 7, 9 we find no solution.
• For z = 4, 5, 8, 10 we find the following five solutions: (x, y, z) = (1, 7, 4), (6, 2, 4), (2, 2, 5), (3, 1, 8)
and (1, 1, 10).
So in brief, this equation has only these 13 solutions.
(b) If z > 3 then the LHS becomes less then 4. So, we must have z = 1, 2, 3 and hence:
• z = 1 and hence x1 + y2 = 1. Now, we must have x > 1 and y > 2. However, if y > 2 then we must
have x < 4. So in brief, we must have x = 2, 3 that is: y2 = 12 (i.e. y = 4) and y2 = 32 (i.e. y = 3). So,
we found the following two solutions: (x, y, z) = (2, 4, 1) and (3, 3, 1).
• z = 2 and hence x1 + y2 = 25 , i.e. x2 + y4 = 5. Now, we must have y = 1 and hence x = 2. So, we found
the following solution: (x, y, z) = (2, 1, 2).
• z = 3 and hence x1 + y2 = 3. The only possibility in this case is x = y = 1. So, we found the following
solution: (x, y, z) = (1, 1, 3).
So in brief, this equation has only these 4 solutions.
8. Find all x, y, z ∈ N that satisfy the following equations:
(a) xy + yz + xz = 1. (b) xy + yz + xz = 2. (c) xy + yz + xz = 3.
Solution:[51]
(a) The LHS of this equation is greater than 1 because at least one of the variables is greater than or
equal to another variable and hence one term at least is greater than or equal to 1 and thus the sum
of the three terms must be greater than 1 (noting that the sum of the other two terms is greater than
0).[52] Hence, this equation has no solution.
(b) We have two cases to consider:
• The triple equality x = y = z does hold and hence the LHS of the equation is 3, i.e. there is no
solution.
• The triple equality x = y = z does not hold and hence one of the variables x, y, z must be greater
than another variable. So, let assume (without loss of generality since it is a matter of labeling) that x
is the greater variable. Hence, (with a proper labeling of y and z) we have one of the following three
situations:
⋆ x = y > z and hence xy = 1 while yz > 1. So, the LHS is greater than 2, i.e. there is no solution.
[51] We refer the reader to Problem 8 of § 7.3 for another method for solving this Problem.
[52] For example, if x ≥ y ≥ z then (x/y) ≥ 1 while if x ≤ y ≤ z then (z/x) ≥ 1.
5.7 Diophantine Equations Involving Roots and Fractions 81
⋆ x > y = z and hence xy > 1 while yz = 1. So, the LHS is greater than 2, i.e. there is no solution.
⋆ x > y > z and hence xy > 1 and yz > 1. So, the LHS is greater than 2, i.e. there is no solution.
So in brief, this equation has no solution.
(c) We have two cases to consider:
• The triple equality x = y = z does hold and hence the LHS of the equation is 3. So, in this case we
have the solution (x, y, z) = (k, k, k) where k ∈ N.
• The triple equality x = y = z does not hold and hence one of the variables x, y, z must be greater
than another variable. So, let assume (without loss of generality) that x is the greater variable. Hence,
we have one of the following three situations:
⋆ x = y > z and hence we have:
1 + xz + xz = 3 → x z
z + x =2 → x2 − 2xz + z 2 = 0 → (x − z)2 = 0
i.e. x = z which is a contradiction. Hence, there is no solution.
⋆ x > y = z and hence we have:
x y x y
y +1+ x =3 → y + x =2 → x2 − 2xy + y 2 = 0 → (x − y)2 = 0
i.e. x = y which is a contradiction. Hence, there is no solution.
⋆ x > y > z and hence x = z + a and y = z + b where 2 ≤ a and 1 ≤ b with a > b. Accordingly:
x y z z+a z+b z
+ + = + +
y z x z+b z z+a
a2 z + ab2 + 2abz + 3az 2 + b2 z + 3bz 2 + 3z 3
=
abz + az 2 + bz 2 + z 3
2(abz + az + bz 2 + z 3 ) a2 z + ab2 + az 2 + b2 z + bz 2 + z 3
2
= +
abz + az 2 + bz 2 + z 3 abz + az 2 + bz 2 + z 3
a z + ab + az + b z + bz + z 3
2 2 2 2 2
= 2+
abz + az 2 + bz 2 + z 3
a z + ab2 + b2 z + (az 2 + bz 2 + z 3 )
2
= 2+
abz + (az 2 + bz 2 + z 3 )
Now, (a2 z + ab2 + b2 z) > abz (noting that a2 z > abz since a > b) and hence the last term in the last
equation is greater than 1, i.e. the LHS of the given equation is greater than 3 and hence there is no
solution.
So in brief, the only solution of this equation is (x, y, z) = (k, k, k) where k ∈ N.
2s
Therefore, s − 2 must divide 2s (since x is a perfect square noting as well that s−2 is rational). Now,
s − 2 divides 2s − 4 and s − 2 supposedly divides 2s and hence s − 2 divides their difference which is 4.
5.8 Diophantine Equations Involving Factorials 82
So, s − 2 = ±1, ±2, ±4 and hence s = 1, 3, 4, 6 (where we take only the positive values of s). On trying
2
2s
these values of s on the equation x = s−2 we find that only s = 3, 4, 6 produce valid solutions to
the original equation.
So in brief, the solutions of the given Diophantine equation are: (x, y) = (36, 9), (16, 16) and (9, 36).
2
3s
(b) If we repeat the argument of part (a) with replacing 2 by 3 we get x = s−3 and hence s − 3
divides 9. So, s − 3 = ±1, ±3, ±9 and hence s = 2, 4, 6, 12 (where we take only the positive values of
2
3s
s). On trying these values of s on the equation x = s−3 we find that only s = 4, 6, 12 produce valid
solutions to the original equation.
So in brief, the solutions of the given Diophantine equation are: (x, y) = (144, 16), (36, 36) and (16, 144).
(c) We choose to solve this part (more simply) √ by a logical argument (rather than by a mathematical
argument as we did in part a), that is: 1/ x must √ be 1 because otherwise the LHS will be less than
1/2 (noting that the√highest magnitude that 1/ x can assume if it is not 1 is 1/2 since x must be a
√
perfect square). So, x must be 1 (i.e. x = 1) and hence y must be 2 (i.e. y = 4).
So in brief, we have only one possible solution, i.e. (x, y) = (1, 4).
(d) We
√ argue logically (similar to what we did in part c) that is: √
• 1/ x cannot be 1 because otherwise the LHS will be either 0 (i.e. if 1/ y is 1) or greater than 1/3
√ √
(i.e. if 1/ y is less than 1 noting that the highest magnitude that 1/ y can assume if it is less than 1
is 1/2
√ since y must be a perfect square).
• 1/ x cannot be less√ than 1/2 because otherwise the LHS will be less than 1/3 (noting that the highest
magnitude that √ 1/ x can assume if it is less than 1/2 is 1/3 since x must be a perfect square).
√
Therefore, 1/ x must be 1/2 (i.e. x = 4) and hence 1/ y must be 1/6 (i.e. y = 36).
So in brief, we have only one possible solution, i.e. (x, y) = (4, 36).
2. Find all x, y, z ∈ N that satisfy the following equations:
(a) √1x + √1y + √1z = 2. (b) √1x + √1y = √1z .
Solution:
(a) x, y, z must be perfect squares (for reasons explained earlier). Now:
If all the square roots are greater than 1 then the LHS will be less than 2, and this implies that at least
one of the square roots must be 1 (i.e. at least one of the variables must be 1).
If more than one of the square roots are 1 then the LHS will be greater than 2, and this implies that
exactly one of the square roots must be 1 (i.e. exactly one of the variables must be 1).
If one of the remaining square roots is greater than 2 then the LHS will be less than 2, and this implies
that one of the remaining square roots must be 2 (i.e. one of the remaining variables must be 4).
Accordingly, the other remaining variable must be 4.
So in brief, the solutions of the given equation are: (x, y, z) = (1, 4, 4), (4, 1, 4) and (4, 4, 1).
We finally note that a simpler approach is to use the solutions of part (b) of Problem 2 of § 5.6 by
squaring the variables since the given equation is equivalent to X1 + Y1 + Z1 = 2 where X, Y, Z represent
the square roots of x, y, z. However, we preferred the above approach for the sake of diversity and
because it is not dependent on having the solutions of another equation (noting that we use the method
of comparison occasionally; see part b).
(b) If we write this equation as X1 + Y1 = Z1 (where these capital symbols represent radicals of their
corresponding variables) then we can obtain the solutions of the given equation from the solutions of
the equation of part (b) of Problem 4 of § 5.6 by squaring the values of the variables of those solutions.
The following are some solutions (corresponding to the sample solutions given in Problem 4 of § 5.6):
(4, 4, 1) (9, 36, 4) (16, 16, 4) (16, 144, 9) (25, 400, 16) (36, 9, 4) (36, 36, 9)
Solution:
13
(a) By inspection, this equation has no solution for y < 13. For y ≥ 13 we have 11x = 0 whose only
solution is x = 13k where k ∈ Z. On substituting this in the given equation we get:
11(13k) − y! = 13 → y!+13
k = 11×13 → k = (y!/13)+1
11
Now, 11 divides y!/13 (noting that y ≥ 13) but it does not divide 1 and hence 11 does not divide
(y!/13) + 1. This means that there is no integer k that satisfies the given equation and hence the given
equation has no solution.
7
(b) By inspection, this equation has no solution for y < 7. For y ≥ 7 we have x = 6, i.e. x = 6 + 7k
where k ∈ Z. On substituting this in the given equation we get:
15(6 + 7k) − 19y! = 538 → k = 19y!+448
105
Now, 105 divides 19y! (noting that 105 = 3 × 5 × 7 and y ≥ 7) but it does not divide 448 and hence
105 does not divide 19y! + 448. This means that there is no integer k that satisfies the given equation
and hence the given equation has no solution.
7
(c) By inspection, this equation has no solution for y < 7. For y ≥ 7 we have x3 = 3 which has no
solution. Hence, the given equation has no solution.
2. Find all the solutions of the following equations (where x ∈ Z and y ∈ N0 ):
(a) x2 − y! = 2. (b) x2 − y! = 3. (c) x2 − y! = 1. (d) 16x + 9y! = 121.
Solution:
3 3
(a) For y > 2 we have x2 = 2. However, x2 = 2 has no solution (because 2 is quadratic non-residue of
3; see § 1.6). So, if there is any solution then we must have y = 0 (and hence x2 − 1 = 2 which has no
solution) or y = 1 (and hence x2 − 1 = 2 which has no solution) or y = 2 (and hence x2 − 2 = 2, i.e.
x = ±2). So, the solutions are: (x, y) = (±2, 2).
4 4
(b) For y > 3 we have x2 = 3. However, x2 = 3 has no solution (because 3 is quadratic non-residue of
4). So, if there is any solution then we must have y = 0 (and hence x2 − 1 = 3, i.e. x = ±2) or y = 1
(and hence x2 − 1 = 3, i.e. x = ±2) or y = 2 (and hence x2 − 2 = 3 which has no solution) or y = 3
(and hence x2 − 6 = 3, i.e. x = ±3). So, the solutions are: (x, y) = (±2, 0), (±2, 1), (±3, 3).
(c) This is known as Brocard’s problem. The only known solutions are: (x, y) = (±5, 4), (±11, 5),
(±71, 7). It is unknown if the problem can have more solutions (so the problem is in the research
domain and hence it deserves the attention of the young ambitious mathematicians).
(d) For y = 0 and y = 1 we have x = 7. For y > 1 the LHS is even while the RHS is odd and hence
there is no solution. So, the only solutions to this equation are: (x, y) = (7, 0) and (x, y) = (7, 1).
3. Find all the solutions of the following equations (where x, y ∈ Z and z ∈ N0 ):
(a) 2x + 3y − 6z! = 222. (b) 3x + 5y + 15z! = 17. (c) x2 + y 2 + z! = 24. (d) x2 + y 2 − z! = 3.
Solution:
3
(a) On reducing the equation in modulo 3 we get 2x = 0, i.e. x = 3k where k ∈ Z.
2
On reducing the equation in modulo 2 we get y = 0, i.e. y = 2s where s ∈ Z.
On substituting these into the original equation we get:
2(3k) + 3(2s) − 6z! = 222 → 6k + 6s − 6z! = 222 → k + s − z! = 37 → s = z! + 37 − k
So, the solutions are: (x, y, z) = (3k, 2t! + 74 − 2k, t) where k ∈ Z and t ∈ N0 .
5
(b) On reducing the equation in modulo 5 we get 3x = 2, i.e. x = 4 + 5k where k ∈ Z.
3
On reducing the equation in modulo 3 we get 2y = 2, i.e. y = 1 + 3s where s ∈ Z.
On substituting these into the original equation we get:
3(4 + 5k) + 5(1 + 3s) + 15z! = 17 → 12 + 15k + 5 + 15s + 15z! = 17 → s = −k − z!
0
So, the solutions are: (x, y, z) = (4 + 5k, 1 − 3k − 3t!, t) where k ∈ Z and t ∈ N .
(c) z cannot be greater than 4 because otherwise the LHS will be greater than 24. So, all we need to
do is to consider z = 0, 1, 2, 3, 4. On doing so we get the following five solutions:
(x, y, z) = (−3, ±3, 3) (x, y, z) = (0, 0, 4) (x, y, z) = (3, ±3, 3)
5.9 Trigonometric Diophantine Equations 84
4
(d) For z > 3 we have x2 +y 2 = 3 which has no solution. So, all we need to do is to consider z = 0, 1, 2, 3.
On doing so we get the following twenty solutions:
(±3, 0, 3) (±2, −1, 2) (±2, 0, 0) (±2, 0, 1) (±2, 1, 2)
(±1, −2, 2) (±1, 2, 2) (0, ±3, 3) (0, ±2, 0) (0, ±2, 1)
[53] In fact, it is also continuation to the material about this topic which we investigated in the first volume of this book.
85
6.1 General Issues about Diophantine Systems 86
solution (or sub-integer solution if there are extra conditions imposed on the system by the given
problem such as being positive or non-negative or within certain range as demanded for instance by
physical requirements).
5. Discuss briefly “linear” and “non-linear” systems of Diophantine equations.
Solution: We note the following:
• Systems of Diophantine equations can be classified into two main categories: linear (when all the
equations of the system are linear) and non-linear (when some or all of the equations of the system are
non-linear).
• Systems of linear Diophantine equations can be easily solved by the well known (and standard)
methods of linear algebra where only the integer (or sub-integer such as positive integer) solutions are
accepted. Other methods (including the methods used for solving systems of non-linear equations) are
also possible to use in general for solving systems of linear equations (as will be discussed later).
• Non-linear systems of Diophantine equations can be solved usually by the well known algebraic
methods of solving systems of equations (which are not restricted to Diophantine equations) such as
by elimination, comparison and substitution where only integer (or sub-integer) solutions are accepted.
However, it should be noted that certain methods (which are mostly investigated in linear algebra)
are not applicable in solving non-linear Diophantine systems since these methods are specific to linear
systems.
6. Outline some general recommendations or guidelines that should be followed in solving systems of
Diophantine equations (especially the non-linear ones).
Solution: For example:
• Initial sensibility checks (such as parity or modularity or sign or magnitude checks) are strongly
recommended (if not required) as the first step in tackling and solving Diophantine systems as well as
in tackling and solving individual Diophantine equations (see Problem 5 of § 5.1 as well as Problem 7
of the present section). In many cases, solving the given system of equations does not need more than
these initial sensibility checks since these checks can reveal that the system either has no solution (e.g.
because one of the equations has no solution due to parity violation or modularity inconsistency or
because some of the equations require conditions that contradict the conditions required by the other
equations) or because the solution becomes so obvious by these initial sensibility checks.
• It is recommended to test all the obtained solutions on the given system of equations. This is because
some of the algebraic manipulations which are (usually) required during the process of solving systems of
non-linear equations (such as raising to powers or multiplication or division by a variable) can introduce
foreign solutions and hence by testing the obtained solutions we make sure that no foreign solution is
introduced during these manipulations.
• Systems of linear equations can be considered as a special case of systems of non-linear equations
and hence they can be solved by the methods of systems of non-linear equations (when applicable) as
well as by the methods and techniques which are specific to systems of linear equations (such as by the
methods of matrices of linear algebra).
• Unlike linear systems of Diophantine equations, there is no standard (or systematically applicable)
method or technique for solving non-linear systems of Diophantine equations and hence solving these
systems is a mix of art and science (where the art is required for selecting the main approach or strategy
for solving the system while the science is needed for employing and applying the technicalities of the
selected approach). Therefore, it is recommended to investigate various potential methods or strategies
before setting off and making the choice of the best (or even applicable) strategy to use. Investing
some time and effort in this initial investigation can be very rewarding and beneficial and can save
considerable amounts of time and effort in trying to solve the system in a rather random approach and
chaotic manner (i.e. by a “hit-and-miss” approach).
• If the system of Diophantine equations contains an equation whose solution is known (or can be
obtained easily or more easily) then the best approach for solving the system is to test the solutions
of that equation on the other equations where only the common solutions (if any) to all equations are
accepted.[54] This is particularly true when some of the equations in the (non-linear) system are linear.
[54] This is based on the obvious fact that the solution of the system is the intersection of the solutions of the individual
6.2 Systems of Diophantine Equations 87
This approach usually saves considerable amounts of time and effort in trying to solve the system by
other methods. In fact, in some cases this can be the only viable method for solving the system.
7. Discuss (briefly) initial sensibility checks and the importance of applying them when tackling a Dio-
phantine system problem.
Solution: Conducting initial sensibility checks as a first step in dealing with Diophantine problems
applies not only to single Diophantine equations (which we investigated in Problem 5 of § 5.1) but also
to systems of Diophantine equations. So, if a system contains a non-solvable equation then the system
is not solvable. Therefore, it is worthwhile to inspect the individual equations of the system (to check
if they are solvable or not) before trying to solve the system. For example, if we are given the following
system:
x2 + y 3 − z 4 = 3 2x + y 2 − 3y − 6z 2 = 75 (x, y, z ∈ Z)
then a quick initial inspection should reveal that the second equation has no solution (due to parity
violation) and hence the system has no solution (with no need for inspecting the first equation or the
system as a whole).
It is also worthwhile to inspect the characteristics of the system as a whole (i.e. not only its individual
equations separately) to see if it is sensible for the system to have a solution or not. For example, if we
are given the following system of Diophantine equations:
3x4 + 7y 2 + z 2 = 0 x2 + y 4 = 37 (x, y, z ∈ Z)
then a quick initial inspection should reveal that the first equation has only the trivial solution (i.e.
x = y = z = 0), while the second equation can have only non-trivial solutions (i.e. it cannot accept
the trivial solution). This means that the two equations cannot have a common solution and hence the
system has no solution (although both equations are solvable individually). Initial inspection to the
system as a whole should also reveal that the following system:
3x2 + 5y 2 − z = 0 2x2 + 7y 4 + z 3 + 9 = 0 x+y+z+1=0 (x, y, z ∈ Z)
has no solution because if the first equation has a solution then z must be non-negative, while if the
second equation has a solution then z must be negative. So, the two equations cannot have a common
solution and hence this system cannot have a solution (although each equation in the system is solv-
able).
Also see Problem 5 of § 5.1.
equations (see Problem 1) and hence the set of solutions of the system cannot exceed the set of solutions of any one of
the equations in the system, i.e. the set of solutions of the system is a (proper or improper) subset of the set of solutions
of any one of the equations in the system.
6.2 Systems of Diophantine Equations 88
So, the only solution to this system is (x, y) = (−5, −14). Also see part (a) of Problem 1 of § 6.3.
(b) From the first equation we get x = (11y 2 + 8)2 . On substituting this into the second equation and
simplifying we get 484y 5 + 704y 3 − 1033y 2 + 256y = 411 whose only (integer) solution is y = 1 (and
hence x = 192 = 361). So, the only solution to this system is (x, y) = (361, 1).
(c) We have two cases:
• x = 0 and hence (from the second equation) we get y = 0.
• x 6= 0 and hence:
If y = 0 then (from the second equation) we get x2 − x = 0 whose solution is x = 1 (noting that x 6= 0).
If y 6= 0 then (from the first equation) we get:
x3 y + y 3 x − xy = 0 → x3 y + y 3 x = xy → x2 + y 2 = 1
The last equation has no solution (noting that x 6= 0 and y 6= 0).
So in brief, the given system has only two solutions: (x, y) = (0, 0) and (x, y) = (1, 0).
(d) If xy = 0 then (x, y) = (0, 0) is a solution.
If xy 6= 0 then on dividing the first equation by x and the second equation by y we get:
x2 + xy + 2y = 0 and y 2 + xy + 2x = 0
This implies that y = ±x. On substituting these into the first equation we get:[55]
x3 + x + 2x2 = 0 and x3 − x − 2x2 = 0
On solving these equations we get x = −1 from the first equation (and no integer solution 6= 0 from
the second equation). On substituting x = −1 in any one of the given equations and solving for y we
get y = −1.
So in brief, the given system has only two solutions: (x, y) = (0, 0) and (x, y) = (−1, −1).
(e) Someone with modest knowledge in mathematics should immediately realize that the first equation
represents a parabola while the second equation represents a circle, and hence the problem can be solved
“graphically” (possibly with no need to make any plot). If we put these equations in their standard
forms (so that we can easily identify the shape and position of the graphs they represent) then we have:
y + 3 = −(x − 1)2 (x + 3)2 + (y − 5)2 = 4
So, now it is obvious that the first equation represents a parabola which concaves down with vertex at
(x, y) = (1, −3) while the second equation represents a circle with radius 2 and center at (x, y) = (−3, 5)
and hence they cannot have a common point. Therefore, this system obviously has no solution. Also
see part (d) of Problem 1 of § 6.3.
(f ) In part (j) of Problem 1 of § 4.1.5 of V1 we obtained the solutions of 15x + 13xy − 20y = 0 which
are: (x, y) = (2, −5), (0, 0), (−10, −1). So, the easiest approach for solving this system is to test the
solutions of this equation on the other equations in the system where we accept only the solutions
which are common to all the equations in the system.[56] If we do so we will find out that only the
solution (x, y) = (2, −5) satisfies all the equations of the system and hence this is the only solution to
the system.
(g) We note that the last equation in this system is easy to solve (since we have a few possibilities for
x and y to satisfy this equation). The solutions of the last equation are: (x, y) = (±1, 4), (±1, −4),
(±4, 1) and (±4, −1). On testing these eight solutions on the other two equations in the system we find
that only the solution (x, y) = (4, −1) satisfies the other two equations. Hence, this system has only
one solution, i.e. (x, y) = (4, −1). Also see part (c) of Problem 1 of § 6.3.
(h) Initial inspection should reveal that the second equation has no solution because in modulo 5
5
this equation becomes y 2 = 3 which has no solution since 3 is not a quadratic residue of 5. So, this
system has no solution although the other two equations in the system have a common solution, i.e.
(x, y) = (7, −1).
[55] Thesame result will be obtained from substitution into the second equation.
[56] Thejustification of this approach is that the solution of the system is the intersection of the solutions of the individual
equations and hence the set of solutions of the system cannot exceed the set of solutions of any one of the equations in
the system, i.e. the set of solutions of the system is a (proper or improper) subset of the set of solutions of any one of
the equations in the system. Also see Problem 6 of § 6.1.
6.2 Systems of Diophantine Equations 89
(and hence x = 2). So, the given system has only two solutions, i.e. (x, y, z) = (2, ±3, 0).
(e) We have:
3 x3 − y 3 + 3xy + z 3 + 3y 3 − 8xy − 3z 3 = (3 × 103) + 101
3x3 + xy = 410
410
y = − 3x2
x
i.e. x is a divisor of 410. Now, the divisors of 410 are 1, 2, 5, 10, 41, 82, 205, 410 and their negatives
(i.e. 16 divisors in total). So, from the last equation we obtain the value of y corresponding to each one
of these 16 divisors (which represent the values of x) and hence we get 16 (x, y) pairs. On trying these
16 pairs on the three equations of the system and solving for z we find that only the pair (x, y) = (5, 7)
produces a consistent result (where z corresponding to this pair is 6). Hence, the only solution of the
given system is (x, y, z) = (5, 7, 6).
(f ) The second equation implies z ≥ 0 while the third equation implies z ≤ 16. So, all we need to do
is to try the values z = 0, 1, . . . , 16 in the first equation to get the corresponding values of x and hence
obtaining 34 pairs of (±|x|, z). On trying these 34 pairs[57] in the second and third equations we get
the corresponding values of y. On doing this we find that only the pair (x, z) = (−1, 9) produces a
consistent result (where y corresponding to this pair is 2). Hence, the only solution of the given system
is (x, y, z) = (−1, 2, 9).
3. Find all x, y ∈ Z such that f1 = f2 = f3 = f4 where:
Also, from the price limits and the purchased quantities we get the following inequalities:
1510 ≤ a ≤ 1710 and 1420 ≤ b ≤ 1570
Now, if we solve Eq. 28 considering the restrictions imposed by these inequalities we get only one ac-
ceptable integer solution which is (a, b) = (1598, 1463).[59] Accordingly:
[57] Actually, we try only the integers of these pairs.
[58] The easiest way to solve this system is by solving the equation f1 − f3 = 0, i.e. 22y − y 3 + 6441 = 0. The only (integer)
solution of this equation is y = 19 and hence x = −33 (where this can be obtained, for instance, from f1 − f2 = 0).
[59] From Eq. 28 we have a = (2753.55 − 0.91b)/0.89. So, on trying 1420 ≤ b ≤ 1570 we get only two integer solutions:
(a, b) = (1598, 1463) and (1507, 1552). However, the latter solution is not acceptable because 1510 ≤ a ≤ 1710.
6.3 Solving Systems of Diophantine Equations Graphically 91
• Regarding the orange deal we have the following system of simultaneous equations:
1.71x + 1.63y + 1.51z = 1598 and x + y + z = 1000
where x, y, z are the numbers of kilograms of class A, B, C of orange which we bought. On solving this
system[60] we get: (x, y, z) = (1.5z − 400, 1400 − 2.5z, z). Now, we must have:
x ≥ 100 → 1.5z − 400 ≥ 100 → z ≥ 500/1.5 → z ≥ 334
y ≥ 100 → 1400 − 2.5z ≥ 100 → z ≤ 1300/2.5 →
z ≤ 520
So, z = 400 and thus (x, y, z) = (200, 400, 400) or z = 500 and thus (x, y, z) = (350, 150, 500) . How-
ever, the latter solution is not acceptable because it violates the condition of multiples of 100’s. So,
(x, y, z) = (200, 400, 400).
• Regarding the apple deal we have the following system of simultaneous equations:
1.57X + 1.49Y + 1.42Z = 1463 and X + Y + Z = 1000
where X, Y, Z are the numbers of kilograms of class A, B, C of apple which we bought. On solving this
system[61] we get: (X, Y, Z) = (0.875Z − 337.5, 1337.5 − 1.875Z, Z). Now, we must have:
X ≥ 100 → 0.875Z − 337.5 ≥ 100 → Z ≥ 437.5/0.875 → Z ≥ 500
Y ≥ 100 → 1337.5 − 1.875Z ≥ 100 →
Z ≤ 1237.5/1.875 → Z ≤ 660
So, Z = 500 and thus (X, Y, Z) = (100, 400, 500) or Z = 600 and thus (X, Y, Z) = (187.5, 212.5, 600) .
However, the latter solution is obviously not acceptable. So, (X, Y, Z) = (100, 400, 500).
solution. On testing (x, y) = (−5, −14) on the system we find this is a solution. Hence, we conclude
graphically that (x, y) = (−5, −14) is the only solution of this system (which is a conclusion that we
obtained algebraically in part a of Problem 1 of § 6.2).
(b) If we plot these equations we get what we see in Figure 2. From this Figure it is obvious that this
system has only one possible solution (noting that x, y ∈ N0 because of the exponential equation) which
(by graphic inspection and verification) is (x, y) = (3, 2).
Figure 2: The plot of part (b) of Problem 1 of § 6.3. The parts of the curves outside the first quadrant
should be ignored.
(c) If we plot these equations we get what we see in Figure 3. This Figure (associated with the aware-
ness that all the “potential solutions” that belong to the circle are within the plotted area) should lead
to the definite conclusion that the only solution to this system is (x, y) = (4, −1). This conclusion was
obtained algebraically in part (g) of Problem 1 of § 6.2).
(d) In part (e) of Problem 1 of § 6.2, this system was “solved graphically” without visualization (i.e.
we used a “graphic argument” without plotting any graph). In the present Problem we plot the graphs
6.4 Final Thought about how to Solve Diophantine Problems 93
representing the two equations of this system to confirm our solution in that Problem (see Figure 4).
V1 for some recommendations and guidelines; also see Problem 5 of § 5.1 and Problem 6 of § 6.1 of
the present volume). Many Diophantine problems do not need in their solution more than an informed
inspection based on these initial and simple checks and tests and hence it is worthwhile to spend a few
minutes on doing this sort of initial inspection and tests which can save a considerable amount of time
and effort in trying to solve the given problem by the use of sophisticated approaches and techniques
(which may or may not lead to the required result).
2. Use computational tools (such as coding or spreadsheets or software packages) to give you an initial
impression and insight about the nature of the expected (and sought-after) solution(s). In fact, this
initial computational inspection can be a great help in identifying and producing a theoretical and
general argument (or proof or formulation or . . .) that solves the problem completely and unequivocally.
3. Use graphic tools (when possible and applicable) for initial inspection of systems of Diophantine equa-
tions by plotting the equations on the same graph to see if and where they have points of intersection
(see § 6.3). In fact, the use of these tools can lead to the final solution of the problem without further
inspection or work.
4. Classify the problem such as linear or non-linear, exponential or polynomial (involving quadratic or/and
cubic or . . .), 2- or 3- · · · or n-variable problem, etc.
5. Recall the standard methods of solution for the specific type (as identified according to the recommen-
dation of the previous point). Use previously-solved problems (related to the identified specific type)
as prototypes and models to see if it is possible to apply their methods of solution to the problem at
hand.
6. Consider comparing the given Diophantine equation to a similar equation whose solutions are known or
whose solutions are easier to obtain and hence obtain the solutions of the given equation with minimal
effort (or with no effort). See for instance Problem 3 of § 5.1.
7. Look for symmetry in the variables which can be exploited (for instance) in assuming temporarily
that the variables have a certain increasing or decreasing order. This should facilitate the search for a
solution (where the final and complete solution can be obtained eventually by permuting the solution
obtained on the base of ordering assumption). Also look for cyclic pattern in the variables where this
pattern can be exploited similarly (e.g. by assuming certain ordering in the variables).
8. Consider reducing the domain of solution temporarily until a solution is found (for the reduced domain)
where this solution can be extended and generalized later on to reach the final and complete solution
for the entire domain. For example, if we are dealing with a Diophantine equation in the domain of
integers Z involving variables with even powers then we can start by considering its solution in the
domain of natural numbers N (instead of Z) where the final and complete solution can be obtained
trivially later on by extending the domain to the negative integers (noting that even powers do not
distinguish between positive and negative bases).
9. Consider producting a factored expression involving variables (on the LHS) that is equal to a specific
number (on the RHS) where the factors involving variables (on the LHS) can be matched with numeric
factors (on the RHS) to produce systems of simultaneous equations that can be solved to produce the
solution(s) of the given problem. The number of the possible factors on the two sides should also be
considered in some problems since it can eliminate certain possibilities for the solution (see for instance
Problem 7 of § 5.2). Also consider employing divisibility arguments of one side (or of factors of one
side) by the other side (or by factors of the other side).
10. Consider employing modular arithmetic to reduce the given equation in certain moduli where the
relationship between ordinary and congruence equations (see § 2.7.6 of V1) can be exploited to infer
the solutions of the given equation (or to conclude that the given equation has no solution).
11. Recall basic rules and principles (such as ordering rules and principles). Examples of these rules and
principles are:
No (perfect) square can be between consecutive squares, no (perfect) cube can be between consecutive
cubes, and so on.
No (perfect) square can be the sum of two odd squares.
Any (perfect) cube can be expressed as a difference of two squares.
Fermat’s last theorem can also be considered in this regard since it eliminates certain possibilities of
6.4 Final Thought about how to Solve Diophantine Problems 95
solution.
12. Remember Pell’s equation (see § 1.2) when dealing with quadratic polynomial equations in 2-variables.
Consider manipulating the equation (if necessary) to put it in a standard Pell’s form (e.g. by scaling
the equation and completing squares to simplify the expressions and reducing the number of terms as
well as organizing the equation to identify and recognize the pattern). Also consider the generalized
form of Pell’s equation (not only its standard form). As soon as we solve the obtained Pell equation
we can try obtaining the solutions of the original equation by the reverse transformation (where we
accept only the integer solutions). However, we should keep in mind that the existence of solution to
the transformed Pell equation does not guarantee the existence of solution to the original equation (see
§ 1.2) since the reverse transformation may not produce integer solutions.
13. Remember Pythagorean triple rules and theorems when dealing with quadratic equations in 3 variables.
As in the previous point, consider manipulating the equation (if necessary) to put it in a standard
Pythagorean triple equation form (e.g. by completing the squares or/and by transforming the variables).
14. Consider upper and lower bounds on the potential solutions (e.g. when dealing with equations involving
fractions).
15. Consider sign bounds and bounding inequalities (e.g. when dealing with polynomials and exponentials).
16. Recall Wilson’s theorem when the equation involves factorial.
17. Consider special (or limiting or obvious or eccentric or . . .) cases and instances such as when one (or
more) of the variables is 0 or ±1 or goes to infinity. Such considerations can give an insight in the
solution (or reduce the possibilities or organize the approach of solution or . . .).
Give special attention to the dominating terms which can (for instance) impose limits or determine the
eventual tendency of the equation.
18. Use computational tools (such as coding or spreadsheets or software packages) to check the final answer
(if necessary) especially when you have some doubt or when the produced argument (or proof or
formulation or . . .) is very messy and susceptible to errors and mistakes.
Chapter 7
Inequalities
7.1 General Issues about Inequalities
1. Outline some basic rules that govern inequalities and hence they can (and should) be used to solve
inequality problems in number theory (as well as in other mathematical branches like analysis).
Solution: For example:
• We can add and subtract the same quantity to both sides.
• We can multiply and divide each side by the same (non-zero) quantity but the sense of inequality
should be reversed if the quantity is negative.
• The factorial function n! grows faster than the corresponding exponential function an (where a > 1
is constant) and hence n! becomes > an eventually (i.e. at high values of n).
• The exponential function an (a > 1, n > 0) grows faster than the corresponding polynomial function
(e.g. n5 ) and hence an becomes > n5 eventually.
• Higher order polynomials (e.g. n3 ) grows faster than the corresponding lower order polynomials (e.g.
n + 99) and hence the higher order becomes bigger (in magnitude) than the lower order eventually. In
particular, any (non-constant) polynomial will eventually exceed (in magnitude) any constant (polyno-
mial) function.
• An inequality involving absolute value represents double inequality. For example, |n| < 3 means
−3 < n < 3 while |n| > 3 means n < −3 and n > 3.
• Taking the absolute value of the two sides of an inequality whose both sides are negative should reverse
the sense of inequality (because it is equivalent to multiplication by −1). For example, if m, n < 0 and
m < n then |m| > |n|.
2. List some tools and techniques that can (and should) be used (at least as a first step) in inspecting and
investigating inequality problems.
Solution: The most common tools and techniques are:
• Graphs (whether in 1D or 2D or 3D depending on the nature of the problem and the number of
variables).[63]
• Tables of values (such as spreadsheets) where the sense of inequality can be observed as a function of
the value of variable(s).
• Tables of sign (see for instance Problem 3 of § 2).
• Coding and programming by using computer languages for systematic search and inspection. In fact,
this tool is usually more powerful than graphs and tables (especially in multivariate inequalities and
could be the only viable choice in such cases) since it can inspect a huge amount of possibilities and
values in reasonable time and with maximum reliability (if vigilance and caution are observed).
3. Which of the following inequalities is correct/incorrect:
(a) 92793284 > 39794729 . (b) 4321! > 1711251 . 2388
(c) C991 2388
< C1397 . 1127
(d) P528 1324
< P444 .
Solution: All these inequalities are incorrect because:
(a) The number of digits of 92793284 is (see Problem 10 of § 2):
⌊3284 log10 9279⌋ + 1 = ⌊13029.274⌋ + 1 = 13030
while the number of digits of 39794729 is:
⌊4729 log10 3979⌋ + 1 = ⌊17023.331⌋ + 1 = 17024
[63] 1Dgraph refers to the common technique of using number line (possibly truncated) to mark the critical values for the
inequality. 2D and 3D graphs should be obvious (e.g. the x, y and the x, y, z plots which are commonly used in calculus
and analysis).
96
7.2 Univariate Inequalities 97
1324
while the number of digits of P444 is:
$ 1324
% $ 1324 %
X X
log10 (k) + 1 = log10 (k) + 1 = ⌊1349.497⌋ + 1 = 1350
k=1324−444+1 k=881
So, to prove that (n + 1)6 + 3(n + 1)4 + 2 < (n + 1)! we need (by comparing Eqs. 29 and 30) to show
that:
(n7 + 3n5 + 2n) ≥ (6n5 + 15n4 + 32n3 + 33n2 + 18n + 4) (31)
Now:
n7 + 3n5 + 2n 1 + 3n−2 + 2n−6
=
6n5 + 15n4 + 32n3 + 33n2 + 18n + 4 6n−2 + 15n−3 + 32n−4 + 33n−5 + 18n−6 + 4n−7
> 1 + 3n−2 + 2n−6
where the last inequality is justified by the fact that for n ≥ 10 the denominator of the last fraction is
< 1 (as well as positive). Now, since (1 + 3n−2 + 2n−6 ) > 1 the inequality of Eq. 31 is true and hence
(n + 1)6 + 3(n + 1)4 + 2 < (n + 1)!. So, by mathematical induction we conclude that n6 + 3n4 + 2 < n!
for all n ≥ 10 and hence n6 + 3n4 + 2 > n! is true only for n = 0, 1, . . . , 9.
7.2 Univariate Inequalities 98
5n+1 = 5 × 5n = (4 × 5n ) + 5n (33)
Now, for all n > 11 we have (4 × 5n ) < n5n and hence (from Eqs. 32 and 33) we get:
P1 > P2 & P2 > P3 & P3 > P4 → P1 − P2 > 0 & P2 − P3 > 0 & P3 − P4 > 0
i.e. (n + 1)n+1 > (n + 1)!. Hence, by mathematical induction this inequality is true for all N ∋ n > 1.
7
6. Find n ∈ N such that 10n < 56 < 10n+1 .
Solution: We have:
7 7 67
log10 56 = 279936 log10 5 → 56 = 10log10 5 = 10279936 log10 5 ≃ 10195666.867
Hence, n = 195666.
7.3 Multivariate Inequalities 99
x
+ y
+ z r r √
y z x x y z xyz 3
µa = µg = 3
× × = 3
= 1=1
3 y z x xyz
where we used Euler’s criterion in step 3 (see § 1.9). It is worth noting that since p = 4k − 1 then
(p + 1)/4 is integer.
k k/g
4. Let m = aµ and n = aν where m, a, µ, n, ν ∈ Z. Show that if m = n then µ = ν where g = gcd(a, k).
Solution: We have:
k
m=n (given)
k
aµ = aν (m = aµ, n = aν)
k/g
µ = ν (rule 8 of § 2.7 of V1; see Problem 5 of § 2.7 of V1)
Note: the result of this Problem implies that we can divide the two sides of a congruence equation by
an integer a (which is a common factor of the two sides) without affecting the validity of the congruence
iff a is coprime to the modulo k.
p
5. Show that m = n iff m = n for every p ∈ P (where m, n ∈ Z).[65]
p
Solution: Regarding the if part, m = n means p|(m − n). Now, whatever the magnitude of (m − n)
there should be some p whose magnitude is bigger than the magnitude of m − n (due to the fact that
there are infinitely many primes). Noting that 0 is the only integer that is divisible by an integer which
is bigger in magnitude, we conclude that m − n = 0, i.e. m = n.
Regarding the only if part, m = n means m − n = 0 and hence p|(m − n) for any p ∈ P since 0
is divisible by any other integer. The result will follow from the fact that p|(m − n) is equivalent to
p
m = n.
p
Note: “the only if part” of this proposition is straightforward because if m = n then m = n for
every p ∈ P. However, “the if part” of this proposition requires some clarification to avoid potential
misunderstanding. In the above proof of “the if part” we are implicitly assuming that (m − n) has a
[65] Ina sense, this proposition is a stronger version of the proposition that we stated in § 2.7.6 of V1 (with minor differences
m
in symbolism), that is: x = y iff x = y for all m (where x, y ∈ Z and N ∋ m > 1). This is because m should have a
certain prime factorization where the divisibility by m depends on the divisibility by its prime factors. We did not use
this stronger version in V1 for the sake of simplicity noting that the version of V1 was sufficient for our purposes.
101
8.1 General Issues about Congruence Equations 102
given magnitude and this should suggest that m and n are fixed integers. So, “the if part” is essentially
about m and n as fixed integers and not about
them as integers
in whatever shape or form.
For instance, if n = 0 while m is a function say m ≡ f (x) such that for every p ∈ P we have f (x) = kp
p p
(for some x, k ∈ Z and k 6= 0) then we have f (x) = 0 for every p ∈ P (i.e. m = n for every p ∈ P)
although f (x) 6= 0 (i.e. m 6= n). The explanation of this is that the meaning of zero in a congruence
is not the same as the meaning of zero in an ordinary equality (and this should shed more light on the
meaning of zero in the above proof).
In this regard, we should mention the function f (x) = 6x2 + 5x + 1 which is proved in the literature
p
to be congruent to 0 for every p ∈ P (i.e. 6x2 + 5x + 1 = 0 has an integer solution for every p ∈ P)
p
although 6x2 + 5x + 1 = 0 has no integer solution. In other words, m = n for every p ∈ P while m 6= n
p
(where = and 6= indicate the existence and non-existence of an integer solution x).
k
6. Find the number of (modular) solutions of the exponential congruence equation ax = b (where a, b ∈ Z
are given constants, x ∈ N0 and k is a modulo that possesses a primitive root and it is coprime to a
and b).
Solution: Let r be a primitive root of k. Now, if we take the index of both sides of the given congruence
equation (see § 1.5) then we get:
φ(k) φ(k)
Ik,r (ax ) = Ik,r (b) → x Ik,r (a) = Ik,r (b)
This is a linear congruence equation which (accordingto the LCE theorem;
see §3.2.1 of V1) has either
no solution if d6 | Ik,r (b) or has d modular solutions in mod φ(k) if d|Ik,r (b) where d is the gcd of
Ik,r (a) and φ(k) .
7. Find the necessary and sufficient conditions for the following congruence quadratic equation to have
solutions:
p
ax2 + bx + c = 0 (a, b, c, x ∈ Z, a 6= 0, p is odd prime coprime to a)
Solution: Regarding the necessary condition, let assume that the given congruence is solvable and
p p
hence we have some X ∈ Z such that aX 2 + bX + c = 0, i.e. aX 2 + bX = −c. Now:
p
(2aX + b)2 = 4a2 X 2 + 4abX + b2 = 4a(aX 2 + bX) + b2 = 4a(−c) + b2 = b2 − 4ac ≡ ∆ (35)
p
i.e. we have an integer (2aX + b) such that (2aX + b)2 = ∆. This means that the necessary condition
for the given congruence quadratic equation to have solutions is that its discriminant is a quadratic
residue of p (where “quadratic residue” here includes 0; see the preamble of § 1.6).
Regarding the sufficient condition, we will show that this condition is also sufficient, i.e. if the
discriminant is a quadratic residue of p then the given congruence is solvable. So, let us verify this
p
claim by proving that if there is some Y ∈ Z such that ∆ = Y 2 then the given congruence is solvable.
p
Now, according to the LCE theorem (noting that 2a and p are coprime; see § 3.2.1 of V1) Y = 2ax + b
p
is solvable, i.e. there is some X ∈ Z such that Y = 2aX + b. Moreover, from Eq. 35 (read in the
p
reverse direction) ∆ = Y 2 means that the existence of such X is equivalent to the solvability of the
given congruence. So, we conclude that if the discriminant is a quadratic residue of p then the given
congruence is solvable. This means that the sufficient condition for the given congruence quadratic
equation to have solutions is that its discriminant is a quadratic residue of p.
8. Prove the following proposition using modular arithmetic: an integer is divisible by 3 (9) iff the sum
of its digits is divisible by 3 (9).
Solution: Let n = dk . . . d2 d1 d0 (where dk , . . . , d2 , d1 , d0 are digits) and m = 3 (9). So, we have:
n = dk . . . d2 d1 d0 = dk × 10k + . . . + d2 × 102 + d1 × 101 + d0
m
= dk × 1k + . . . + d2 × 12 + d1 × 11 + d0 = dk + . . . + d2 + d1 + d0
This (read in both directions) should prove the equivalence between the divisibility of an integer by 3
(9) and the divisibility of the sum of its digits by 3 (9).
8.1 General Issues about Congruence Equations 103
9. Prove the following using modular arithmetic: an integer is divisible by 11 iff the alternating sum of
its digits is divisible by 11.
Solution: Let n = dk . . . d3 d2 d1 d0 (where dk , . . . , d3 , d2 , d1 , d0 are digits). So, we have:
This (read in both directions) should prove the equivalence between the divisibility of an integer by
11 and the divisibility of the alternating sum of its digits by 11 (noting that the sign does not affect
divisibility since divisibility is an attribute of the magnitude).
p
10. Show that the congruence equation ax2 = b (where p is an odd prime) is solvable iff a and b are both
quadratic residues of p or both quadratic non-residues of p.
p p
Solution: ax2 = b implies x2 = a∗ b and hence (see Problem 13 of § 1.8)[66] a∗ b is a quadratic residue
p p
of p (i.e. x2 = a∗ b is solvable and hence ax2 = b is solvable) iff a∗ and b are either both quadratic
residues of p or both quadratic non-residues of p. Now, a and a∗ are either both quadratic residues or
p
both quadratic non-residues (see Problem 14 of § 1.8). Therefore, ax2 = b is solvable iff a and b are
both quadratic residues of p or both quadratic non-residues of p.
p p p
11. Show that the congruence equation x2 = mn is solvable iff x2 = m and x2 = n are both solvable or
both non-solvable (where p is an odd prime and mn is coprime to p).
Solution: This is a corollary of Problem 13 of § 1.8 (noting the connection between solvability and
quadratic residue).
12. One of the practical applications of congruence equations is in random number generation which is
widely used in many branches and disciplines of computer science (and computing in general) and its
many applications (in theories as well as in real life). In this Problem we outline the basic idea of using
modular arithmetic in the generation of sequences of (pseudo) random numbers.
So, let us create a simple modular arithmetic “model” to generate (pseudo) random numbers ri between
0 and 10000, i.e. 0 ≤ ri ≤ 9999 where i = 1, 2, . . .. This model is based on the following congruence
equation:
k
ri = mri−1 + d
where r0 (i.e. r1−1 ) is the seed (which determines the progress of the sequence), k (which is equal to
10000 in our case) is the upper limit of the generated random numbers, m is a natural number between
1 and k (i.e. 2 ≤ m ≤ 9999), and d is a given integer increment (e.g. d = 713).
For example, if r0 = 93, m = 381 and d = 11 then our random number generation model will generate
the following sequence of random numbers:
5444, 4175, 686, 1377, 4648, 899, 2530, 3941, 1532, 3703, 854, 5385, 1696, 6187, 7258, 5309, 2740, 3951, . . .
This random number generation model (or “device”) can be easily implemented in a few lines of computer
code or in a simple spreadsheet. It is obvious that if the random numbers are required to be between
0 and 1 (instead of being between 0 and k) then we simply divide these numbers by k.
Also see Problem 2 of § 18.1.
13. Discuss the difference between Legendre’s symbol and Jacobi’s symbol as metrics for determining the
solvability of quadratic congruence equations.
Solution: From point 8 in the preamble of § 1.11, we can see that Legendre’s symbol is a full metric for
solvability of quadratic congruence equations since it can determine its solvability and non-solvability,
while Jacobi’s symbol is a partial metric for solvability of quadratic congruence equations since it can
determine only its non-solvability.
71 101 2
For instance, we can conclude that x2 = 2 is solvable and x2 = 2 is non-solvable because 71 = 1 and
[66] It
is obvious that we are assuming a and p are coprime (noting that otherwise the case is trivial and obvious and can be
excluded or included according to the convention about quadratic residue; see § 1.6).
8.2 Univariate Congruence Equations 104
2
101 = −1.
21 2
On the other hand, we can conclude that x2 = 2 is non-solvable because = −1, but we cannot
21
2 21 2 21 16
conclude
that x = 16 and x = 5 are solvable (or non-solvable) from the fact that 21 = 1 and
5
21 = 1 (noting that the first is solvable while the second is not).
p p
i.e. x = p − 1 is the other solution. It should be obvious that 1 6= (p − 1) because otherwise:
p p
1 = (p − 1) → p=2 → p|(p − 2)
p
which is nonsensical since p > (p − 2) and (p − 2) 6= 0 noting that p is an odd prime.[67] So, x = 1 and
p p
x = p − 1 are the only (distinct modular) solutions to the congruence equation x2 = 1.
2
Note: we may also prove the given proposition (more easily) by noting that (±1) = 1 and hence the
p p p p
distinct modular solutions of x2 = 1 are x = 1 and x = −1 = p − 1 (noting that modular distinction
p
is because p is an odd prime). We may also prove it by using Problem 2 of § 8.1, i.e. if x2 = 12 then
p p p
x = ±1 (where x = −1 = p − 1 noting again that modular distinction is because p is an odd prime).
4
5. Show that if n ∈ Z is a solution of the congruence equation n3 + 6n2 + n + 6 = 0 then n cannot be the
difference of two squares.
4 4
Solution: The only solution to n3 + 6n2 + n + 6 = 0 is n = 2 (see § 3.2.1 of V1). Now, if n is the
[67] We p p
may similarly say: p = 2 means 0 = 2 which is nonsensical because p is an odd prime.
8.2 Univariate Congruence Equations 105
difference between two squares then we have 4 possibilities regarding the parity of the squares (where
m, k ∈ Z):
4 4
n = (2m + 1)2 − (2k + 1)2 = 0 n = (2m)2 − (2k)2 = 0
4 4
n = (2m + 1)2 − (2k)2 = 1 n = (2m)2 − (2k + 1)2 = 3
As we see, there is no n which is a difference between two squares that is congruent (mod 4) to 2, and
4
hence if n is a difference between two squares then it cannot be a solution to n3 + 6n2 + n + 6 = 0.
th
6. Let P (x) (where x ∈ Z) be an n degree polynomial none of its coefficients is zero. Create examples
for the following:[68]
k
(a) n = 2 and P = 0 (k = 3, 5, 7, 11) has root 0 for all these moduli.
k
(b) n = 3 and P = 0 (k = 2, 6, 9, 13, 15) has root 1 for all these moduli.
12
(c) n = 3 and P = 0 has the following roots (and possibly other roots): 1, 3, 4, 7, 10.
Solution:
(a) If we start with a quadratic whose constant coefficient is 0 (say x2 − x) then it is obvious that
k
x2 − x = 0 (k = 3, 5, 7, 11) has root 0 for all these moduli. Now, if we add to this polynomial the least
common multiple of these moduli (i.e. their product which is 1155) then P = x2 − x + 1155 should
meet all the given conditions.
k
(b) If we start with the linear polynomial (x − 1) then it is obvious that x − 1 = 0 (k = 2, 6, 9, 13, 15)
has root 1 for all these moduli. Now, if we multiply (x − 1) by a quadratic polynomial with non-
zero coefficients (say x2 − 4x + 3) then we get a cubic that meet all the given conditions, i.e. P =
(x − 1)(x2 − 4x + 3) = x3 − 5x2 + 7x − 3.
12
(c) Let the congruence equation be ax3 + bx2 + cx + d = 0 (where a, b, c, d ∈ Z). Now, if this equation
has the given roots (i.e. 1, 3, 4, 7, 10) then we must have:
12
a(1)3 + b(1)2 + c(1) + d = 0
3 2 12
a(3) + b(3) + c(3) + d = 0
12
a(4)3 + b(4)2 + c(4) + d = 0
3 2 12
a(7) + b(7) + c(7) + d = 0
12
a(10)3 + b(10)2 + c(10) + d = 0
On solving this system of congruences for the variables a, b, c, d (see § 4.4.1 of V1 as well as chapter 9
12
of the present volume) we get: (a, b, c, d) = (2, 2, 8, 12). Hence, P = 2x3 + 2x2 + 8x + 12 should meet
all the given conditions.
p
7. Show that the congruence equation n6 − 11n4 + 36n2 − 36 = 0 is always solvable (where p ∈ P and
n ∈ Z).
Solution: We have three (comprehensive) cases to consider:
• p = 2: the polynomial n6 − 11n4 + 36n2 − 36 is even and hence the given congruence is solvable.
3
• p = 3: we have n6 − 11n4 + 36n2 − 36 = 0 which has the solution n = 3k (k ∈ Z).
• p > 3: we have:
n6 − 11n4 + 36n2 − 36 = (n2 − 2)(n2 − 3)(n2 − 6)
Now, from Problem 3 of § 1.8 at least one of 2, 3, 6 must be a quadratic residue (mod p) which means
p
that at least one of the three congruences: n2 − a = 0 (a = 2, 3, 6) is solvable. Therefore, the given
congruence equation is solvable.
So, in all three cases the given congruence equation is solvable and hence it is always solvable.
[68] ThisProblem (and its alike) is about obtaining polynomial congruences with given conditions. The purpose of it is to
improve the skill of constructing such congruences when needed during investigating and solving some number theory
problems.
8.2 Univariate Congruence Equations 106
2010
8. Show that 98n − 68n − 31n + 1 = 0 for all n ∈ N.
Solution: We have 2010 = 2 × 3 × 5 × 67. Now:
2
• 98n − 68n − 31n + 1 is even and hence 98n − 68n − 31n + 1 = 0 for all n ∈ N.
n n n 3 n n n
• 98 − 68 − 31 + 1 = 2 − 2 − 1 + 1 = 0 for all n ∈ N.
5
• 98n − 68n − 31n + 1 = 3n − 3n − 1n + 1 = 0 for all n ∈ N.
67
• 98n − 68n − 31n + 1 = 31n − 1n − 31n + 1 = 0 for all n ∈ N.
2010
Hence, 98n − 68n − 31n + 1 = 0 for all n ∈ N (see rule 14 of § 2.7 of V1).
9. Which of the following quadratic congruence equations are solvable:
3797 5281
(a) 3x2 − 15x + 221 = 0. (b) 11x2 + 4x + 311 = 0.
7171 199
(c) x2 − 19x − 52 = 0. (d) 26x4 + 31x3 − 85x2 − 111x − 5 = 0.
Solution: We use the proposition of Problem 7 of § 8.1 (where Legendre’s symbol criterion is used to
[69]
determine if the discriminant ∆ is a quadratic residue of the modulo or not).
2 −2427
(a) 3797 is prime. We have ∆ = (−15) − 4 × 3 × 221 = −2427. Now, 3797 = 1 (i.e. ∆ is a quadratic
residue of 3797) and hence the given congruence equation is solvable.
(b) 5281 is prime. We have ∆ = (4)2 − 4 × 11 × 311 = −13668. Now, −13668 3797 = −1 (i.e. ∆ is a
quadratic non-residue of 5281) and hence the given congruence equation is not solvable.
71
(c) 7171 = 71 × 101. If the given congruence equation is solvable then we must have x2 − 19x − 52 = 0
101
and x2 − 19x − 52 = 0. We have ∆ = (−19)2 − 4 × (−52) = 569. Now, 569 71 = 1 and 569
101 = 1 and
hence the given congruence is solvable.
(d) 199 is prime. Also, 26x4 + 31x3 − 85x2 − 111x − 5 = (2x2 − x − 5)(13x2 + 22x + 1). So, if the given
199 199
congruence equation is solvable then we must have 2x2 − x − 5 = 0 or/and 13x2 + 22x + 1 = 0.
41
199
For 2x2 − x − 5 we have ∆ = (−1)2 − 4 × 2 × (−5) = 41. Now, 199 = −1 and hence 2x2 − x − 5 = 0
is not solvable.
432 199
For 13x2 +22x+1 we have ∆ = (22)2 −4×13×1 = 432. Now, 199 = −1 and hence 13x2 +22x+1 = 0
is not solvable.
Therefore, the given congruence equation is not solvable.
10. Find the number of (modular) solutions of the following exponential congruence equations (where
n ∈ N):
7 10 27 25 22
(a) 5n = 6. (b) 3n = 1. (c) 4n = 7. (d) 7n = 1. (e) 3n = 5.
Solution: We use the proposition of Problem 6 of § 8.1 (noting that all these congruences meet the
required conditions of that proposition where we take r = 5, 3, 2, 2, 7 for k = 7, 10, 27, 25, 22).
7
(a) The congruence 5n = 6 has one solution (mod 6) because I7,5 (5) = 1 and φ(7) = 6 and hence their
gcd is 1.
10
(b) The congruence 3n = 1 has one solution (mod 4) because I10,3 (3) = 1 and φ(10) = 4 and hence
their gcd is 1.
27
(c) The congruence 4n = 7 has two solutions (mod 18) because I27,2 (4) = 2 and φ(27) = 18 and hence
their gcd is 2 (noting that 2 divides I27,2 7 which is 16).
25
(d) The congruence 7n = 1 has five solutions (mod 20) because I25,2 (7) = 5 and φ(25) = 20 and hence
their gcd is 5 (noting that 5 divides I25,2 1 which is 20).
22
(e) The congruence 3n = 5 has two solutions (mod 10) because I22,7 (3) = 4 and φ(22) = 10 and hence
their gcd is 2 (noting that 2 divides I22,7 5 which is 2).
11. Find the solutions of the congruence equations of Problem 10 using the index of integer method.
k
Solution: According to Problem 6 of § 8.1, the congruence equation an = b can be solved by the index
of integer method using the equation:
φ(k)
n Ik,r (a) = Ik,r (b) (36)
[69] For how to evaluate Legendre symbols we refer the reader to § 1.8 (see for instance Problem 8 of § 1.8).
8.2 Univariate Congruence Equations 107
6 6
(a) From Eq. 36 we have n × 1 = 3. So, the solution is n = 3.
4 4
(b) From Eq. 36 we have n × 1 = 4. So, the solution is n = 0.
18 18 9
(c) From Eq. 36 we have n × 2 = 16. So, the solutions are n = 8, 17 (i.e. n = 8).
20 20 4
(d) From Eq. 36 we have n × 5 = 20. So, the solutions are n = 0, 4, 8, 12, 16 (i.e. n = 0).
10 10 5
(e) From Eq. 36 we have n × 4 = 2. So, the solutions are n = 3, 8 (i.e. n = 3).
12. Find all primes p such that the following congruences have solutions:
p p p
(a) x2 − 1 = 0. (b) x2 + 1 = 0. (c) x2 − 2 = 0.
p p p
(d) x2 + 2 = 0. (e) x2 − 4 = 0. (f ) x2 + 4 = 0.
Solution: We note first that all these congruences are solvable for p = 2 and hence in the following we
consider only odd primes.
p
(a) We have x2 = 1, i.e. 1 is a quadratic residue of p. Now, 1 is a quadratic residue for all odd primes
and hence the given congruence is solvable for all p (see Problem 2 of § 1.6).
p
(b) We have x2 = −1, i.e. −1 is a quadratic residue of p. Now, the Legendre symbol −1 p is +1 for
all p = 4k + 1 and −1 for all p = 4k − 1 (see Problem 9 of § 1.8). So, the given congruence is solvable
for all p = 4k + 1 and non-solvable for all p = 4k − 1.
p
(c) We have x2 = 2, i.e. 2 is a quadratic residue of p. So, from Eq. 7 we conclude that the given
8 8
congruence is solvable for all p = ±1 and non-solvable for all p = ±3.
p
(d) We have x2 = −2, i.e. −2 is a quadratic residue of p. Now, form Eq. 8 we have −2 p = −1 p
2
p ,
i.e. −2 p = 1 if −1p and p2 have the same sign. So, from parts (b) and (c) we conclude that the
8 8 8 8
given congruence is solvable if p = 4k + 1 and p = ±1 (i.e. p = 1) or p = 4k − 1 and p = ±3 (i.e. p = 3)
and non-solvable otherwise.
p
(e) We have x2 = 4, i.e. 4 is a quadratic residue of p. Now, 4 is a quadratic residue for all odd primes
and hence the given congruence is solvable for all p (see Problem 2 of § 1.6).
p
(f ) We have x2 = −4, i.e. −4 is a quadratic residue of p. Now, form Eqs. 8 and 9 we have:
2 2
−4 −1 4 −1 2 −1 2 −1
= = = =
p p p p p p p p
So, as in part (b) the given congruence is solvable for all p = 4k + 1 and non-solvable for all p = 4k − 1.
Pp−2 k p
13. Let x ∈ N and P ∋ p > 3. Find all the solutions of the following congruence equation: k=0 x = 0.
p Pp−2 k p p
Solution: We note first that x = 1 is not a possible solution because k=0 1 = p − 1 = −1 6= 0.
p Pp−2 p p
Similarly, x = p is not a possible solution because k=0 pk = 1 6= 0. So, any potential solution must
p
be among x = 2, 3, . . . , p − 1.
We have (see Eq. 12 in V1):
P P p
p−2 k p−1 p−2 k
(x − 1) k=0 x = x − 1 → (x − 1) k=0 x = xp−1 − 1 →
P p p
p−2 k
(x − 1) k=0 x = 0 (x = 2, 3, . . . , p − 1)
p
where we used Fermat’s little theorem in the Plast step(noting that p6 | x for x = 2, 3, . . . , p − 1). The
p−2 k p
last congruence means that p divides (x − 1) k=0 x . Now, for x = 2, 3, . . . , p − 1 we have p6 | (x − 1)
P Pp−2 p p
p−2 k
and hence we must have p k=0 x , i.e. k=0 xk = 0 for x = 2, 3, . . . , p − 1. So, the solutions of the
Pp−2 p p
congruence k=0 xk = 0 are x = 2, 3, . . . , p − 1.
323
14. Show that the following congruence equation has no solution: 4x4 + 4 = 0.
323 323
Solution: If 4x4 + 4 = 0 then x4 + 1 = 0 (because 4 and 323 are coprime; see rule 7 of § 2.7 of V1).
323
Noting that 323 = 17 × 19, x4 + 1 = 0 means that x4 + 1 is divisible by 17 and divisible by 19, i.e.
8.2 Univariate Congruence Equations 108
17 19 17 17
x4 + 1 = 0 and x4 + 1 = 0. It is fairly obvious that x4 + 1 = 0 has a solution (e.g. x = 2) and hence
323 19 19
x4 + 1 = 0 has a solution iff x4 + 1 = 0 has a solution. So, let us see if x4 + 1 = 0 has a solution
19
(where from now on we can assume that x and 19 are coprime noting that 0 + 1 6= 0).
19 19 19
x4 + 1 = 0 implies x4 = −1 and hence x8 = 1. Now, from Problem 1 of § 1.3 we conclude that O19 x|8,
i.e. O19 x = 1 or O19 x = 2 or O19 x = 4 or O19 x = 8. Now:
19 19 19
• If O19 x = 1 then x1 = 1 and hence x4 = 1 which contradicts x4 = −1.
19 19 19
• If O19 x = 2 then x2 = 1 and hence x4 = 1 which contradicts x4 = −1.
19 19
• If O19 x = 4 then x4 = 1 which contradicts x4 = −1.
So, we must have O19 x = 8. Now, from Problem 3 of § 1.3 we must have 8|φ(19), i.e. 8|18 which is
19 323 323
untrue. This means that x4 + 1 = 0 has no solution and hence x4 + 1 = 0 (as well as 4x4 + 4 = 0)
has no solution.
15. Find all the solutions of the following exponential congruence equations (where x ∈ N):
33 9 15
(a) 13x = 1. (b) 7x = 4. (c) 22x = 13.
Solution: We use points 1 and 2 in the preamble of § 1.3.
10
(a) We have O33 13 = 10 and hence the solutions are x = 0 (i.e. x = 10, 20, 30, . . .).
9 3
(b) We have O9 7 = 3 and 72 = 4 and hence the solutions are x = 2 (i.e. x = 2, 5, 8, . . .).
15 4
(c) We have O15 22 = 4 and 223 = 13 and hence the solutions are x = 3 (i.e. x = 3, 7, 11, . . .).
16. Find an integer a such that:
107 107 107
(a) The congruence equation ax2 = 5 has the solutions x = 4 and x = 103 (where 0 < a < 107).
29 29
(b) The congruence equation ax19 = 43 has the solution x = 21 (where 0 < a < 29).
Solution:
(a) A primitive root of 107 is 2. Taking the index of both sides of the given congruence equation (see
§ 1.5) we have:
φ(107) 106
I107,2 ax2 = I107,2 (5) → I107,2 (a) + 2I107,2 (x) = I107,2 (5) →
106 106
I107,2 (a) = I107,2 (5) − 2I107,2 (x) → I107,2 (a) = 47 − 2I107,2 (x)
107
Now, if x = 4 then I107,2 (4) = 2 and hence:
106 φ(107)
I107,2 (a) = 47 − 2 × 2 that is I107,2 (a) = 43
107 107
Thus, a = 243 = 7, i.e. a = 7 (noting that 0 < a < 107).
107
Similarly, if x = 103 then I107,2 (103) = 55 and hence:
106 φ(107)
I107,2 (a) = 47 − 2 × 55 that is I107,2 (a) = 43
107
i.e. we get the same result as for x = 4. Therefore, a = 7.
(b) A primitive root of 29 is 2. Taking the index of both sides of the given congruence equation (see §
1.5) we have:
φ(29) 28
I29,2 ax19 = I29,2 (43) → I29,2 (a) + 19I29,2 (x) = I29,2 (43) →
28 28
I29,2 (a) = I29,2 (43) − 19I29,2 (x) → I29,2 (a) = 13 − 19I29,2 (x)
29
Now, if x = 21 then I29,2 (21) = 17 and hence:
28 φ(29)
I29,2 (a) = 13 − 19 × 17 that is I29,2 (a) = 26
29 29
Thus, a = 226 = 22, i.e. a = 22 (noting that 0 < a < 29).
8.3 Multivariate Congruence Equations 109
2 3 5 5
(a) x3 + y = 0. (b) x2 + y 3 = 1. (c) 3x2 + 4y 4 = 1. (d) x2 + 2y + 3z = 1.
Solution: All these congruences can be easily solved by considering all the modular combinations of
x, y, z (as we did in parts d, e and f of Problem 1 of § 4.2.1 of V1).
2
(a) (x, y) = (0, 0) (1, 1)
3
(b) (x, y) = (0, 1) (1, 0) (2, 0)
5
(c) (x, y) = (2, 1) (2, 2) (2, 3) (2, 4) (3, 1) (3, 2) (3, 3) (3, 4)
5
(d) (x, y, z) = (0, 0, 2) (0, 1, 3) (0, 2, 4) (0, 3, 0) (0, 4, 1) (1, 0, 0) (1, 1, 1) (1, 2, 2) (1, 3, 3)
(1, 4, 4) (2, 0, 4) (2, 1, 0) (2, 2, 1) (2, 3, 2) (2, 4, 3) (3, 0, 4) (3, 1, 0) (3, 2, 1)
(3, 3, 2) (3, 4, 3) (4, 0, 0) (4, 1, 1) (4, 2, 2) (4, 3, 3) (4, 4, 4)
5. Solve the following exponential congruence equations (where x, y, z ∈ N0 ):
5 7 11
(a) 3x + 4y = 2. (b) 3x + 5y = 1. (c) 5x + 7y = 10.
7 11 11
(d) 2x + 3y + 5z = 4. (e) 3x + 4y + 7z = 5. (f ) 2x + 3y + 5z = 4.
Solution: All these congruences can be easily solved by considering all the modular combinations of
the exponentials (as we did in § 4.2.2 of V1).
4 2
(a) (x =, y =) (0, 0) (1, 1)
6 6
(b) (x =, y =) (1, 1) (2, 3) (3, 4) (4, 2) (5, 5)
5 10
(c) (x =, y =) (0, 8) (1, 2) (2, 1) (3, 7) (4, 0)
3 6 6
(d) (x =, y =, z =) (0, 0, 4) (0, 2, 0) (0, 3, 2) (0, 4, 3) (0, 5, 1) (1, 0, 0) (1, 1, 3) (1, 3, 5)
(1, 4, 1) (1, 5, 2) (2, 0, 3) (2, 1, 2) (2, 2, 1) (2, 3, 0) (2, 4, 5) (2, 5, 4)
5 5 10
(e) (x =, y =, z =) (0, 0, 4) (0, 2, 5) (0, 3, 7) (0, 4, 0) (1, 0, 0) (1, 1, 8) (1, 2, 9) (1, 3, 6)
(1, 4, 5) (2, 0, 7) (2, 1, 4) (2, 2, 3) (2, 3, 8) (2, 4, 6) (3, 0, 5) (3, 1, 1)
(3, 2, 7) (3, 3, 3) (3, 4, 9) (4, 1, 9) (4, 2, 1) (4, 3, 4) (4, 4, 8)
10 5 5
(f ) (x =, y =, z =) (0, 2, 1) (0, 3, 4) (1, 0, 0) (1, 2, 3) (1, 4, 4) (3, 1, 3) (3, 2, 4) (3, 4, 2)
(4, 0, 4) (4, 2, 0) (4, 3, 1) (5, 0, 3) (5, 4, 0) (6, 0, 1) (6, 1, 2) (6, 3, 0)
(7, 1, 1) (7, 3, 2) (7, 4, 3) (8, 1, 4) (8, 2, 2) (9, 3, 3) (9, 4, 1)
6. Solve the following congruence equations (where m, n ∈ N0 and x ∈ Z):
7 11 5
(a) x2 + n! = 0. (b) 7m + n! = 1. (c) 2x2 + 3m + n! = 0.
Solution:
(a) We have five main cases to consider:
7
• n = 0, 1, 2, 5 and hence x2 + a = 0 (where a = 1, 1, 2, 120 respectively) which has no solution.
7 7
• n = 3 and hence x2 + 6 = 0 whose solutions are x = 1, 6.
7 7
• n = 4 and hence x2 + 24 = 0 whose solutions are x = 2, 5.
7 7
• n = 6 and hence x2 + 720 = 0 whose solutions are x = 1, 6.
7 7
• n > 6 and hence x2 = 0 whose solution is x = 0.
So in brief, the solutions of the given congruence equation are (where N ∋ b > 6 and k ∈ Z):
(n, x) = (3, 1 + 7k) (3, 6 + 7k) (4, 2 + 7k) (4, 5 + 7k) (6, 1 + 7k) (6, 6 + 7k) (b, 7k)
(b) We have:
10 11
7m =0,1,2,3,4,5,6,7,8,9 = 1, 7, 5, 2, 3, 10, 4, 6, 9, 8 and
11
n!(n = 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, > 10) = 1, 1, 2, 6, 2, 10, 5, 2, 5, 1, 10, 0.
On considering all the possible combinations we get the following solutions (noting that m is in modulo
10 while n is in ordinary arithmetic):
(m, n) = (0, > 10) (1, 6) (1, 8) (3, 5) (3, 10) (5, 2) (5, 4) (5, 7) (7, 3)
8.3 Multivariate Congruence Equations 111
(c) We have:
5 5
2x2 (x = 0, 1, 2, 3, 4) = 0, 2, 3, 3, 2 and
4 5
3m=0,1,2,3 = 1, 3, 4, 2 and
5
n!(n = 0, 1, 2, 3, 4, > 4) = 1, 1, 2, 1, 4, 0.
On considering all the possible combinations we get the following solutions (noting that x is in modulo
5 and m is in modulo 4 while n is in ordinary arithmetic):
(x, m, n) = (0, 0, 4) (0, 1, 2) (0, 2, 0) (0, 2, 1) (0, 2, 3) (1, 0, 2) (1, 1, > 4)
(1, 2, 4) (1, 3, 0) (1, 3, 1) (1, 3, 3) (2, 0, 0) (2, 0, 1) (2, 0, 3)
(2, 1, 4) (2, 3, > 4) (3, 0, 0) (3, 0, 1) (3, 0, 3) (3, 1, 4) (3, 3, > 4)
(4, 0, 2) (4, 1, > 4) (4, 2, 4) (4, 3, 0) (4, 3, 1) (4, 3, 3)
Chapter 9
Congruence Systems
In this chapter we investigate some examples of systems of congruence equations of various types and how
they are solved. In fact, this chapter should be regarded as continuation to the previous chapter as both
chapters are essentially about solving congruence equations (i.e. individually or collectively).[70]
[70] In fact, it is also continuation to the material about this topic which we investigated in the first volume of this book.
[71] In fact, there are some details about the nature of m and n and if they belong to different residue classes or not. In
7 7 7
general, such a system is solvable in trivial cases like x2 = 8, x2 = 15, x2 = 120 (noting that 8, 15, 120 belong to the
same residue class modulo 7, i.e. 1).
[72] See Problem 3 of § 9.2.2 and Problem 5 of § 9.3.2 for more details about this issue.
112
9.2 Univariate Congruence Systems 113
[73] For how to obtain the solutions of the individual congruence equations (in this and other Problems), we refer the reader
to the previous chapter (as well as V1).
[74] Alternatively (and more simply), if we convert modulo 8 to modulo 16 (similar to what we did in part a by converting
16
modulo 5 to modulo 10) then the solutions of the second congruence are: x = 2, 4, 6, 10, 12, 14 and hence we obtain the
same result.
9.2.2 Multiple Moduli 114
2310
of this system are: x = 132, 330, 792, 1980.
69
(c) The solutions of the first congruence are: x = 0, 33, 42 while the solutions of the second congruence
22 69 22
are: x = 13, 17, 19. Now, if we try the 9 combinations of x = 0, 33, 42 with x = 13, 17, 19 we find that
1518
the solutions of this system are: x = 171, 387, 525, 585, 723, 897, 1311, 1449, 1491.
[75] Instead, 21 7
we could have simplified the congruence 33x8 = 27 to 11x8 = 9 (by using rule 9 of § 2.7 of V1) and hence obtain
7
the solution x = 2, 5.
9.2.2 Multiple Moduli 115
[76] Infact, this extension is also present in the upcoming Problems of this subsection.
[77] Actually, this extension normally deals with non-linear systems of polynomial type (although the idea is applicable to
other types of non-linear systems).
9.3 Multivariate Congruence Systems 116
90
two solutions: x = 37, 73.
16
(b) The solutions of the first congruence are: x = 2 while the solutions of the second congruence are:
15 240
x = 8, 10. On trying these two combinations we get the following two solutions: x = 98, 130.
40
(c) The solutions of the first congruence are: x = 0, 21, 31 while the solutions of the second congruence
60 120
are: x = 0. Hence, the only solution to this system is x = 0.
6. Solve the following systems of mixed polynomial-exponential congruence equations (where x ∈ N0 ):
124 144
(a) 2x3 + 5x2 + 8x + 1 = 0 5x + 7x = 12.
77 101
(b) x4 + 12x2 + 7x + 22 = 0 13x + 25x = 2.
69 117
(c) 6x3 + 33x2 + 13x = 0 19x + 35x + 41x = 3.
Solution:
124
(a) The solutions of the first congruence are: x = 3, 17, 55, 65, 79, 117 while the solutions of the second
12 124 12
congruence are: x = 1. On trying the 6 combinations of x = 3, 17, 55, 65, 79, 117 with x = 1 (using the
372
Chinese remainder theorem) we find that the only solutions of this system are: x = 241, 265, 313.
77
(b) The solutions of the first congruence are: x = 22, 55 while the solutions of the second congruence
50 77 50
are: x = 0. On trying the two combinations of x = 22, 55 with x = 0 we find that the solutions of this
3850
system are: x = 1100, 2750.
69
(c) The solutions of the first congruence are: x = 0, 33, 42 while the solutions of the second congruence
12 69 12
are: x = 0. On trying these three combinations of x = 0, 33, 42 with x = 0 we find that the solutions
276
of this system are: x = 0, 180, 240.
88
(c) By looping we get the following 32 solutions in modulo 88 i.e. (x, y, z) = :
(1, 0, 0) (1, 44, 0) (9, 12, 24) (9, 28, 72) (9, 56, 24) (9, 72, 72) (17, 28, 32)
(17, 72, 32) (21, 6, 84) (21, 38, 4) (21, 50, 84) (21, 82, 4) (33, 20, 64) (33, 40, 80)
(33, 64, 64) (33, 84, 80) (45, 22, 44) (45, 66, 44) (53, 6, 28) (53, 34, 68) (53, 50, 28)
(53, 78, 68) (61, 6, 76) (61, 50, 76) (65, 16, 48) (65, 28, 40) (65, 60, 48) (65, 72, 40)
(77, 18, 36) (77, 42, 20) (77, 62, 36) (77, 86, 20)
2. Solve the following systems of exponential congruence equations (where x, y, z ∈ N0 ):
19 19
(a) 3x + 4y = 2 3x + 5y = 1.
41 41
(b) 3x + 4y = 2 5x + 7y = 10.
11 11
(c) 2x + 3y + 5z = 4 3x + 4y + 7z = 5.
Solution:
(a) The solutions of these equations are (see § 8.3):
18 9
(x =, y =) (0, 0) (4, 2) (5, 7) (10, 8) (11, 6) (13, 3) (14, 5) (15, 4) (16, 1)
18 9
(x =, y =) (1, 4) (2, 3) (5, 1) (10, 8) (12, 5) (13, 2) (14, 7) (17, 6)
As we see, what is common between these two sets of solutions (i.e. their intersection) is only one so-
18 9
lution, i.e. x = 10 and y = 8. So, this is the only solution to this system.
(b) The solutions of these equations are:
8 10
(x =, y =) (0, 0) (1, 5) (3, 2)
20 40
(x =, y =) (0, 10) (1, 18) (2, 23) (3, 2) (5, 0) (6, 39) (7, 12) (8, 22)
(9, 14) (10, 37) (11, 3) (12, 19) (13, 13) (14, 6) (15, 31) (16, 15)
(17, 17) (18, 29) (19, 24)
Now, we form the following 57 systems of linear congruence equations in x (where the rows represent
x in mod 8 and the columns represent x in mod 20 while the entries represent x in mod 40 noting that
the empty entries mean no solution) and solve them (by the Chinese remainder theorem):
0 1 2 3 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
0 0 8 32 16
1 1 25 9 33
3 3 27 11 35 19
We also form the following 57 systems of linear congruence equations in y (where the rows represent y
in mod 10 and the columns represent y in mod 40 while the entries represent y in mod 40 noting that
the empty entries mean no solution) and solve them:
10 18 23 2 0 39 12 22 14 37 3 19 13 6 31 15 17 29 24
0 10 0
5 15
2 2 12 22
40
On comparing the two tables we can see that we have only 3 solutions: (x, y) = (0, 10), (3, 2) and (27, 12).
(c) The solutions of these equations are given in Problem 5 of § 8.3. Now if we consider the 529 (i.e.
23 × 23) combinations we can eliminate most of them and obtain the solutions as follows:
5 10
• For x = 0: we have a solution only for x = 0, 5. Moreover, because y must be identical (since it is
in mod 5 in both sets of solutions) then we have only the following 5 potentially solvable combinations
(noting that these combinations are one-to-one):
5 5 10
(x =, y =, z =) (0, 0, 4) (0, 2, 5) (0, 3, 7) (0, 4, 0)
10 5 5
(x =, y =, z =) (5, 0, 3) (0, 2, 1) (0, 3, 4) (5, 4, 0)
9.3.1 Single Modulo 118
However, considering the solvability of the z system, only the last combination has a solution, i.e.
10 5 10
(x =, y =, z =) = (5, 4, 0).
5
• For x = 1: following the procedure of the previous point we get the following 6 combinations:
5 5 10
(x =, y =, z =) (1, 0, 0) (1, 0, 0) (1, 1, 8) (1, 2, 9) (1, 3, 6) (1, 4, 5)
10 5 5
(x =, y =, z =) (1, 0, 0) (6, 0, 1) (6, 1, 2) (1, 2, 3) (6, 3, 0) (1, 4, 4)
10 5 10
However, only the first combination has a solution, i.e. (x =, y =, z =) = (1, 0, 0).
5
• For x = 2: we get the following 3 combinations:
5 5 10
(x =, y =, z =) (2, 1, 4) (2, 3, 8) (2, 4, 6)
10 5 5
(x =, y =, z =) (7, 1, 1) (7, 3, 2) (7, 4, 3)
However, none of these combination has a solution.
5
• For x = 3: we get the following 5 combinations:
5 5 10
(x =, y =, z =) (3, 1, 1) (3, 1, 1) (3, 2, 7) (3, 2, 7) (3, 4, 9)
10 5 5
(x =, y =, z =) (3, 1, 3) (8, 1, 4) (3, 2, 4) (8, 2, 2) (3, 4, 2)
10 5 10
However, only the fourth combination has a solution, i.e. (x =, y =, z =) = (8, 2, 7).
5
• For x = 4: we get the following 4 combinations:
5 5 10
(x =, y =, z =) (4, 2, 1) (4, 3, 4) (4, 3, 4) (4, 4, 8)
10 5 5
(x =, y =, z =) (4, 2, 0) (4, 3, 1) (9, 3, 3) (9, 4, 1)
However, none of these combinations has a solution.
10 5 10
So in brief, this system has only three solutions, i.e. (x =, y =, z =) = (1, 0, 0), (5, 4, 0) and (8, 2, 7).
3. Solve the following system of mixed polynomial-exponential congruences (where x, y ∈ N0 ):
11 11
x3 + y = 0 3x + 4y = 2.
Solution: The solutions of these equations are (see § 8.3):
11
(x, y) = (0, 0) (1, 10) (2, 3) (3, 6) (4, 2) (5, 7) (6, 4) (7, 9) (8, 5) (9, 8) (10, 1)
5
(x, y) = (0, 0) (2, 1) (4, 3)
Now, we form the following 33 systems of linear congruence equations in x and the corresponding 33
systems of linear congruence equations in y and solve them where the solutions are shown in the third
and sixth columns:
11 5 55 11 5 55
x= x= x= y= y= y=
0 0,2,4 0,22,44 0 0,1,3 0,11,33
1 0,2,4 45,12,34 10 0,1,3 10,21,43
2 0,2,4 35,2,24 3 0,1,3 25,36,3
3 0,2,4 25,47,14 6 0,1,3 50,6,28
4 0,2,4 15,37,4 2 0,1,3 35,46,13
5 0,2,4 5,27,49 7 0,1,3 40,51,18
6 0,2,4 50,17,39 4 0,1,3 15,26,48
7 0,2,4 40,7,29 9 0,1,3 20,31,53
8 0,2,4 30,52,19 5 0,1,3 5,16,38
9 0,2,4 20,42,9 8 0,1,3 30,41,8
10 0,2,4 10,32,54 1 0,1,3 45,1,23
55
So, these are the solutions of the given system, i.e. (x, y) = (0, 0), (22, 11), (44, 33) . . . , (32, 1), (54, 23).
9.3.2 Multiple Moduli 119
[78] If 9 9
we multiply the congruence by 3 we get 18x − 9y = 3, i.e. 0 = 3 which is nonsensical.
9.3.2 Multiple Moduli 120
6
(x, y) = (0, 0, 4) (0, 1, 3) (0, 2, 2) (0, 3, 1) (0, 4, 0) (0, 5, 5) (1, 0, 5) (1, 1, 4) (1, 2, 3)
(1, 3, 2) (1, 4, 1) (1, 5, 0) (2, 0, 0) (2, 1, 5) (2, 2, 4) (2, 3, 3) (2, 4, 2) (2, 5, 1)
(3, 0, 1) (3, 1, 0) (3, 2, 5) (3, 3, 4) (3, 4, 3) (3, 5, 2) (4, 0, 2) (4, 1, 1) (4, 2, 0)
(4, 3, 5) (4, 4, 4) (4, 5, 3) (5, 0, 3) (5, 1, 2) (5, 2, 1) (5, 3, 0) (5, 4, 5) (5, 5, 4)
2. Solve the following systems of non-linear polynomial congruence equations (where x, y, z ∈ Z):
2 5
(a) x3 + y = 0 3x2 + 4y 4 = 1.
3 7
(b) x2 + y 3 = 1 4x2 − 5y = 3.
3 5
(c) x3 − 2y 2 + 2z 2 = 1 x2 + 2y + 3z = 1.
Solution:
(a) The solutions of these equations are (see Problem 4 of § 8.3):
2
(x, y) = (0, 0) (1, 1)
5
(x, y) = (2, 1) (2, 2) (2, 3) (2, 4) (3, 1) (3, 2) (3, 3) (3, 4)
On forming 16 systems of linear congruence equations in x and the corresponding 16 systems of linear
congruence equations in y (as we did in Problem 1) and solving them we get the following 16 solutions:
10
(x, y) = (2, 2) (2, 4) (2, 6) (2, 8) (3, 1) (3, 3) (3, 7) (3, 9)
(7, 1) (7, 3) (7, 7) (7, 9) (8, 2) (8, 4) (8, 6) (8, 8)
(b) The solutions of these equations are (see Problem 4 of § 8.3 as well as Problem 1 of 4.2.1 of V1):
3
(x, y) = (0, 1) (1, 0) (2, 0)
7
(x, y) = (0, 5) (1, 3) (2, 4) (3, 1) (4, 1) (5, 4) (6, 3)
On forming 21 systems of linear congruence equations in x and the corresponding 21 systems of linear
congruence equations in y (as we did in Problem 1) and solving them we get the following 21 solutions:
21
(x, y) = (0, 19) (1, 3) (2, 18) (3, 1) (4, 15) (5, 18) (6, 10)
(7, 12) (8, 3) (9, 4) (10, 15) (11, 15) (12, 4) (13, 3)
(14, 12) (15, 10) (16, 18) (17, 15) (18, 1) (19, 18) (20, 3)
(c) The solutions of these equations are (see Problem 4 of § 8.3 as well as Problem 1 of 4.2.1 of V1):
3
(x, y, z) = (0, 1, 0) (0, 2, 0) (1, 0, 0) (1, 1, 1) (1, 1, 2) (1, 2, 1) (1, 2, 2) (2, 0, 1) (2, 0, 2)
5
(x, y, z) = (0, 0, 2) (0, 1, 3) (0, 2, 4) (0, 3, 0) (0, 4, 1) (1, 0, 0) (1, 1, 1) (1, 2, 2) (1, 3, 3)
(1, 4, 4) (2, 0, 4) (2, 1, 0) (2, 2, 1) (2, 3, 2) (2, 4, 3) (3, 0, 4) (3, 1, 0) (3, 2, 1)
(3, 3, 2) (3, 4, 3) (4, 0, 0) (4, 1, 1) (4, 2, 2) (4, 3, 3) (4, 4, 4)
On forming 225 systems of linear congruence equations in x (and the corresponding 225 systems in y
and 225 systems in z as we did in the previous Problems) and solving them we get the following 225
solutions (in modulo 15):
9.3.2 Multiple Moduli 121
(x y, z)
0 1,3 2,9 4,6 5,12 7,9 8,0 10,12 11,3 13,0 14,6
1 0,0 1,1 1,11 2,2 2,7 3,3 4,4 4,14 5,5 5,10 6,6 7,2 7,7
8,8 8,13 9,9 10,5 10,10 11,1 11,11 12,12 13,8 13,13 14,4 14,14
2 0,4 0,14 3,2 3,7 6,5 6,10 9,8 9,13 12,1 12,11
3 1,0 2,6 4,3 5,9 7,6 8,12 10,9 11,0 13,12 14,3
4 0,0 1,1 1,11 2,2 2,7 3,3 4,4 4,14 5,5 5,10 6,6 7,2 7,7
8,8 8,13 9,9 10,5 10,10 11,1 11,11 12,12 13,8 13,13 14,4 14,14
5 0,2 0,7 3,5 3,10 6,8 6,13 9,1 9,11 12,4 12,14
6 1,6 2,12 4,9 5,0 7,12 8,3 10,0 11,6 13,3 14,9
7 0,9 1,5 1,10 2,1 2,11 3,12 4,8 4,13 5,4 5,14 6,0 7,1 7,11
8,2 8,7 9,3 10,4 10,14 11,5 11,10 12,6 13,2 13,7 14,8 14,13
8 0,4 0,14 3,2 3,7 6,5 6,10 9,8 9,13 12,1 12,11
9 1,6 2,12 4,9 5,0 7,12 8,3 10,0 11,6 13,3 14,9
10 0,12 1,8 1,13 2,4 2,14 3,0 4,1 4,11 5,2 5,7 6,3 7,4 7,14
8,5 8,10 9,6 10,2 10,7 11,8 11,13 12,9 13,5 13,10 14,1 14,11
11 0,5 0,10 3,8 3,13 6,1 6,11 9,4 9,14 12,2 12,7
12 1,0 2,6 4,3 5,9 7,6 8,12 10,9 11,0 13,12 14,3
13 0,9 1,5 1,10 2,1 2,11 3,12 4,8 4,13 5,4 5,14 6,0 7,1 7,11
8,2 8,7 9,3 10,4 10,14 11,5 11,10 12,6 13,2 13,7 14,8 14,13
14 0,5 0,10 3,8 3,13 6,1 6,11 9,4 9,14 12,2 12,7
3. Solve the following systems of exponential congruence equations (where x, y, z ∈ N0 ):
5 7
(a) 3x + 4y = 2 3x + 5y = 1.
5 11
(b) 3x + 4y = 2 5x + 7y = 10.
7 11
(c) 2x + 3y + 5z = 4 3x + 4y + 7z = 5.
Solution:
(a) The solutions of these equations are (see Problem 5 of § 8.3):
4 2
(x =, y =) (0, 0) (1, 1)
6 6
(x =, y =) (1, 1) (2, 3) (3, 4) (4, 2) (5, 5)
Now, we form the following 10 systems of linear congruence equations in x and the corresponding 10
systems of linear congruence equations in y and solve them (using for instance the Chinese remainder
theorem) where the solutions (if exist) are shown in the third and sixth rows (noting that blank means
there is no solution):
4
x= 0 0 0 0 0 1 1 1 1 1
6
x= 1 2 3 4 5 1 2 3 4 5
12
x= 8 4 1 9 5
2
y= 0 0 0 0 0 1 1 1 1 1
6
y= 1 3 4 2 5 1 3 4 2 5
6
y= 4 2 1 3 5
So, the solutions are (noting that only some combinations produce solutions for both x and y):
12 6
(x =, y =) (1, 1) (4, 2) (5, 5)
9.3.2 Multiple Moduli 122
7
x= 0 0 0 1 1 1 2 2 2 3 3 3 4 4 4 5 5 5 6 6 6
5
x= 0 2 4 0 2 4 0 2 4 0 2 4 0 2 4 0 2 4 0 2 4
35
x= 0 7 14 15 22 29 30 2 9 10 17 24 25 32 4 5 12 19 20 27 34
7
y= 0 0 0 6 6 6 6 6 6 1 1 1 6 6 6 1 1 1 1 1 1
5
y= 0 1 3 0 1 3 0 1 3 0 1 3 0 1 3 0 1 3 0 1 3
35
y= 0 21 28 20 6 13 20 6 13 15 1 8 20 6 13 15 1 8 15 1 8
35
So, these are the solutions of the given system, i.e. (x, y) = (0, 0), (7, 21), . . . , (34, 8). Also see part (b)
of Problem 3 of § 18.3.
5. Comment on the contents and results of the present subsection.
Solution: We can claim that our investigation in the present subsection is essentially a generalization
(or extension) to the Chinese remainder theorem from univariate to multivariate systems of congruence
equations. Now, if we look back to Problem 3 of § 9.2.2 we can say: so far we essentially made three
main generalizations (or extensions) to the Chinese remainder theorem:
• The extension of lifting the restriction of linearity.[79]
• The extension of lifting the restriction of coprimality of moduli.
• The extension of lifting the restriction of univariability.
So in brief, we can now solve (with the help of the humble Chinese remainder theorem and similar
methods) non-linear systems or/and with non-coprime moduli (subject to the conditions given earlier)
or/and with multiple variables.
[79] In
fact, this extension is not limited to what we did in Problem 1 of § 9.2.2 (and its alike), but it should include what
we did in the present subsection with regard to solving non-linear systems of various types.
Chapter 10
Common Functions
1. Find all n ∈ N such that σ(n) = 960 and τ (n) = 4.
Solution: Let the second and third divisors of n be a and b (respectively). Hence, n = ab and we have
959 − a
1 + a + b + ab = 960 → b=
1+a
√
Now, if we note that 1 < a < 960 ≃ 30.98 and a and b must be primes (noting that 1+p+p2 +p3 = 960
has no solution) then on trying the primes a = 2, 3, 5, . . . , 29 accepting only the corresponding primes
of b we obtain only 4 legitimate values of b (i.e. b = 239, 79, 47, 31 corresponding to a = 3, 11, 19, 29).
The corresponding values of n are: 717, 869, 893, 899. So, these 4 values represent all n ∈ N such that
σ(n) = 960 and τ (n) = 4.
2. Solve the following “Diophantine” equations (where x, y, z ∈ N):
(a) φ(2x 13y 19z ) = 216. (b) φ(2x 3y 5z 7w ) = 4032.
Solution:
(a) We have (see Eq. 44 in V1):
1 1 1 108
216 = φ(2x 13y 19z ) = 2x 13y 19z 1 − 1− 1− = 2x 13y 19z
2 13 19 247
Hence:
108
2x 13y 19z 247 = 216 → 2x 13y 19z = 247 1 1
108 × 216 = 494 = 2 × 13 × 19
1
Hence:
8
2x 3y 5z 7w 35 = 4032 → 2x 3y 5z 7w = 35 3 2 1
8 × 4032 = 17640 = 2 × 3 × 5 × 7
2
4. Show that φ(m) φ(n) = φ(g) φ(l) where m, n ∈ N, g = gcd(m, n) and l = lcm(m, n).
Solution: This can be obtained by comparing Eq. 46 in V1 to Eq. 47 in V1.
5. Find the number of integers between 1 and 1000 (inclusive) which are divisible neither by 2 nor by 5?
Solution: We note that 1000 = 103 = (2 × 5)3 = 23 × 53 . So, if a number between 1 and 1000 is not
divisible by 2 and 5 then it must be coprime to 1000. This means that we want to find the number of
integers between 1 and 1000 which are coprime to 1000. In fact, this is the same as φ(1000) since by
definition φ(n) is the number of positive integers which are less than or equal to n and are relatively
prime to n. Thus, the number of integers between 1 and 1000 which are divisible neither by 2 nor by 5
is φ(1000) = 400.
124
10 COMMON FUNCTIONS 125
Note: a different approach (for solving this problem and its alike) is to argue as follows: we have
500 integers (between 1 and 1000) which are divisible by 2, and 200 integers which are divisible by 5
and hence we have 500 + 200 = 700 integers which are divisible by 2 or/and 5. However, we have 100
integers (i.e. the multiples of 10) which are divisible by both 2 and 5 and hence they are counted twice.
So, (by the rules of cardinality of sets) we have 700 − 100 = 600 integers which are divisible by 2 or 5.
Therefore, we must have 1000 − 600 = 400 integers which are divisible neither by 2 nor by 5 (noting
that “integers divisible neither by 2 nor by 5” is the complement
of “integers divisible
by 2 or 5”).
6. A natural number n is called abundant if σ(n) > 2n or equivalently s(n) > n . Show the following:
(a) n is abundant when n = 2k−1 (2k − 1) where (2k − 1) is composite and k ∈ N.
(b) There are infinitely many abundant numbers.
(c) There are infinitely many even abundant numbers.
(d) Natural multiples of abundant numbers are also abundant.
(e) Natural multiples (> 1) of perfect numbers are abundant.
Solution:
(a) 2k−1 is a natural power of 2 (noting that 2k − 1 is composite) and (2k − 1) is odd and hence they
are coprime (since they have no common factor). Hence:
σ(n) = σ 2k−1 (2k − 1) = σ(2k−1 ) σ(2k − 1) = (2k − 1) σ(2k − 1) (37)
where we used the multiplicativity of the divisor function in step 2 and used Eq. 34 of V1 in step 3.
Now, since (2k − 1) is composite then it must have at least three positive divisors, i.e. 1 and itself as
well as another positive divisor. Accordingly, σ(2k − 1) > 2k and hence from Eq. 37 we get:
σ(n) = (2k − 1) σ(2k − 1) > (2k − 1) 2k = 2 2k−1 (2k − 1) = 2n
This is because[80] the set S representing the divisors of kn are the divisors of k and the divisors of n
as well as the (product) combinations of these divisors, while the set s representing kd (where d is a
divisor
Pof n) is just a subset (whether proper or improper) of S, and hence σ(kn) cannot be smaller
than d|n kd. Accordingly:
X X
σ(kn) ≥ kd = k d = k σ(n) > k 2n = 2(kn)
d|n d|n
where the justification of > is similar to what is given in part (d) noting that in this case k > 1.
7. Show that n is prime iff φ(n) = n − 1.
Solution: If φ(n) = n − 1 then all positive integers < n are coprime to n and hence n must be prime
(because this means that the only divisor of n among the positive integers which are less than n is 1).
If n is prime then all positive integers < n are coprime to n (since none of these integers, except 1, can
divide n) and hence φ(n) = n − 1 (as required by the definition of φ).
8. Show that n is composite iff φ(n) < (n − 1).
Solution: If we note that for all n > 1 we have φ(n) ≤ (n − 1) (see point 7 in the preamble of § 2.6.4
of V1), then the proposition of the present Problem is essentially the contrapositive of the proposition
of Problem 7.
9. Impose a lower and upper bound on φ(n) where n ∈ N.
Solution: The lower bound is obviously 1 while the upper bound is n − 1 (see Problems 7 and 8), i.e.
1 ≤ φ(n) ≤ (n − 1).
10. Find all n ∈ N such that (noting that 1 = d1 < d2 < . . . < dτ = n):
(a) n has τ = 9 (positive) divisors with d5 − d3 = 22 and d8 − d5 = 312.
(b) n has τ = 24 (positive) divisors with d2 + d3 + d4 + d5 = 15 and d20 + d21 + d22 + d23 = 1080.
(c) n has τ = 3 (positive) divisors.
(d) n has τ = 5 (positive) divisors and s(n) = n.
(e) n has τ = 10 (positive) divisors and σ(n) < 200.
Solution:
(a) n must be a perfect square and hence n = d25 (see Problem 18 of § 1.9 of V1 and Problem 3 of §
2.6.3 of V1). Now, we have two possibilities:
• If n is even then d2 must be 2 and hence d3 must be either 3 or 4 (noting that 4 must be a divisor since
n is an even perfect square and hence it must have a factor of 22 ). However, d3 = 3 is not a possibility
because in this case d5 = 25 and d8 = 337 and hence n = d25 = 625 which is not divisible by 337. So,
we must have d3 = 4 and hence d5 = 26 and d8 = 338 which is consistent with n = d25 = 262 = 676
(noting that the divisors of 676 are 1, 2, 4, 13, 26, 52, 169, 338, 676). This means that n = 676 is a
solution (and indeed the only possible solution if n is even because d3 is fixed).
• If n is odd then d2 must be an odd prime. This is because 2 (and its multiples) is not a possibility for
d2 since n is odd; moreover d22 must also be a divisor since n is a perfect square. Now, if we note that
d25 = d2 d8 then we must conclude that d2 divides d5 and hence d2 must also divide d8 . So, we have:
This means that d2 divides 312. Now, the only odd prime divisors of 312 are 3 and 13. So:
If d2 = 3 then d22 = 9 must also be a divisor of n. Now, since d22 = 9 is a divisor then d3 can only be 5
or 7 or 9. However, none of these possibilities produce consistent results.[81]
If d2 = 13 then d22 = 169 must also be a divisor of n since n is a perfect square. Now, since d22 = 169 is
a divisor then d3 can only be one of the primes between 17 and 167 (inclusive) or 169. However, none
of these possibilities produce consistent results.[82]
So, we conclude that the only solution to this problem is n = 676.
[81] d 2
3 = 5, 7, 9 lead (noting that d5 − d3 = 22 and n = d5 ) to n = 729, 841, 961. Now, the number of divisors of 729, 841, 961
is 7, 3, 3 and hence they are not acceptable.
[82] If we follow a similar procedure to the one outlined in the previous footnote then we will find that all these possibilities
of n (except n = 1521, 4225 corresponding to d3 = 17, 43 and d5 = 39, 65) are not divisible by 169. Regarding 1521, its
d2 is 3. Regarding 4225, its d2 is 5.
10 COMMON FUNCTIONS 127
(b) From the relation d2 + d3 + d4 + d5 = 15 (noting that 1 < d2 < d3 < d4 < d5 ) we conclude that
d2 = 2, d3 = 3 and d4 = 4 (because otherwise d2 + d3 + d4 + d5 > 15), and hence d5 must be 6. We
must also have:
n = d2 d23 = d3 d22 = d4 d21 = d5 d20 i.e. n = 2d23 = 3d22 = 4d21 = 6d20
Now, if we substitute from these relations into the relation d20 + d21 + d22 + d23 = 1080 we get:
n n n n
+ + + = 1080 → n = 864
6 4 3 2
So, n = 864 is the required (and the only) solution to this problem.
(c) This applies to all squares of primes (e.g. 4, 9, 25) since their divisors are only 1, p and p2 (where
p ∈ P; see part e of Problem 13 of § 2).
(d) τ = 5 means n is a perfect square (see Problem 18 of § 1.9 of V1 and Problem 3 of § 2.6.3 of
V1), while s(n) = n means n is a perfect number (see § 2.8 of V1). These conditions are incompatible
because no perfect number is a perfect square (see Problem 7 of § 2.8 of V1). Hence, there is no such
n.
(e) σ(n) < 200 means n < 200. On inspecting the natural numbers which are less than 200 (using
for instance tables of divisors) we find that only 48 and 80 satisfy the given conditions (noting that
although 112, 162 and 176 satisfy τ = 10 they do not satisfy σ < 200).
11. Justify why φ(n) 6= 391, 454 for any n ∈ N.
Solution: φ(n) 6= 391 because the totient function is even for all integers greater than 2.
Regarding φ(n) 6= 454, we have three (comprehensive) cases:
• n is prime and φ(n) = 454. This is impossible because 455 is not prime (see Problem 7).
• n is a natural power (> 1) of prime and φ(n) = 454. This is also impossible because there is no p ∈ P
and a ∈ N that satisfy 454 = pa − pa−1 (see Eq. 42 in V1).
• n is composite (but not a natural power of prime) and φ(n) = 454. This is also impossible because
the prime factorization of 454 is 2 × 227, and this means that 227 = (pa − pa−1 ) for some p ∈ P and
a ∈ N (see Eq. 43 in V1). However, there is no such p and a that satisfy this equation because 227 is
odd while (pa − pa−1 ) is even (noting that p = 2 and a = 1 is not a possibility).
So, in each one of the three comprehensive cases we have φ(n) 6= 454 and hence φ(n) 6= 454 for any
n ∈ N.
12. Find all n ∈ N such that φ(n) divides (n − 1).
Solution: We have three cases:
• n = 1 and hence φ(n) = 1 which divides n − 1 = 0.
• n is prime and hence φ(n) = n − 1 which divides n − 1.
• n is composite. This is an open problem known as Lehmer’s totient problem (and hence it deserves
the attention of young mathematicians). No composite n is known such that φ(n) divides (n − 1).
So in brief, φ(n) divides (n − 1) for n = 1 and for all n ∈ P; moreover it is believed (according to
Lehmer’s totient conjecture) that there is no composite n with this property.
13. Find all n ∈ N such that (noting that m ∈ N):
(a) φ(2n) = φ(n). (b) φ(2n) = 2φ(n). (c) φ(2m n) = 2m−1 φ(n). (d) φ(2m n) = 2m φ(n).
Solution:
(a) This applies to all odd n because if n is odd then 2 and n are coprime and hence:
φ(2n) = φ(2) φ(n) = 1 × φ(n) = φ(n)
(b) This applies to all even n because if n is even then n = 2k ν (where k ∈ N and ν is odd) and hence:
φ(2n) = φ(2k+1 ν) = φ(2k+1 ) φ(ν) = (2k+1 − 2k ) φ(ν) = 2 (2k − 2k−1 ) φ(ν)
= 2 φ(2k ) φ(ν) = 2 φ(2k ν) = 2 φ(n)
(c) This applies to all odd n because if n is odd then 2m and n are coprime and hence:
φ(2m n) = φ(2m )φ(n) = (2m − 2m−1 ) φ(n) = 2m−1 (2 − 1) φ(n) = 2m−1 φ(n)
10 COMMON FUNCTIONS 128
[83]
where d is a positive divisor of n. For example, the divisor function σ(n) is the summatory function
of f (d) = d because (see Eq. 33 in V1):
X X
σ(n) = f (d) = d
d≤n d|n
Similarly, the tau function τ (n) is the summatory function of f (d) = 1 because (see Eq. 37 in V1):
X X
τ (n) = f (d) = 1
d≤n d|n
16. Show that if f is a multiplicative function, then its summatory function F is also multiplicative.
Solution: Let n1 , n2 ∈ N be coprime and hence (according to the definition of summatory function
which was given in Problem 15) we have:
X
F (n1 n2 ) = f (d) (38)
d|(n1 n2 )
Now, since n1 and n2 are coprime then each divisor (i.e. d) of their product can be written as d = d1 d2
where d1 and d2 are coprime. Accordingly, Eq. 38 can be written as:
X X X
F (n1 n2 ) = f (d) = f (d1 d2 ) = f (d1 ) f (d2 )
d|(n1 n2 ) d1 |n1 , d2 |n2 d1 |n1 , d2 |n2
X X
= f (d1 ) f (d2 ) = F (n1 ) F (n2 )
d1 |n1 d2 |n2
Note: the result of this Problem may be used to prove that σ(n) and τ (n) are multiplicative because:
• σ(n) is the summatory function of f (d) = d (i.e. the identity function) and hence:
f (mn) = mn = f (m) f (n)
i.e. f is a completely multiplicative function[84] (and hence it is multiplicative).
• τ (n) is the summatory function of f (d) = 1 (i.e. the unity function) and hence:
f (mn) = 1 = 1 × 1 = f (m) f (n)
i.e. f is a completely multiplicative function (and hence it is multiplicative).
[83] This definition (which should be “sufficient and necessary” to us for the time being) is rather limited. Therefore, the
readers should be careful about the terminology used in the literature in this regard where the domain of f (and hence
the “summatory function” F ) could vary. These issues should be elaborated and clarified further in the future.
[84] A “completely multiplicative function” f means: f (mn) = f (m)f (n) for all m, n ∈ N (i.e. regardless of m, n being
coprime or not).
10 COMMON FUNCTIONS 129
17. Show that the summatory function of the totient function is n, i.e.
X
φ(d) = n
d|n
[85] Thecode CongLargeFactorial.cpp (see Problem 3 of § 18.1) can be used to verify the results of this Problem. We should
also note that r in these Problems represents the least non-negative residue of the given congruences.
130
11.2 Euler’s Theorem 131
Solution: In Problem 3 of § 2.9.1 of V1 we proved (by using Wilson’s theorem) that (q!)2 + (−1)q is
divisible by p ∈ P where p = 2q + 1, i.e.
p p p
(q!)2 + (−1)q = 0 → (q!)2 = −(−1)q → (q!)2 = (−1)q+1
p−1
Now, if p = 4k + 1 then q ≡ 2 is even (i.e. q = 2k) and hence:
2
2 p−1 p
(q!) ≡ ! = (−1)q+1 = (−1)2k+1 = −1
2
p−1
while if p = 4k − 1 then q ≡ 2 is odd (i.e. q = 2k − 1) and hence:
2
2 p−1 p
(q!) ≡ ! = (−1)q+1 = (−1)2k−1+1 = (−1)2k = +1
2
i.e. x = p−1
2 ! when p = 4k + 1.
p
Regarding the only if part, let assume that x2 + 1 = 0 has a solution with p 6= 4k + 1 (i.e. p = 4k − 1).
p
This implies that x and p are coprime (because otherwise we will have 0 + 1 = 0). So, by Fermat’s little
theorem we have:
p p p 2k−1 p p
xp−1 = 1 → x4k−1−1 = 1 → x4k−2 = 1 → x2 =1 → (−1)2k−1 = 1
p
i.e. −1 = 1 which is nonsensical noting that p is an odd prime. So, this contradiction implies (by con-
p
traposition) that x2 + 1 = 0 has no solution when p 6= 4k + 1.
30
2. Show that the congruence x45 = x is true identically (i.e. it is satisfied by all x ∈ Z).
2 3 5
Solution: We note that 30 = 2 × 3 × 5. So, we need to show that x45 = x, x45 = x and x45 = x are
true identically.
2 2
Regarding x45 = x, this congruence is equivalent to x45 − x = 0 which is true identically because the
LHS is always even.
3
Regarding x45 = x, we use Fermat’s little theorem (repeatedly), that is:
15 3 15 5 3 2 3
x45 = x3 = x = x3 = x5 = x3 x−1 = x2 x−1 = x
Similarly:
9 5 2 5
x45 = x5 = x9 = x5 x−1 = x2 x−1 = x
2 3 5 30
So, x45 = x, x45 = x and x45 = x are true identically and hence x45 = x is true identically.
3. Use Fermat’s little theorem to find r:
401 2703
(a) 172804 = r. (b) 132455 = r.
Solution:
(a) We have:
401 7 401 401
r = 172804 = 17401 17−3 = 177 × 17−3 = 174 = 113
(b) We note that 2703 = 3 × 17 × 53. Now, we have:
3 3
r = 132455 = 12455 = 1
17 144 7 17 144 9 17 17
r = 132455 = 1317 13 = 13 × 137 = 13151 = 1317 13−2 = 139 × 13−2 = 137 = 4
53 47 −36 53 47 53
r = 132455 = 1353 13 = 13 × 13−36 = 1311 = 16
3 17 53
So, we have the following system of linear congruence equations: r = 1, r = 4 and r = 16. On solving
2703
this system (e.g. by the Chinese remainder theorem) we get r = 2401.
17
polynomial” congruence (i.e. 0 = 0) which is always true regardless of the value of x.
4 4 4
(2a + 1)2 + (2b)2 = 4a2 + 4a + 1 + 4b2 = 1 6= 3 = 4k + 3 = n
As we see, the sum of two squares is incongruent (mod 4) to n = 4k +3 and hence n cannot be expressed
as a sum of two squares.
4. Show that no integer of the form n = 8k + 7 (where k ∈ Z) can be expressed as a sum of three (perfect)
squares.
Solution: We simply prove this theorem by showing that no sum of three perfect squares of integers
can be of the form 8k + 7. Now, n is odd and hence it cannot be the sum of three even integers. Also,
n cannot be the sum of two odd integers plus an even integer. So, we have only two possibilities:
• All the three squares are odd say (2a + 1)2 , (2b + 1)2 and (2c + 1)2 where a, b, c ∈ Z and hence:
where step 2 is because (a2 + a), (b2 + b) and (c2 + c) are all even.
• Two of the squares are even and the third is odd say (2a)2 , (2b)2 and (2c + 1)2 where a, b, c ∈ Z and
hence:
(2a)2 + (2b)2 + (2c + 1)2 = 4a2 + 4b2 + 4c2 + 4c + 1 = 4(a2 + b2 ) + 8C + 1
Now:
If a and b are of the same parity then (a2 + b2 ) is even (say a2 + b2 = 2D) and hence we have:
8 8 8
4(a2 + b2 ) + 8C + 1 = 4(2D) + 8C + 1 = 8D + 8C + 1 = 1 6= 7 = 8k + 7 = n
Similarly, if a and b are of opposite parity then (a2 + b2 ) is odd (say a2 + b2 = 2D + 1) and hence we
have:
8 8 8
4(a2 + b2 ) + 8C + 1 = 4(2D + 1) + 8C + 1 = 8D + 8C + 5 = 5 6= 7 = 8k + 7 = n
So, in all cases the sum of three squares is incongruent (mod 8) to n = 8k + 7 and hence n cannot be
expressed as a sum of three squares.
Chapter 12
Floors and Ceilings
j 2 k 2
1. Solve the following equation (where x ∈ Z): x +2x−1
7 = x +2x−1
7 .
Solution: The floor of a real number is equal to the number iff the number is an integer. So, the given
equation is a statement that (x2 + 2x − 1)/7 is an integer, and hence it is equivalent to the congruence
7
equation x2 + 2x − 1 = 0. Thus, the solutions of the given equation are: x = 2 + 7k and x = 3 + 7k
(where k ∈ Z).
2. Solve the following equations (where x ∈ R):
(a) ⌈7 ⌊x⌋ + 12x⌉ = 39. (b) 25 ⌊x⌋ − 18 ⌈x⌉ = 91. (c) x2 + 12x − 4 = 22.
Solution:
(a) Let ⌊x⌋ = X and hence we have ⌈7X + 12x⌉ = 39. This means:
38−7X
38 < 7X + 12x ≤ 39 → 38 − 7X < 12x ≤ 39 − 7X → 12 < x ≤ 39−7X
12
Also, ⌊x⌋ = X means X ≤ x < (X + 1). So, we need to solve the following system of inequalities:
38−7X 39−7X
12 <x≤ 12 and X ≤ x < (X + 1)
This system implies:
38−7X 26
12 < (X + 1) → (38 − 7X) < (12X + 12) → 26 < 19X → X> 19
39−7X 39
X≤ 12 → 12X ≤ (39 − 7X) → 19X ≤ 39 → X≤ 19
On combining these results we get 26 39
19 < X ≤ 19 , i.e. X = 2 (noting that X is an integer). Now, on
38−7X
substituting this into the equation 12 < x ≤ 39−7X 12
24
we get 12 25
< x ≤ 12 25
(i.e. 2 < x ≤ 12 ).
(b) We have two cases to consider:
• x is an integer and hence ⌊x⌋ = ⌈x⌉ = x, that is:
25 ⌊x⌋ − 18 ⌈x⌉ = 91 → 25x − 18x = 91 → 7x = 91 → x = 13
• x is not an integer. Now, if ⌊x⌋ = xf then ⌈x⌉ = xf + 1 and hence:
25 ⌊x⌋ − 18 ⌈x⌉ = 91 → 25xf − 18(xf + 1) = 91 → 7xf = 109 → xf = 109
7 ≃ 15.57
which is nonsensical because xf is integer.
So, the only solution
to 25 ⌊x⌋ − 18 ⌈x⌉ = 91 is x = 13.
(c) x2 + 12x − 4 = 22 means 21 < x2 + 12x − 4 ≤ 22. So, we have two inequalities to consider:
• 21 < x2 + 12x − 4 and hence:
25 < x2 + 12x → 61 < x2 + 12x + 36 → 61 < (x + 6)2
√ √ √ √
So, either − 61 > (x + 6) or 61 < (x + 6), i.e. x < −6 − 61 or x > −6 + 61.
• x2 + 12x − 4 ≤ 22 and hence:
x2 + 12x ≤ 26 → x2 + 12x + 36 ≤ 62 → (x + 6)2 ≤ 62
√ √ √ √
So, − 62 ≤ (x + 6) ≤ 62, i.e. −6 − 62 ≤ x ≤ −6 + 62.
So, the solution is the intersection of the inequalities:
√ √ √ √
x < −6 − 61 x > −6 + 61 −6 − 62 ≤ x ≤ −6 + 62
which is: √ √ √ √
−6 − 62 ≤ x < −6 − 61 and −6 + 61 < x ≤ −6 + 62
l 3 2
m
3. Solve the following equation x +2x x−35x+1 = 0 (where Z ∋ x 6= 0).
135
12 FLOORS AND CEILINGS 136
Solution: We have:
3
x + 2x2 − 35x + 1 1 1
= x2 + 2x − 35 + = x2 + 2x − 35 + =0
x x x
which is even.
• If x is odd (say x = 2k + 1) then we have:
2 lx m 2
x+1 2k + 2 2k + 1 2 1
+3 +2 = +3 + 2 = ⌊k + 1⌋ + 3 k + + 2
2 2 2 2 2
= (k + 1)2 + 3(k + 3) = k 2 + 2k + 1 + 3k + 9 = k 2 + 5k + 10
which is even.
So, the given expression is even in both cases and hence it is always even.
6. Solve the following equation (where x ∈ N0 ): x2 + 4 x3 = 329.
Solution: We have six cases to consider (where k ∈ N0 ):
• x = 6k and hence we have 3k + 4(2k) = 329 which has no solution.
• x = 6k + 1 and hence we have 3k + 4(2k + 1) = 329 which has no solution.
• x = 6k + 2 and hence we have 3k + 1 + 4(2k + 1) = 329 which has no solution.
• x = 6k + 3 and hence we have 3k + 1 + 4(2k + 1) = 329 which has no solution.
• x = 6k + 4 and hence we have 3k + 2 + 4(2k + 2) = 329 whose solution is k = 29 and hence x = 178.
• x = 6k + 5 and hence we have 3k + 2 + 4(2k + 2) = 329 whose solution is k = 29 and hence x = 179.
So, the only solutions to the given equation are: x = 178 and x = 179.
7. Solve the following series equations (where x ∈ N):
Px Px
(a) k=1 25 k = 87. (b) k=1 25 k = 109.
Solution: P
25
(a) We have k=1 25 k = 87. Now, for all k > 25 we have 25 k = 0, and hence the sum remains 87 for
all x > 25. So,Pthe solution of the given equation is x = 25, 26, 27,
.25. ..
25
(b) We have k=1 25 k = 109. Now, for all k > 25 we have k = 1, and hence the sum keeps
increasing. So, the solution of the given equation j 2k is x = 25.
8. Solve the following inequality (where x ∈ Z): 3x 37 < 5x.
j 2k 2
j 2k
Solution: If 3x 37 < 5x then we must have 3x 2
37 < 5x, i.e. 3x −185x < 0. This is because if
3x
37 < 5x
j 2k
3x 3x2
then 5x is greater than 37 by at least 1 (noting that the two sides are integers) while 37 cannot
j 2k
be greater than 3x 37 by 1 (i.e. if it is greater then it is greater by less than 1). The solution of this
12 FLOORS AND CEILINGS 137
j 2k
inequality (i.e. 3x2 − 185x < 0) is 1 ≤ x ≤ 61. So, the solutions of the inequality 3x 37 < 5x are:
x = 1, 2, . . . , 61. It is worth noting that this Problem can be easily solved computationally (e.g. by a
computer code or a spreadsheet).
9. Let us define f (x, y) as follows (where x, y ∈ N):
( xy
1 12 =1
f (x, y) = xy
0 12 6= 1
140
13 GCD AND LCM 141
k
So, let us assume that g ≡ gcd(n, k) > 1 and hence n = gν and k = gκ and thus (from m = n) we
have m = sk + n = g(sκ + ν) which means that g|m and hence g is a common factor of m and k which
contradicts the condition that gcd(m, k) = 1. So, we must have gcd(n, k) = 1.
5. Find gcd(n, n + 2) for all n ∈ N.
Solution: For even n (say n = 2m where m ∈ N) we have:
mn (3290 + 1)(370 + 1)
lcm(m, n) = = = 9827 . . . 4650
gcd(m, n) 310 + 1
which is a 167-digit integer.
(b) If x = 510 then m = x33 + 1 and n = x39 + 1. The gcd of x33 + 1 and x39 + 1 is x3 + 1. Hence,
gcd(m, n) = 530 + 1 = 931322574615478515626.
Regarding the lcm, we have:
mn (5330 + 1)(125130 + 1)
lcm(m, n) = = = 1946 . . . 5626
gcd(m, n) 530 + 1
which is a 483-digit integer.
13 GCD AND LCM 142
9. Show that if m, n, k are integers (which are not all zero) then there are s, t, u ∈ Z such that gcd(m, n, k) =
sm + tn + uk.
Solution: We note first that in the following we use the rules of gcd which we stated in § 2.4 of V1
without detailed reference to these rules because of their obviousness.
If (exactly) two of m, n, k are 0 (say n = k = 0) then we have gcd(m, 0, 0) = gcd(m, 0) = (±1)m+t0+u0
(where plus for m > 0 and minus for m < 0).
If (exactly) one of m, n, k is 0 (say k = 0) then we have gcd(m, n, 0) = gcd(m, n) = sm + tn + u0.
If none of m, n, k is 0 then we have:
gcd(m, n, k) = gcd m, gcd(n, k) = sm + α gcd(n, k) = sm + α(βn + γk) = sm + tn + uk
11. Express gcd(60, 105, 70, 385) as a linear combination of 60, 105, 70, 385.
Solution: The procedure (or “algorithm”) for doing this can be easily inferred from the argument of
Problem 9, that is:
gcd(60, 105, 70, 385) = gcd gcd(60, 105), gcd(70, 385) = gcd 15, 35 = (−2)15 + (1)35
= (−2) gcd(60, 105) + (1) gcd(70, 385)
= (−2) (2)60 + (−1)105 + (1) (−5)70 + (1)385
= (−4)60 + (2)105 + (−5)70 + (1)385
k
12. Show that if m = n then gcd(m, k) = gcd(n, k).
k
Solution: m = n means m = n + bk (where b ∈ Z) and hence gcd(m, k) = gcd(n + bk, k). Now, if k is
a factor of n then we have:
On the other hand, if k is not a factor of n then let g = gcd(n, k) and hence we have:
where the third step is justified by the fact that n′ and k ′ are coprime and hence gcd(n′ + bk ′ , k ′ ) = 1.
So, in both cases we have gcd(m, k) = gcd(n, k).
13. Let m, n be coprime integers. Find the following:
(a) gcd(2m + n, 3m + 5n). (b) gcd(7m + 3n, 3m + 4n).
Solution:
(a) Let S = 5(2m + n) − (3m + 5n) = 7m and D = 2(3m + 5n) − 3(2m + n)= 7n. Now, if d is any
common factor of (2m + n) and (3m + 5n) then d should divide both S and D i.e. d|(7m) and d|(7n)
and hence d should divide their gcd i.e. d| gcd(7m, 7n); see Problem 10 of § 2.4 of V1 . Now:
where the second step is because m and n are coprime. Accordingly, d|7 which means that d is either
±1 or ±7 and hence gcd(2m + n, 3m + 5n) = 1 or gcd(2m + n, 3m + 5n) = 7.
13 GCD AND LCM 143
(b) Let S = 4(7m + 3n) − 3(3m + 4n) = 19m and D = 7(3m + 4n) − 3(7m + 3n) = 19n. Now, if d is
any common
factor of (7m + 3n) and (3m + 4n) then d should divide both S and D i.e. d|(19m) and
d|(19n) and hence d should divide their gcd, i.e. d| gcd(19m, 19n). Now:
Accordingly, d|19 which means that d is either ±1 or ±19 and hence gcd(7m + 3n, 3m + 4n) = 1 or
gcd(7m + 3n, 3m + 4n) = 19.
14. Propose an “efficient algorithm” for computing the gcd of a large number of (distinct) positive integers
greater than 1.[89]
Solution: This “algorithm” is outlined in the following points:
• Take the smallest of these numbers (noting that the gcd cannot exceed in magnitude its operands).
• If anyone of the remaining numbers is prime then the gcd is 1 (because the smallest cannot be divisible
by the prime which is divisible only by itself and 1).
• If the smallest is prime (and none of the remaining numbers is prime) then order the remaining
numbers increasingly and start dividing the remaining numbers by the smallest. If anyone of the
remaining numbers is not divisible by the smallest then the gcd is 1; otherwise the gcd is the smallest.
• If the smallest is composite (and none of the remaining numbers is prime) then:
Order the remaining numbers increasingly and calculate the gcd of the smallest with the second smallest
(say gcd1 ).
Calculate the gcd of the third smallest with the gcd1 and hence find their gcd (say gcd2 ).
Continue this process i.e. calculating the gcd of the (n + 2)th smallest with the gcdn to obtain gcdn+1
until you get a gcd that is equal to 1 (and hence the gcd of the given numbers is 1) or you reach the
last remaining numbers (and hence the gcd of the given numbers is the last obtained gcd).
15. Find the gcd of the following integers using the “algorithm” of Problem 14:
(a) 2135, 1152, 5531, 789, 7105, 3329, 1287, 105, 69917, 7709, 11679, 33219, 4727, 2752.
(b) 1261, 679, 8536, 5917, 97, 2910, 388, 1843, 2619, 9797, 5238.
Solution:
(a) The smallest of these numbers is 105 which is composite. On testing the remaining numbers one by
one (say in their increasing order to simplify the process) we find that 3329 is prime. Hence, the gcd of
these numbers is 1.
(b) The smallest of these numbers is 97 which is prime. On inspecting the remaining numbers one by
one we find that they are all divisible by 97. Hence, the gcd of these numbers is 97.
16. Find the lcm of the following integers:
7907, 178, 2315, 443, 6682, 2971, 55349, 16728, 1291, 5681, 22100, 3607, 5641, 19996
Solution: The following numbers are prime: 7907, 443, 2971, 1291, 3607, 5641. The prime-factorizations
of the remaining numbers are:
178 = 2 × 89 2315 = 5 × 463 6682 = 2 × 13 × 257 55349 = 7 × 7907
16728 = 23 × 3 × 17 × 41 5681 = 13 × 19 × 23 22100 = 22 × 52 × 13 × 17 19996 = 22 × 4999
So, the lcm of these numbers is:
240680395597658170044361592180236529515800
17. Find the gcd of all the elements of the following sets (where x ∈ Z):
(a) {x7 − x}. (b) {x11 − x}.
[89] If
one of the numbers is 0 then we simply ignore it (noting that the gcd of the rest is the same as the gcd of the numbers
including 0). If one of the numbers is 1 then the gcd of the numbers is 1. If the numbers include negatives then we
take their absolute value (noting that the gcd is not affected by sign). We note that “efficient algorithm” is because
the traditional methods for calculating the gcd of a large number of integers are not efficient especially when the given
numbers are large in magnitude.
13 GCD AND LCM 144
Solution:
(a) According to Problem 3 of § 8.2, any prime number that divides (x7 − x) for all x ∈ Z must be
less than or equal to 7. So, the gcd of {x7 − x} can contain only the following primes: p = 2, 3, 5, 7.
p
On testing these primes on the congruence x7 = x we find that only p = 2, 3, 7 satisfy this congruence
identically (i.e. for all x ∈ Z). So, the prime factors of the gcd of the elements of {x7 − x} are only
2, 3, 7. Moreover, p2 (and hence any higher natural power of p) of these primes does not divide x7 − x
identically because:
22 32 72
27 − 2 = 2 37 − 3 = 6 77 − 7 = 42
So, the gcd of the elements of the set {x7 − x} for all x ∈ Z is 2 × 3 × 7 = 42.
(b) As in part (a), any prime number that divides (x11 − x) for all x ∈ Z must be less than or equal to
11. So, the gcd of {x11 − x} can contain only the following primes: p = 2, 3, 5, 7, 11. On testing these
p
primes on the congruence x11 = x we find that only p = 2, 3, 11 satisfy this congruence identically (i.e.
for all x ∈ Z). So, the prime factors of the gcd of the elements of {x11 − x} are only 2, 3, 11. Moreover,
p2 (and hence any higher natural power of p) of these primes does not divide x11 −x identically because:
22 32 112
211 − 2 = 2 311 − 3 = 6 1111 − 11 = 110
So, the gcd of the elements of the set {x11 − x} for all x ∈ Z is 2 × 3 × 11 = 66.
18. Find the gcd of 17! + 17 and 18! + 17.
Solution: No prime < 17 can divide 17! + 17 because such a prime divides 17! but not 17. So, no prime
< 17 can be a factor in the gcd of 17! + 17 and 18! + 17.
Also, no prime > 17 can divide both 17! + 17 and 18! + 17 because if such a prime can divide both then
it should divide their difference, that is:
(18! + 17) − (17! + 17) = 18! − 17! = 17!(18 − 1) = 17! × 17
As we see, any prime > 17 can divide neither 17! nor 17 and hence it cannot divide their product. This
implies that no prime > 17 can divide both 17! + 17 and 18! + 17. So, no prime > 17 can be a factor
in the gcd of 17! + 17 and 18! + 17.
Thus, the only possible prime that can divide both 17! + 17 and 18! + 17 (and hence it can be a factor
in their gcd) is 17. So, the gcd of 17! + 17 and 18! + 17 must be a natural power of 17. Now if we try
172 and 173 we find that only 172 divides both 17! + 17 and 18! + 17. Hence, we conclude that the gcd
of 17! + 17 and 18! + 17 is 172 = 289.
Chapter 14
Last Digits
1. Find the last 6 digits of the following (where n ∈ N):
(a) 3412378234699945612 × 7562988712348990246. (b) 999999n .
(c) 1001n . (d) 19230 .
Solution:
(a) The last 6 digits of this product are determined by the product of the last ∼ 6 digits of the
multiplicands (noting that the higher rank digits of the multiplicands contribute only to the higher
rank digits of the product). Accordingly:
As we see, the last 6 digits of the product do not change in the last two equalities (where we take the
last 6 and 7 digits only) and hence the last 6 digits of the given product are 500552.
106 106
(b) The last 6 digits x are given by x = 999999n which is equivalent to x = (−1)n . Now, for n odd
106 106 106 106
we have x = (−1)n = −1 = 999999 while for n even we have x = (−1)n = 1 = 000001. So, the last
6 digits of 999999n are 999999 for odd n and 000001 for even n.
(c) We have:
where line 2 is justified by the binomial theorem (see Eq. 13 in V1), and line 3 is because all the
(C2n 10002 + · · · ) terms have a factor of 106 . Now, if n = · · · d2 d1 d0 (where the d’s stand for digits and
where · · · d2 d1 could be totally or partially 0) then the last 6 digits x of 1001n are:
x = 1 + d2 d1 d0 000 = d2 d1 d0 001
For example, for n = 6, 84, 892, 4574 we have x = 006001, 084001, 892001, 574001.
(d) 195 = 2476099 and hence:
145
14 LAST DIGITS 146
106
= 113896099 × (−9895501)
106
= 449401
[90] For 4 4
example, 6345 − 3 = (−1)45 − 3 = −4 = 0 and hence 6345 − 3 = 4k (k ∈ N). Therefore:
45 10 45 45 k 10 10
3763 = (−3)63 = (−3)63 (−3)3 = (−3)4k (−3)3 = (−3)4 (−3)3 = 1k (−3)3 = −27 = 3
−3
14 LAST DIGITS 147
Solution:
1000
(a) On inspecting the low values of n we find that the lowest n such that 197n = 677 is n = 73, while
1000
the lowest n such that 197n = 1 is n = 100.[91] Hence:
k 1000 1000
19773+100k = 19773 × 197100k = 19773 × 197100 = 19773 × 1k = 19773 = 677
i.e. the last digit of n5 is the same as the last digit of n for all n ∈ N0 .
6. Show that no perfect square ends in 2, 3, 7, 8.
Solution: This is a consequence of the result of Problem 4 noting that the squares of 0, 1, 2, 3, 4, 5,
6, 7, 8, 9 are: 0, 1, 4, 9, 16, 25, 36, 49, 64, 81.
7. Find the last digit of the quadratic expression 5n2 − 3n + 17 for all n ∈ Z.
Solution: Let f (n) ≡ 5n2 − 3n + 17. Now, we have:
5 10
f n = 1, 2, 3, 4, 5 = 9, 1, 3, 5, 7
i.e. the last digit of the given expression for n = 1 + 5k, 2 + 5k, 3 + 5k, 4 + 5k, 5 + 5k (where k ∈ Z) is
9, 1, 3, 5, 7 (respectively).
8. Find the last two digits of the factorial expression 7n! + 237 for all n ∈ N0 .
Solution: By inspection, the last two digits of the expression for n = 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 is 44, 44,
51, 79, 05, 77, 77, 17, 77, 97.
Regarding n ≥ 10, the number of trailing zeros in n! (and hence in 7n!) is not less than two (see Eq.
84 in V1) and hence the last two digits of the sum 7n! + 237 is the same as the last two digits of 237
(i.e. 37). So, the last two digits of the given expression is 37 for all n ≥ 10.
[91] This inspection can be done by writing a simple code using modular arithmetic where exponentiation is done by repet-
itive multiplication in which only the last few digits of the product are taken in each stage. The reader can use the
LastDigit1.cpp code (which is in the “Codes” directory) for this inspection.
[92] Again, the reader can use the LastDigit1.cpp code for this inspection.
[93] In fact, we can use the result of Problem 4 directly. However, we prefer this for clarity and demonstration.
14 LAST DIGITS 148
9. Find the last digit of the exponential expression 699999993n + 1 for all n ∈ N.
Solution: We have:
699999993n + 1 = (11111111n × 9n × 7n ) + 1
Now:
11111111n always terminates in 1 and hence it has no cycle (i.e. its period is 1).
9n has a cycle of 2, i.e. it terminates in 9 for odd n and in 1 for even n.
7n has a cycle of 4, i.e. it terminates in 7, 9, 3, 1 corresponding to n = 1 + 4k, 2 + 4k, 3 + 4k, 4 + 4k
(where k ∈ N0 ).
So, 699999993n + 1 has a cycle of 4, i.e. it terminates in 4, 0, 8, 2 corresponding to n = 1 + 4k, 2 + 4k, 3 +
4k, 4 + 4k.
2
10. Find the last digit of the expression x+1 2 + 3 x2 + 2 for all x ∈ Z.
Solution: In Problem 5 of § 12 it was shown that this expression is always even and hence the last
digit can only be 0, 2, 4, 6, 8. Moreover, this expression is equal to:
k 2 + 3k + 6 when x is even and k 2 + 5k + 10 when x is odd
10
Now, if we try k 2 + 3k + 6 = 0, 2, 4, 6, 8 we find that this congruence has solutions only for 0, 4, 6. Sim-
10
ilarly, if we try k 2 + 5k + 10 = 0, 2, 4, 6, 8 we find that this congruence has solutions only for 0, 4, 6. So,
the last digit of this expression can only be 0, 4, 6. Further inspection should reveal that the last digit
10
of this expression is 0, 0, 6, 6, 4, 4, 4, 4, 6, 6 corresponding to x = 1, 2, 3, 4, 5, 6, 7, 8, 9, 10.
Chapter 15
Divisibility
1. Find all natural numbers of the form abab which are divisible by 9 (where a, b are digits).
Solution: We have abab = 101 × ab. Now, 101 is not divisible by 9 and hence if abab is divisible by 9
then ab must be divisible by 9, i.e. a + b must be divisible by 9. So, we have only the following eleven
possibilities: ab = 09, 18, 27, 36, 45, 54, 63, 72, 81, 90, 99.
2. Show that for any n ∈ Z, 7|(n − 1) iff 343|(n3 − 3n2 − 46n + 48).
Solution: We note first that n3 − 3n2 − 46n + 48 = (n − 8)(n − 1)(n + 6) and 343 = 73 . Moreover,
7 7
n − 8 = n − 1 = n + 6. Now:
7 7
• If 7|(n − 1) then 7|(n − 8) and 7|(n + 6) (noting that n − 8 = n − 1 = n + 6) and hence 73 divides
their product which is (n3 − 3n2 − 46n + 48), i.e. 343|(n3 − 3n2 − 46n + 48).
• If 343|(n3 − 3n2 − 46n + 48) then 7 must divide each one of its three factors and hence 7 must divide
(n − 1), i.e. 7|(n − 1).[94]
3. Show that for any n ∈ Z, 5|(n3 − 3n2 + 2n) iff 56 | (n2 − 7n + 12) and vice versa.
Solution: We have:
5
• n3 − 3n2 + 2n = n(n − 1)(n − 2) and hence it is obvious that the solutions of n3 − 3n2 + 2n = 0 are
5
n = 0, 1, 2.
5
• n2 − 7n + 12 = (n − 3)(n − 4) and hence it is obvious that the solutions of n2 − 7n + 12 = 0 are
5
n = 3, 4.
5 5
So, the residue classes (mod 5) are partitioned (as solutions) between n3 −3n2 +2n = 0 and n2 −7n+12 =
0 and hence what solves one of these congruences does not solve the other congruence and vice versa,
i.e. 5|(n3 − 3n2 + 2n) iff 56 | (n2 − 7n + 12) and vice versa.
4. Show that for any N ∋ n > 2 there are x, y, z ∈ N (where x 6= y 6= z and n2 < x, y, z < n3 ) such that
z|(x2 − y 2 ).
Solution: For example, x = n2 + 2, y = n2 + 1 and z = 2n2 + 3 meet these conditions because:
2 2
x2 − y 2 = n2 + 2 − n2 + 1 = 2n2 + 3 = z
x2 + y 2 x2 + y 2
= 31k → = k(x + y)
x+y 31
31 31
i.e. 31|(x2 + y 2 ). This implies that x2 + y 2 = 0 whose only solution is (x, y) = (0, 0). Accordingly, the
solutions of this Problem are: (x, y) = (31s, 31t) where s, t ∈ Z and s + t 6= 0.
[94] To be more clear we may say: if 343|(n3 − 3n2 − 46n + 48) then 7 must divide one of the three factors of the polynomial
7 7
(noting that 343 = 73 ) and hence 7 must divide all the three factors of the polynomial (noting that n − 8 = n − 1 = n + 6),
i.e. 7|(n − 1).
149
15 DIVISIBILITY 150
(b) Again, x + y 6= 0. Let a symbolize a divisor of 35, i.e. a = ±1, ±5, ±7, ±35. Hence, we must have
x2 +y 2
x+y = a, that is:
X 2 + Y 2 = 2a2
Now, we have four cases to consider:
• a = ±1 and hence X 2 + Y 2 = 2. Now, the only possibility for 2 to be the sum of two squares is
(X, Y ) = (±1, ±1) and hence the solutions (x, y) are (noting that x = y = 0 is not a possibility):
(0, 1) (1, 0) (1, 1) (−1, −1) (−1, 0) (0, −1)
2 2
• a = ±5 and hence X + Y = 50. Now, the only possibilities for 50 to be the sum of two squares are
(X, Y ) = (±1, ±7), (±5, ±5), (±7, ±1) and hence the solutions (x, y) are (noting that x = y = 0 is not
a possibility):
(2, −1) (2, 6) (3, −1) (3, 6) (−3, −6) (−3, 1) (−2, −6) (−2, 1)
(−1, 2) (6, 2) (−1, 3) (6, 3) (−6, −3) (1, −3) (−6, −2) (1, −2)
2 2
• a = ±7 and hence X + Y = 98. Now, the only possibility for 98 to be the sum of two squares is
(X, Y ) = (±7, ±7) and hence the solutions (x, y) are (noting that x = y = 0 is not a possibility):
(0, 7) (7, 0) (7, 7) (−7, −7) (−7, 0) (0, −7)
• a = ±35 and hence X 2 + Y 2 = 2450. Now, the only possibilities for 2450 to be the sum of two squares
are (X, Y ) = (±7, ±49), (±35, ±35), (±49, ±7) and hence the solutions (x, y) are (noting that x = y = 0
is not a possibility):
(14, −7) (14, 42) (21, −7) (21, 42) (−21, −42) (−21, 7) (−14, −42) (−14, 7)
(0, 35) (35, 0) (35, 35) (−35, −35) (−35, 0) (0, −35)
(−7, 14) (42, 14) (−7, 21) (42, 21) (−42, −21) (7, −21) (−42, −14) (7, −14)
So in brief, we have 56 solutions.
(c) As before, we assume x − y 6= 0. Now, the divisors of 21 are a = ±1, ±3, ±7, ±21 and hence if we
follow a similar approach to that of part (b) then we get:
• a = −21 leads to the solutions: (x, y) = (−21, 0), (−21, 21), (0, 21).
• a = −7 leads to the solutions: (x, y) = (−7, 0), (−7, 7), (0, 7).
• a = −3 leads to the solutions: (x, y) = (−3, 0), (−3, 3), (0, 3).
• a = −1 leads to the solutions: (x, y) = (−1, 0), (−1, 1), (0, 1).
• a = 1 leads to the solutions: (x, y) = (0, −1), (1, −1), (1, 0).
• a = 3 leads to the solutions: (x, y) = (0, −3), (3, −3), (3, 0).
• a = 7 leads to the solutions: (x, y) = (0, −7), (7, −7), (7, 0).
• a = 21 leads to the solutions: (x, y) = (0, −21), (21, −21), (21, 0).
So, these 24 pairs are all the solutions of this problem.
6. Find all x, y, z ∈ Z such that:
(a) xy|(x2 + y 2 ). (b) xyz|(x2 + y 2 ).
Solution:
(a) It is obvious that xy 6= 0. If xy|(x2 + y 2 ) then we have:
x2 + y 2 x y
=k → + =k (k ∈ Z)
xy y x
15 DIVISIBILITY 151
if x = y = 1 then we have only one possibility for z, i.e. z = 4. So, only (x, y, z) = (1, 1, 4) makes
A = 5.
• A = 6: x must be 1 because otherwise A < 6. Similarly, y must be 1 because otherwise A < 6. Now,
if x = y = 1 then we have only one possibility for z, i.e. z = 2. So, only (x, y, z) = (1, 1, 2) makes
A = 6.
• A = 7: as before, we must have x = y = 1 because otherwise A < 7. Now, if x = y = 1 then we
must have:
(1 + 1)(1 + 1)(z + 1) 4(z + 1)
A= = =7 → 3z = 4
1×1×z z
which has no integer solution. So, we have no solution for A = 7.
• A = 8: as before, we must have x = y = 1 because otherwise A < 8. Now, if x = y = 1 then we have
only one possibility for z, i.e. z = 1. So, only (x, y, z) = (1, 1, 1) makes A = 8.
So far we were assuming x ≤ y ≤ z. Now, if we lift this condition (noting the symmetry in x, y, z) by
permuting x, y, z (and hence permuting the above 12 solutions) then we get in total 55 solutions to the
given divisibility statement.
(b) To avoid singularity we must have x 6= 1, y 6= 1 and z 6= 1. So, in the following we assume x, y, z > 1.
Now, if X = x − 1, Y = y − 1 and Z = z − 1 then we have:
XY Z| (X + 1)(Y + 1)(Z + 1) (X, Y, Z ∈ N)
So, this problem is the same as the problem of part (a) with X, Y, Z replacing x, y, z. Accordingly, we
must have the same solutions for X, Y, Z as the solutions for x, y, z in part (a). The final solutions
(x, y, z) will be obtained by the transformation: (x, y, z) = (X + 1, Y + 1, Z + 1). So in brief, the
main 12 solutions are: (x, y, z) = (2, 2, 2), (2, 2, 3), (2, 2, 5), (2, 3, 4), (2, 4, 9), (2, 5, 6), (3, 3, 4), (3, 5, 16),
(3, 6, 10), (3, 7, 8), (4, 4, 9), (4, 5, 6), while the final 55 solutions are obtained by permuting these 12
solutions.
(c) To avoid singularity we must have x, y, z > 1. So, let:
xyz − 1
A≡
(x − 1)(y − 1)(z − 1)
The maximum value of A is 7, i.e. when x = y = z = 2. Following a similar analysis to the analysis
of part (a) we find that the only solutions are: (x, y, z) = (2, 2, 2), (2, 2, 4), (2, 4, 8), (3, 5, 15) and their
permutations. So in total, we have 16 solutions.
(d) Let:
xyz − 1 xyz − 1
A ≡ =
(x + 1)(y + 1)(z + 1) xyz + xy + xz + yz + x + y + z + 1
xyz − 1
=
(xyz − 1) + (xy + xz + yz + x + y + z + 2)
It is obvious that 0 ≤ A < 1. So, the only integer value of A is 0 which occurs when x = y = z = 1.
Therefore, the only solution is: (x, y, z) = (1, 1, 1).
9. Show that 12|(2n+2 + 5n+3 − 9) for all n ∈ N0 .
12 12
Solution: 12|(2n+2 + 5n+3 − 9) is equivalent to 2n+2 + 5n+3 = 9. Now, for even n we have 2n+2 = 4
12 12 12 12
and 5n+3 = 5, while for odd n we have 2n+2 = 8 and 5n+3 = 1. Hence, the congruence 2n+2 + 5n+3 = 9
n+2 n+3 0
is always true, i.e. 12|(2 +5 − 9) for all n ∈ N .
10. Show that if m3 |n2 then m|n (where m, n ∈ N).
Solution: If the (non-standard) prime factorization of m and n are m = pa1 1 pa2 2 . . . pakk and n =
pb11 pb22 . . . pbkk then we have:
2bk
n2 p12b1 p2b
2 . . . pk
2
m3 p13a1 p3a
2
2
. . . p k
15 DIVISIBILITY 153
Now, since m3 |n2 then we must have pi2bi −3ai ≥ 1 for all i = 1, 2, . . . , k. Hence:
p2b
i
i −3ai
≥1 → p2b
i
i
≥ pi3ai → 2bi ≥ 3ai →
b b b
p11 p22 ...pkk
bi ≥ a i → n
m = a1 a2
p1 p2 ...pkk
a → n
m = pb11 −a1 pb22 −a2 . . . pbkk −ak
where pbi i −ai ≥ 1 for all i = 1, 2, . . . , k (because bi ≥ ai ). This means that n/m is an integer and hence
m|n.
We may also argue (more simply) that if m3 |n2 then (where k ∈ N):
n2
n 2 n
√
m3 = k → m = km → m = km
Now, if a square root of an integer (i.e. km) is rational (i.e n/m) then the integer (i.e. km) is a perfect
square. This means that n/m Pn is an integer and hence m|n.
11. Find all n ∈ N such that x=1 (2x5 − 6x4 − x2 + 9) is divisible by 33.
Solution: We have (see the identities of § 1.10 in V1):
n n
! n
! n
! n
!
X X X X X
5 4 2 5 4 2
(2x − 6x − x + 9) = 2 x −6 x − x +9 1
x=1 x=1 x=1 x=1 x=1
n (n + 1)2 (2n2 + 2n − 1)
2
n(n + 1)(2n + 1)(3n2 + 3n − 1)
= 2 −6 −
12 30
n(n + 1)(2n + 1)
+ 9n
6
10n6 − 6n5 − 65n4 − 70n3 − 20n2 + 271n
=
30
So, if the given series is divisible by 33 then (10n6 − 6n5 − 65n4 − 70n3 − 20n2 + 271n) must be divisible
99
by 99 (noting that 33 and 10 are coprime), i.e. 10n6 − 6n5 − 65n4 − 70n3 − 20n2 + 271n = 0. The
99
solution to this congruence equation is n = 0, 44, 88 (see § 3.2.1 of V1 as well as § 8.2 of the present
volume). So, the given series is divisible by 33 iff n = 44 + 99m or n = 88 + 99m or n = 99(1 + m)
where m ∈ N0 .
12. Find the remainder when:
(a) 2978354896302 is divided by 101. (b) 36718924 is divided by 663.
(c) 563897823 is divided by 5931.
Solution:
101
(a) If r represents the remainder then we have 2978354896302 = r and hence:
101 101 548963 2 φ(101) 548963 2 101 548963 2
r = 2978354896302 = 8954896302 = 89100 89 = 89 89 = 1 89
101
= 892 = 43
where we used Euler’s theorem in the fifth step (noting that 29783 and 101 are coprime).
(b) We have 663 = 3 × 13 × 17. Let r be the remainder when 36718924 is divided by 663 and hence
663
36718924 = r. Now:
3 4462 3 4462
36718924 = 28924 = 22 =1 =1
8924 13 8924
4 2231 13 2231
3671 = 5 = 5 =1 =1
17
36718924 = (−1)8924 = 1
663 3 13 17
Now, since 36718924 = r then we must have r = 1, r = 1 and r = 1. On solving this system of
663
congruence equations[95] (using for instance the Chinese remainder theorem) we get: r = 1, i.e. the
[95] More simply, we can use rule 14 of § 2.7 of V1.
15 DIVISIBILITY 154
13
where the second step is because of the result of the “if part” while theP last step is because 712n = 1
s−1
(by Fermat’s little theorem and the power rule for congruences). Now, k=0 7k is not divisible by 13
(as we concluded earlier in the case of 0 ≤ m ≤ 10), and hence the given series is not divisible by 13
for any m 6= 12n − 1, i.e. if 13 divides the given series then m = 12n − 1.
15 DIVISIBILITY 155
(for some k ∈ N). Since 445! and 6454 are divisible by 14 then r should also be divisible by 14, i.e.
r = 14ρ (for some ρ ∈ N). Thus:
6454 445! 461 461 460!461 460!
445! = 14ρ → 14 = ρ → 445! = 14ρ → 445! 445! = 445! r →
461 460! 461 460! 461 461
460! = 445! r → −1 = 445!
r → 396r = −1 → r = 383
where:
steps 1 and 2 are from rules 9 and 6 of § 2.7 of V1,
step 5 is from Wilson’s theorem (noting that 461 is prime),
460! 461
step 6 is because 445! = 446 × 447 × · · · × 460 = 396, and
461 461
step 7 is because r = −1 × 396∗ = −78 = 383.
14 461
So, we have r = 0 (because r = 14ρ) and r = 383. On solving this system of congruence equations
6454
(using for instance the Chinese remainder theorem) we get: r = 2688, i.e. the remainder when 445!
is divided by 6454 is 2688.
20. Find the remainder when:
(a) 729 1618 is divided by 23. (b) 792606470587122315 is divided by 18.
Solution: In this Problem we use a method based on the index of integer (see § 1.5). In the following
r symbolizes the remainder.
(a) A primitive root of 23 is 5 and we have noting that φ(23) = 22 :
23 φ(23)
r = 729 1618 → I23,5 (r) = I23,5 729 1618 →
22 22
I23,5 (r) = 29 I23,5 (7) + 18 I23,5 (16) → I23,5 (r) = 29 × 19 + 18 × 8 →
22 22
I23,5 (r) = 695 → I23,5 (r) = 13
22 φ(23) 23 23
So, I23,5 (r) = 13 i.e. I23,5 (r) 13 which means r = 513 = 21. Hence, the remainder is 21.
=
18
(b) A primitive root of 18 is 5 and we have noting that φ(18) = 6 and 7926064705871 = 17 :
18 18 φ(18)
r = 792606470587122315 → r = 1722315 I18,5 (r) = I18,5 1722315 →
6 6 6
I18,5 (r) = 22315 I18,5 (17) → I18,5 (r) = 22315 × 3 = 3
6 φ(18) 18 18
So, I18,5 (r) = 3 i.e. I18,5 (r) = 3 which means r = 53 = 17. Hence, the remainder is 17.
21. Find all m ∈ Z such that m|(6n2 − 14n − 10) and m|(2n3 − 8n + 6) for all n ∈ Z.
Solution: On factorizing the two expressions we get: 6n2 −14n−10 = 2(3n2 −7n−5) and 2n3 −8n+6 =
2(n − 1)(n2 + n − 3). So, the common factor of these expressions is 2. Hence, m|(6n2 − 14n − 10) and
m|(2n3 − 8n + 6) for all n ∈ Z if m = ±1 and m = ±2.
22. Find all m ∈ Z such that m|(4n2 + 4n + 7) and m|(n2 + 5) for some n ∈ Z.
Solution: We have:
• m|(4n2 + 4n + 7) and m|(n2 + 5) and hence m (4n2 + 4n + 7) − 4(n2 + 5) , i.e. m|(4n − 13).
• m|(4n − 13) and hence m|(4n − 13)2 , i.e. m|(16n2 − 104n + 169).
• m|(16n2 − 104n + 169) and m|(4n2 + 4n + 7) and hence m (16n2 − 104n + 169) − 4(4n2 + 4n + 7) ,
i.e. m|(141 − 120n).
• m|(4n − 13) and m|(141 − 120n) and hence m 30(4n − 13) + (141 − 120n) , i.e. m|(−249).
The divisors of 249 are ±1, ±3, ±83, ±249 and hence m = ±1, ±3, ±83, ±249.
It is worth noting that:
• ±1 divides (4n2 + 4n + 7) and (n2 + 5) for all n ∈ Z. This is because ±1 divides any integer.
3 3
• ±3 divides (4n2 + 4n + 7) and (n2 + 5) for all n = 1. This is because the solution of 4n2 + 4n + 7 = 0
3 3 3
is n = 1 while the solution of n2 + 5 = 0 is n = 1, 2 and hence the solution of this system of congruence
3
equations is n = 1 (see § 9.2.1).
83 83
• ±83 divides (4n2 + 4n + 7) and (n2 + 5) for all n = 24. This is because the solution of 4n2 + 4n + 7 = 0
15 DIVISIBILITY 157
83 83 83
is n = 24, 58 while the solution of n2 + 5 = 0 is n = 24, 59 and hence the solution of this system of
83
congruence equations is n = 24.
249 249
• ±249 divides (4n2 +4n+7) and (n2 +5) for all n = 190. This is because the solution of 4n2 +4n+7 = 0
249 249 249
is n = 58, 190 while the solution of n2 + 5 = 0 is n = 59, 107, 142, 190 and hence the solution of this
249
system of congruence equations is n = 190.
23. Find all n ∈ Z such that 9|(n − 7), 17|(n + 1) and 29|(n + 11).
Solution: These divisibility statements are equivalent to the following congruence equations:
9 17 29
n=7 n = −1 n = −11
On solving this system of congruence equations (e.g. by using the Chinese remainder theorem) we get:
n = 3382 + 4437k (where k ∈ Z).
24. Show that the divisibility of 3m + n by 11 is equivalent to the divisibility of 47m − 10n by 11 (where
m, n ∈ Z).
Solution: We have:
47m − 10n = 3m + n + 44m − 11n = 3m + n + 11(4m − n)
Now, 11(4m − n) is divisible by 11 and hence the divisibility of 3m + n by 11 is equivalent to the
divisibility of 47m − 10n by 11.
25. Let q and p be odd primes (q 6= p), n is a positive even integer and k ∈ N. Show that if p|(q n + 1) then
p = 4k + 1.
Solution: We have (where n = 2ν and ν ∈ N):
p p 2 p
p|(q n + 1) → qn + 1 = 0 → q 2ν + 1 = 0 → (q ν ) = −1
i.e. −1 is a quadratic residue of p and hence −1
p = 1. So, from Problem 9 of § 1.8 we conclude that
p = 4k + 1.
26. Let m, n, k ∈ Z. Show that if m|k and n|k and g = gcd(m, n) then mng k.
Solution: Since m|k and n|k then g must be a factor of k (as well as a factor of m and n). So, let
m = gµ and n = gν while k = gκ. Accordingly, µ|κ and ν|κ where µ and ν are coprime (see point 9 in
κ
the preamble of § 2.4 of V1). Therefore, by rule 20 of § 1.9 of V1 we have (µν)|κ which means that µν
κ
is an integer (say µν = A where A ∈ Z). Now, if we multiply A by 1 in the form of g 2 /g 2 then we get:
g2 g2 κ g(gκ) gk k
A=1×A= × A = × = = =
g2 g2 µν (gµ)(gν) mn (mn)/g
which means mn g k.
Note: in Problem 6 of § 2.5 of V1 we proved the identity mn = gcd(m, n) × lcm(m, n) using a prime
factorization approach. This identity can also be obtained (possibly more easily and directly) as a
corollary of the formulation (or method or logic) of the present Problem because (noting that µ and ν
are coprime):
lcm(µ, ν) = µν → g 2 lcm(µ, ν) = gµgν → g lcm(gµ, gν) = gµgν →
g lcm(m, n) = mn → gcd(m, n) × lcm(m, n) = mn
27. Show that no odd prime of the form p = 4k − 1 can divide n2 + 1 (where k ∈ N and n ∈ Z).
p p p
Solution: If p divides n2 + 1 then n2 + 1 = 0, i.e. n2 = −1 and hence n4 = 1. Now, from Problem 1
of § 1.3 we conclude that Op n|4, i.e. Op n = 1 or Op n = 2 or Op n = 4. Now:
p p p
• If Op n = 1 then n1 = 1 and hence n2 = 1 which contradicts n2 = −1 (noting that p is an odd prime).
p p
• If Op n = 2 then n2 = 1 which (again) contradicts n2 = −1 (noting that p is an odd prime).
So, we must have Op n = 4. Now, from Problem 3 of § 1.3 (noting that p and n must be coprime since
p
n2 + 1 = 0) we must have 4|φ(p), i.e. 4|(p − 1) and hence p must be of the form 4k + 1, i.e. p cannot
be of the form 4k − 1 (see Problem 16 of § 2.2 of V1).
15 DIVISIBILITY 158
p2 −1
28. Show that 24 is an integer for all p ≥ 5 (where p ∈ P).
2
Solution: This is because for p ≥ 5 we have p 24 −1
≥ 1. Moreover:
• One of (p − 1) and (p + 1) must be divisible by 3 because (p − 1), p, (p + 1) are three consecutive
integers and p is not divisible by 3 because p ≥ 5. Now, p2 − 1 = (p − 1)(p + 1) and hence p2 − 1 must
be divisible by 3.
• (p − 1) and (p + 1) are consecutive even numbers and hence one of them must be divisible by 2 and the
other is divisible by 4 (i.e. one of them is a multiple of 2 and the other is a multiple of 4). Therefore,
their product (which is equal to p2 − 1) must be divisible by 8.
Thus, p2 − 1 is divisible by 3 and by 8 and hence it must be divisible by 24 (noting that 3 and 8 are
2
coprime), i.e. p 24−1
is an integer for all p ≥ 5.
29. Show the following:
(a) p divides the sum of its quadratic residues (where p is a prime ≥ 5).
(b) p divides the sum of the squares of its quadratic non-residues (where p is a prime ≥ 7).
Solution: 2
(a) According to Problem 2 of § 1.6, the (p − 1)/2 quadratic residues of p are: 12 , 22 , . . . , p−1
2 . Hence,
their sum is (see Eq. 16 in V1):
(p−1)/2
X p−1 p−1
+1 2× p−1
+1 p3 − p p2 − 1
2 2 2 2
k = = =p
6 24 24
k=1
p2 −1
which is divisible by p ≥ 5 (noting that is an integer for p ≥ 5; see Problem 28).
24
2
It is worth noting that although this proof is specific to the integers 12 , 22 , . . . , p−1
2 the given propo-
sition should also apply to their residue classes (mod p) since the integers in any class differ from each
other by integer multiples of p and hence the sum of quadratic residues (represented by any integer in
their classes) should be the same as above plus an algebraic sum of integer multiples of p and hence the
sum remains divisible by p.
(b) Let S symbolize the sum of the squares of the quadratic non-residues of p and let r be a primitive
root of p (see point 5 in the preamble of § 1.4). Now, since the quadratic non-residues of p are the odd
powers of r (see Problem 7 of § 1.6) then we have:
(p−1)/2 (p−1)/2 (p−1)/2 (p+1)/2
X 2 X X X
S= r2k−1 = r4k−2 → r4 S = r4k+2 = r4k−2
k=1 k=1 k=1 k=2
p p
where the last step is because rp − r = 0 by Fermat’s little theorem. Accordingly, S(r4 − 1) = 0 which
p p p p
implies that S = 0 or (r4 − 1) = 0. However, for p ≥ 7 we have r4 − 1 6= 0 (i.e. r4 6= 1) because r is a
p p
primitive root of p and hence its order is (p − 1), i.e. r4 6= 1. So, we must have S = 0, i.e. p divides the
sum of the squares of its quadratic non-residues.
Finally, we should add a note similar to the note in the end of part (a), i.e. r and its powers represent
residue classes and hence the proof is general. We should also note that part (a) can also be proved
in a similar way to the proof of part (b), but we preferred (for the sake of diversity) to use a different
approach.
Chapter 16
Sequences and Series
1. Find all the integer terms of the following sequences (where n = 1, 2, 3, . . .):
3n3 −5n2 +11n+7 n4 +2n3 −5n−3 2n5 +3n3 +14n2 +21
(a) an = 2n2 +2n−3 . (b) an = n2 +n+12 . (c) an = 2n2 +3 .
2 Pn k2 +2k−3
(d) an = 13−7n
2n−17 . (e) an = k=1 5 .
Solution:
(a) We have:
3n3 − 5n2 + 11n + 7 1 47n − 10
2
= 3n − 8 +
2n + 2n − 3 2 2n2 + 2n − 3
Now, |47n − 10| ≥ |2n2 + 2n − 3| only for n = 1, 2, . . . , 22. On inspecting these 22 terms we find only
a1 is an integer. Hence, only a1 of this sequence is an integer.
(b) We have:
n4 + 2n3 − 5n − 3 153 − 4n
2
= n2 + n − 13 + 2
n + n + 12 n + n + 12
Now, |153 − 4n| ≥ |n2 + n + 12| only for n = 1, 2, . . . , 9. On inspecting these 9 terms we find none of
these terms is an integer. Hence, this sequence has no integer term.
(c) We have:
2n5 + 3n3 + 14n2 + 21 (2n2 + 3)(n3 + 7)
= = n3 + 7
2n2 + 3 2n2 + 3
Hence, all the terms of this sequence are integers.
(d) We have:
13 − 7n2 1 1971
= −14n − 119 −
2n − 17 4 2n − 17
Now, if an should be an integer then (as a necessary but not sufficient condition) 2n − 17 must divide
1971, i.e. 2n − 17 must be equal to the divisors of 1971 which are 1, 3, 9, 27, 73, 219, 657, 1971 and their
negatives. Considering all these divisors we find that only the following values of n ∈ N make 2n − 17
a divisor of 1971 and an an integer: n = 4, 7, 8, 9, 10, 13, 22, 45, 118, 337, 994. So, only the terms of the
sequence with these values of n are integers.
(e) We have (see Eqs. 15 and 16 of V1):
n
" n ! n
! n
!#
X k 2 + 2k − 3 1 X X X
2
= k + 2 k − 3
5 5
k=1 k=1 k=1 k=1
1 n(n + 1)(2n + 1) n(n + 1)
= +2 − 3n
5 6 2
3
1 2n + 9n2 − 11n 2n3 + 9n2 − 11n
= =
5 6 30
30 5
Now, the solutions of 2n3 + 9n2 − 11n = 0 are n = 0, 1, 2. Hence, the integer terms of this sequence are
an=0,1,2
5 (i.e. a1 , a2 , a5 , a6 , a7 , a10 , a11 , a12 , a15 , a16 , a17 , . . .).
P23
2. Find all s ∈ Z that make the series k=1 (s + k)3 a natural power of 23.
Solution: We have:
23 23 23
! 23
! 23
! 23
!
X X X X X X
3 3 2 2 3 3 2 2 3
(s + k) = s + 3s k + 3sk + k = s + 3s k + 3sk + k
k=1 k=1 k=1 k=1 k=1 k=1
159
16 SEQUENCES AND SERIES 160
23
! 23
! 23
! 23
!
X X X X
= s3 1 + 3s2 k + 3s k2 + k3
k=1 k=1 k=1 k=1
3 2 23(23 + 1) 23(23 + 1)(2 × 23 + 1) 232 (23 + 1)2
= 23s + 3s + 3s +
2 6 4
= 23s3 + 828s2 + 12972s + 76176 = 23(s3 + 36s2 + 564s + 3312)
Now, the series is supposed to be a natural power of 23 and hence:
23(s3 + 36s2 + 564s + 3312) = 23m → s3 + 36s2 + 564s + 3312 = 23m−1 (m ∈ N)
3 2
Now, for m = 1 we have s + 36s + 564s + 3312 = 1 which has no (integer) solution.
For m > 1, (s3 + 36s2 + 564s + 3312) = (s + 12)(s2 + 24s + 276) = 23m−1 and hence we have 3 cases:
• s + 12 = ±1 and 23|(s2 + 24s + 276). However, these conditions are incompatible because s = −13
and s = −11 do no make (s2 + 24s + 276) divisible by 23.
• s2 + 24s + 276 = ±1 and 23|(s + 12). However, s2 + 24s + 276 = ±1 has no (integer) solution.
23 23
• 23|(s + 12) and 23|(s2 + 24s + 276). However, the solution of s + 12 = 0 is s = 11 while the solutions
23 23
of s2 + 24s + 276 = 0 are s = 0, 22 which are incompatible.
P23
So in brief, there is no s ∈ Z that makes the series k=1 (s + k)3 a natural power of 23.
3. Find all the integer terms of the following sequences (where n = 1, 2, 3, . . .):
√ √ √
(a) an = 64n6 + 16n3 + 1. (b) an = 4n2 − 24n + 41. (c) an+1 = an + 2an − 1 (a1 = 1).
Solution:
(a) We have:
p p p
64n6 + 16n3 + 1 = (23 n3 )2 + 2(23 n3 ) + 1 = (8n3 + 1)2 = 8n3 + 1
So, all the terms of this sequence are integers.
(b) We have:
p p p p
4n2 − 24n + 41 = 4n2 − 24n + 36 + 5 = (2n − 6)2 + 5 = N 2 + 5
√
Now, if 4n2 − 24n + 41 is to be an integer then N 2 + 5 must be a perfect square, i.e. N 2 + 5 = m2
(where m ∈ Z), i.e.
m2 − N 2 = 5 → (m − N )(m + N ) = (−1)(−5) = (−5)(−1) = (1)(5) = (5)(1)
On solving these 4 systems of equations we get (respectively): N = −2, 2, 2, −2 and hence n = 2, 4, 4, 2.
So, only a2 and a4 are integers.
(c) We note first that this sequence is strictly increasingp(so its terms are pairwise distinct) and all its
terms are positive. We have a1 = 1 and hence a2 = 1 + 2(1) − 1 = 2. So, the first two terms of this
sequence are integers. Now, we show that it is impossible for the other terms of this sequence to be
integers. For the (n + 1)st term (n ≥ 2) to be an integer we must have an ∈ N and 2an − 1 = m2 (where
m ∈ N), i.e.
m2 + 1 (2x + 1)2 + 1
an = = (x ∈ N0 ) (39)
2 2
where the second equality is justified because m must be odd (since an is supposedly an integer). Now,
the difference d between any two consecutive terms of the sequence according to Eq. 39 should be at
least:
2 2
(2x + 3) + 1 (2x + 1) + 1
d= − = 4x + 4
2 2
However, according to the sequence form (combined with the condition of oddity) the actual difference
between two consecutive terms of the sequence is:
r
√ (2x + 1)2 + 1 p
an+1 − an = 2an − 1 = 2 − 1 = (2x + 1)2 = 2x + 1
2
16 SEQUENCES AND SERIES 161
This difference is much smaller than d and hence these conditions are incompatible which means that
no term (other than a1 and a2 ) can be an integer. So, only a1 and a2 of this sequence are integers.
4. Find all n ∈ N such that:
Pn Pn
(a) k=1 (k 3 + 1) is divisible by 47. (b) k=1 (2k − 1)3 is divisible by 13.
Pn
(c) k=1 (11k − 1) is divisible by 6.
Solution:
(a) We have (see Eq. 17 of V1):
n n
! n
!
X X X n2 (n + 1)2 n4 + 2n3 + n2 + 4n
3 3
(k + 1) = k + 1 = +n=
4 4
k=1 k=1 k=1
So, if the given series is divisible by 47 then (n4 + 2n3 + n2 + 4n) must be divisible by 47 (noting that
47 47
4 and 47 are coprime), i.e. n4 + 2n3 + n2 + 4n = 0. The solution to this congruence equation is n = 0
(see § 8.2). So, the given series isP divisible by 47 iff n = 47m where m ∈ N.
n
(b) From Eq. 20 of V1 we have k=1 (2k − 1)3 = n2 (2n2 − 1). Now, if 13 divides this series then 13
must divide n2 (and hence divide n) or 13 must divide (2n2 − 1). However, 13 does not divide (2n2 − 1)
13
because 2n2 − 1 = 0 has no solution. Therefore, if 13 divides this series then 13 must divide n. So, this
series is divisible by 13 for all n = 13m where m ∈ N.
6
(c) By Euler’s theorem (with the power rule for congruence) we have 112m − 1 = 0 where m ∈ N. This
P2m 6 P2m−1
means that all even terms of the series are 0 (mod 6) and hence k=1 (11k − 1) = k=1 (11k − 1), i.e
the sum of the first 2m terms is the same (mod 6) as the sum of the first 2m − 1 terms. Accordingly:
2
X 1
X
6 6
(11k − 1) = (11k − 1) = 4
k=1 k=1
4
X 3
X
6 6
(11k − 1) = (11k − 1) = 2
k=1 k=1
6
X 5
X
6 6
(11k − 1) = (11k − 1) = 0
k=1 k=1
As the last entry is 0 (mod 6), this cycle repeats itself and hence the given series is divisible by 6 for
all n = 5 + 6s and n =P6(1 + s) where s ∈ N0 .[97]
m
5. Show that the series k=1 n4k is divisible by 4 where nk are odd natural numbers and m is a natural
multiple of 4 (i.e. m = 4, 8, 12, . . .).
Solution: We have (where s ∈ N0 ):
4
n4k = (2s + 1)4 = 16s4 + 32s3 + 24s2 + 8s + 1 = 1
Hence:
m
X m
X
4
n4k = 1 = m
k=1 k=1
Pm
Now, since m is a natural multiple of 4, it is divisible by 4 and hence the series k=1 n4k is divisible by
4.
[97] We note that:
7
X 6 6 6
(11k − 1) = 117 − 1 = 11 − 1 = 4
k=1
6
where step 1 is because 6k=1 (11k − 1) is 0 (mod 6), and step 2 is because 116 = 1 according to Euler’s theorem (with the
P
power rule for congruence). So, this should fully explain our claim that this cycle repeats itself (i.e. every 6 consecutive
integers).
16 SEQUENCES AND SERIES 162
6. Show that the following series cannot be an integer for any value of n ∈ N:
n
X k
(−1)k+1
k+1
k=1
Solution: This series cannot be an integer because for any n ∈ N its magnitude is less than 1 and
n
greater than 0.[98] This is because if we start from the last term in the series i.e. (−1)n+1 n+1 then
it is obviouslyless than 1 and greater than 0 in magnitude. Now, when we add to the last term its
previous term i.e. (−1)n n−1 n which is opposite in sign and smaller in magnitude, the magnitude of the
n
sum becomes less than the magnitude of (−1)n+1 n+1 but greater than 0. Now, if we add the next term
n−1 n−2
i.e. (−1) the magnitude will restore some of its lost value which it lost when we added the
n−1
term (−1)n n−1n but it cannot compensate all the loss and restore its original value (let alone exceeding
it) and hence it remains less than 1 and greater than 0. This applies all over the series as we move
backwards by adding the previous terms successively until we reach the first term. So, the magnitude
of this series keeps oscillating (along its terms) but it remains always less than 1 and greater than 0
and hence the series cannot be an integer for any n ∈ N. The plot of Figure 5 should provide more
clarification and illustration to this argument.
0.8
0.6
0.4
0.2
0
0 5 10 15 20
-0.2
-0.4
Figure 5: The plot of Problem 6 of § 16. The vertical axis represents the sum as a function of n (which
is represented on the horizontal axis).
7. Give examples of natural numbers (greater than 1) which are coprime to all the terms of the following
infinite sequences (where n ∈ N):
(a) an = 3n + 5n + 7n . (b) bn = 17n − 11n + 13n − 1. (c) cn = n3 − 3n2 + 1.
Solution: The idea of this type of problems is simple, that is: we look for a prime number[99] which
p
cannot divide any term of the given sequence, e.g. a prime p such that 3n + 5n + 7n 6= 0 for any n ∈ N.
2
(a) The obvious example is p = 2 because all the terms of this sequence are odd and hence an 6= 0 for
p
any n ∈ N. Other examples are p = 7 and p = 17 because an 6= 0 for any one of these primes and for
any n ∈ N.[100]
p
(b) Two examples are p = 11 and p = 13 because bn 6= 0 for any one of these primes and for any
[98] We note that for small n (e.g. n = 1, 2, 3) the proposition is obviously true. Hence, the focus in the following argument
is on large n where the series consists of many terms.
[99] Choosing “prime number” is just to make the problem easier to solve and avoid unnecessary complications.
[100] For 7 6 17
p = 7 we have an = 1, 6, 5, 6, 1, 2 corresponding to n = 1, 2, 3, 4, 5, 6 while for p = 17 we have an =
16
15, 15, 2, 13, 13, 9, 16, 14, 2, 2, 15, 4, 4, 8, 1, 3 corresponding to n = 1, 2, . . . , 16.
16 SEQUENCES AND SERIES 163
n ∈ N.[101]
p
(c) Some examples are p = 2, 5, 7, 11, 13 because cn 6= 0 for any one of these primes and for any
n ∈ N.[102]
8. Give examples of natural numbers which are coprime to none of the terms of the following infinite
sequences (where n ∈ N):
(a) an = n3 + 5n + 6. (b) bn = n5 + 24n + 15. (c) cn = n9 − n. (d) dn = 7n − 4n .
Solution: The easiest way to solve this type of problems is to look for a small prime p that makes the
p
congruence of the sequence identically zero (mod p), e.g. an = 0 for all n ∈ N. Thus, any n which is a
natural multiple of p will then be coprime to none of the terms of the sequence.
3
(a) an = 0 for all n ∈ N and hence any multiple of 3 is coprime to none of the terms of this sequence.
5
(b) bn = 0 for all n ∈ N and hence any multiple of 5 is coprime to none of the terms of this sequence.
2 3 5
(c) cn = 0, cn = 0 and cn = 0 for all n ∈ N and hence any multiple of 2 or 3 or 5 is coprime to none of
the terms of this sequence.
3 3
(d) dn = 0 for all n ∈ N (noting that 7n − 4n = 1n − 1n = 0) and hence any multiple of 3 is coprime to
none of the terms of this sequence.
9. Derive lower and upper bounds on the following series in terms of n:
Pn k
Pn √
(a) k=1 k+1 . (b) k=1 k.
Solution:
(a) x/(x + 1) is an increasing function and hence:
ˆ k ˆ k+1
x k x
dx < < dx
k−1 x + 1 k + 1 k x + 1
h ik k h ik+1
x − ln(x + 1) < < x − ln(x + 1)
k−1 k+1 k
[101] For 11 10 13
p = 11 we have bn = 7, 6, 3, 2, 8, 2, 3, 6, 7, 1 corresponding to n = 1, 2, . . . , 10 while for p = 13 we have bn =
12
5, 11, 6, 5, 2, 1, 1, 6, 3, 11, 3, 12 corresponding to n = 1, 2, . . . , 12.
[102] The p
congruence equation n3 − 3n2 + 1 = 0 has no solution for p = 2, 5, 7, 11, 13 (see § 8.2).
16 SEQUENCES AND SERIES 164
n n √
! n+1
x3/2 X x3/2
< k <
3/2 0 3/2 1
k=1
3/2 n √
!
n X (n + 1)3/2 − 1
< k <
3/2 3/2
k=1
10
X
4 n 5000
X 1001 2n 4999
X 1001 2n+1 5000
X 1001 2n 4999
X 1001 2n+1
1001
− = − + − = − ≡ A−B
n=0
1000 n=0
1000 n=0
1000 n=0
1000 n=0
1000
Now, A is a geometric series with a = 1 and r = (1001/1000)2 while B is a geometric series with
a = (1001/1000) and r = (1001/1000)2 . Hence (see Eq. 22 in V1):
1 − (1001/1000)10002 1001 1 − (1001/1000)10000
A= ≃ 10974281.17 B= ≃ 10963316.85
1 − (1001/1000)2 1000 1 − (1001/1000)2
So, A − B ≃ 10964.32 and hence the integer part of the given sum is 10964.
(b) We have:
10 4
104 √ √ 104
X 1 X n+1− n X √ √
√ √ = = ( n + 1 − n)
n=0
n+1+ n n=0
n + 1 − n n=0
√ √ √ √ √ √ √ √
= ( 1 − 0) + ( 2 − 1) + · · · + ( 10000 − 9999) + ( 10001 − 10000)
[103] For example: 10 1 − (9/10)n+1 = 5 leads to
log(1/2)
n+1= ≃ 6.58
log(9/10)
and hence the series steps up from the 4 integer level to the 5 integer level at n = 6.
16 SEQUENCES AND SERIES 165
√ √ √
= − 0 + 10001 = 10001 ≃ 100.005
Hence,
√ the integer part of the given sum is 100.
(c) 20 x is an increasing function and hence:
ˆ n √ √
ˆ n+1 √
20 20 20
x dx < n < x dx
n−1 n
n n+1
x21/20 √
20
x21/20
< n <
21/20 n−1 21/20 n
p
If x 6= 0, 1 then we have:
Pp−3 k p Pp−2 p xp−1 −1 p
k=0 x = −1 → k=0 xk = xp−2 − 1 → x−1 = xp−2 − 1 →
p p p
xp−1 − 1 = (x − 1)(xp−2 − 1) → xp−1 − xp−2 − x + 1 = 0 → xp−2 + x = 2
where the steps are justified as in part (a). However, the only solution[104] to the last congruence equa-
p p
tion is x = 1 which is not acceptable (because x 6= 0, 1).
Hence, there is no solution to the given congruence series equation.
p p
(c) If x = 0 then we have a solution (because 1 = 1).
p p
If x = 1 then there is no solution (because p − 2 6= 1).
p
If x 6= 0, 1 then we have:
Pp−3 k p Pp−2 p xp−1 −1 p
k=0 x = 1 → k=0 xk = xp−2 + 1 → x−1 = xp−2 + 1 →
p p p
xp−1 − 1 = (x − 1)(xp−2 + 1) → xp−1 − 1 = xp−1 + x − xp−2 − 1 → xp−2 − x = 0 →
p
x(xp−3 − 1) = 0
p p
So, we must have x = 0 (which is not acceptable because x 6= 0, 1 although this solution was obtained
p p p p
already) or x = 1 (which is not acceptable because x 6= 0, 1) or x = −1, i.e. x = p − 1 (which is
acceptable).
p p
Hence, there are two solutions to the given congruence series
Pk equation: x = 0 and x = p − 1.
2 2
13. Find all m, n, k ∈ N such that (2m − 1) + (2n − 1) = s=1 (2s − 1).
Solution: According to the formula of arithmetic series we have:
k
X k (1 + 2k − 1)
(2s − 1) = = k2
s=1
2
Now, if we remember that no perfect square can be the sum of two odd squares (see Problem 17 of §
4) then we can conclude that there are no m, n, k ∈ N that satisfy the given series equation.
• f −1 is the decoding function which takes c and decrypt it (i.e. convert it to m) with the help of κ.
Accordingly, we have m = f −1 (c, κ) where:
n
f −1 (c, κ) = cρ (41)
• S is the sender of the message who uses the publicly available information (i.e. k and f ) to encode
m and convert it to c.
• R is the receiver of the message who uses the private information (i.e. p and q and hence κ) to decode
c and hence retrieve m.
So, the idea is that any one (i.e. S) can use the publicly available information (i.e. k and f ) to
encode his message and send it to the receiver (i.e. R). However, the receiver is the only one who can
(practically) decode the encrypted message (because he is the only one in possession of the private key).
The security of this method of encryption originates from the fact that those who use this method to
[105] It is worth noting that the level of security of encryption increases with increasing the size of p and q (since this makes
the factorization of n harder).
[106] In reality, the secrecy of the public key should increase the security of encryption and hence it adds another layer of
167
17 CRYPTOGRAPHY 168
communicate (i.e. the sender and receiver of encrypted messages) do not need to share any common
secret since the required secret (i.e. the private key) is held by only one (i.e. the receiver).
Now, we need to substantiate our claim that the decoding function f −1 actually decodes the encrypted
message (i.e. c) and hence it retrieves the original message (i.e. m). This is shown in the following
(which essentially shows why the RSA encryption system should work):
n ρ n ρ
f −1 (c, κ) = cρ = f (m, k) = mr = mrρ (42)
φ
where we refer to Eqs. 40 and 41 (and the surrounding text) for justification. Now, from rρ = 1 we
have:
rρ = 1 + aφ = 1 + a(p − 1)(q − 1)
p q
where a ∈ Z. Moreover, mp−1 = 1 and mq−1 = 1 (from Fermat’s little theorem). Hence:
p
mp−1 = 1
a(q−1) p
mp−1 = 1a(q−1)
a(q−1) p
m × mp−1 = m × 1a(q−1)
p
m1+a(p−1)(q−1) = m
p
mrρ = m
q pq
This similarly applies to q and hence we have: mrρ = m. Therefore, we have:[107] mrρ = m (i.e.
n
mrρ = m) and hence we can add another step to Eq. 42, that is:
n ρ n ρ n
f −1 (c, κ) = cρ = f (m, k) = mr = mrρ = m
This equation shows that by using f −1 we retrieved the original message text m from the cipher text
c through this modular arithmetic manipulation (with the help of the publicly and privately available
information). So, the secrecy of the encrypted message originates from the fact that the decryption of
the coded message depends on the access to the private key which is known only to the receiver R. For
any eavesdropper to decode the encrypted message he needs to know the private key κ which depends
on knowing p and q (noting that κ depends on ρ which depends on p − 1 and q − 1 since ρ depends on
φ which is the product of p − 1 and q − 1). However, knowing p and q by the eavesdropper requires
factorization of n which is practically non-viable in the available time frame because p and q (and hence
n) are very large.
Note: if we reverse the above argument we can make the public key encryption system a digital
signature system. In brief, let a private key owner encode a message m using his private key (with the
decoding function f −1 ) and he makes his message public. Now, anyone in the public can decrypt the
encoded message using the public key (with the encoding function f ) through the following process:
f f −1 (m, κ), k
So, whoever receives the encrypted message will know that the message comes from the owner of the
private key (i.e. it is a signed message). The justification is as follows:
n r n r n
f (c, k) = cr = f −1 (m, κ) = mρ = mrρ = m
• n = pq = 3293.
• φ = (p − 1)(q − 1) = 36 × 88 = 3168.
• r = 17 (noting that 17 is coprime to 3168 and 1 < 17 < 3168).
• ρ = 17∗ (mod 3168) = 2609.
• k = (3293, 17).
• κ = (3293, 2609).
• f (m, k) is the mapping: m → c ≡ m17 (mod 3293).
• f −1 (c, κ) is the mapping: c → m ≡ c2609 (mod 3293).
So, if S encrypts the message m = 13 by using f (m, k) then he gets: c = 1317 (mod 3293) = 2607.
Accordingly, when R receives c then by using f −1 (c, κ) he gets: m = 26072609 (mod 3293) = 13 which
is the original message.
3. Create and use an RSA encryption system to encode and decode the following message using ASCII
code for conversion between text and numbers: “I WILL COME TO YOUR HOUSE TONIGHT.”.
Solution: The numeric ASCII code for the message is (where each two digits represent a single char-
acter; please refer to the ASCII code table which is available on the Internet):
73328773767632677977693284793289798582327279858369328479787371728446 (43)
79400185343444370351627151552080274173336087045262715155465028297743
The receiver R then decodes this numeric message as 4-digit blocks of integers where in the following
list m(c) represents c2087 (mod 9797), that is:
m(7940) = 7332 m(0185) = 8773 m(3434) = 7676 m(4437) = 3267 m(0351) = 7977
m(6271) = 6932 m(5155) = 8479 m(2080) = 3289 m(2741) = 7985 m(7333) = 8232
m(6087) = 7279 m(0452) = 8583 m(6271) = 6932 m(5155) = 8479 m(4650) = 7873
m(2829) = 7172 m(7743) = 8446
So, R retrieves the original message in numeric format (i.e. what is in Eq. 43). He then uses ASCII
code table to convert this numeric message to a text message and hence he obtains the original message
text (i.e. I WILL COME TO YOUR HOUSE TONIGHT.).
4. Give a simple example of a digital signature system.
Solution: Let us use the encryption system of Problem 3 where R (after receiving the message “I WILL
17 CRYPTOGRAPHY 170
COME . . .”) wants to send a signed confirmation message so that anyone receives the confirmation mes-
sage (notably S) will know for sure that the confirmation message comes from R not from an intruder
or an impersonator. The confirmation message is: “I AM WAITING”. Accordingly:
• The numeric ASCII code for the confirmation
message is 733265773287657384737871.
• On applying the mapping f −1 (m, κ) i.e. m → c ≡ m2087 (mod 9797) where in the following list
2087
c(m) represents m (mod 9797) to the ASCII confirmation message (in blocks of 4 digits) R gets:
c(7332) = 6319 c(6577) = 6929 c(3287) = 1411
c(6573) = 2194 c(8473) = 7036 c(7871) = 7509
Hence, R will send the following encrypted message: 631969291411219470367509.
• When S receives this encrypted message he applies the mapping
f (c, k) i.e. c → m ≡ c23 (mod 9797)
where in the following list m(c) represents c23 (mod 9797) to the encrypted message (in blocks of 4
digits) and hence S gets:
m(6319) = 7332 m(6929) = 6577 m(1411) = 3287
m(2194) = 6573 m(7036) = 8473 m(7509) = 7871
i.e. 733265773287657384737871 which is the original confirmation message in ASCII code (i.e. “I AM
WAITING” in text). So, S knows for sure that this message comes from R, i.e. the confirmation
message is a signed message (where the encryption represents the signature since R is the only one who
holds the private key and hence R is the only one who can encrypt the message in this way).
Chapter 18
Number Theory and Computing
Computing is an essential tool in modern number theory. Many problems in number theory cannot be
solved without employing computational tools and methods. In fact, in many cases computing is needed
(or at least it is useful to use) even to tackle those number theory problems which are essentially of
analytical type and hence they can be solved in a purely analytical way. Accordingly, developing basic
computational knowledge and skills is a requirement for any modern number theorist.
Some number theorists may argue that we can use ready-made software packages and libraries to do
our computational business and hence we do not need to learn computing or develop computational skills.
However, this is not always true because there are always problems that cannot be tackled and solved by
ready-made software packages and libraries (assuming they are available and user friendly and etc.).[108]
Moreover, even if this is true, doing computing in number theory problems gives an insight that can be
gained neither by analytical treatment and methodology nor by using ready-made software packages and
libraries. So, practicing computing (in some shape and form) is beneficial (if not a necessity) in number
theory even to enforce the analytical knowledge and skills (let alone its obvious benefit or necessity in
certain aspects such as doing tests and checks). We should also emphasize on the special importance or
necessity of computing in research.
It is useful to take note of the following remarks about this chapter and its content:
• The purpose of this chapter is to develop some very basic skills in dealing with number theory problems
computationally. Most of the problems in this chapter that we tackle computationally are simple and
hence they do not need more than simple algorithmic ideas and simple codes. We intend to build in the
future volumes of this book on the simple ideas and techniques that we present in this chapter (and hence
extending them in depth and breadth).
• This chapter is deliberately made very short because the idea of it is to give a small sample of number
theory problems that can be tackled and solved computationally (alongside the computational codes
and solutions of these problems). In fact, many other problems in this book can be tackled and solved
computationally in a manner similar to the manner of the problems of this chapter. We encourage the
reader (who is keen to learn how to use computing in number theory) to search for similar problems (in
this book as well as outside this book) and tackle them computationally by simple algorithmic ideas and
codes (similar or different to the ideas and codes that we present in this chapter).
• All the codes that we refer to in this chapter (and in this book) are in C++ and they are available on
the Internet.[109]
• We intentionally kept the codes very basic to avoid distraction and additional computational cost (noting
that the purpose of these codes is just to outline the way of implementing the basic ideas of the algorithms
behind them).
• Artificial Intelligence (which we discussed briefly in the first volume of this book) is a specially important
171
18.1 Simple Tools 172
computational tool that can have an impact in the future not only on the number theory problems of
computational nature but even on the analytical investigation of some number theory problems. In fact,
we expect this tool to dominate the research in certain areas of number theory in the near future. Hence,
it is important for the next generation of mathematicians to develop their knowledge and skills in this
regard. However, due to its rather complicated nature and the requirement of considerable space we do
not discuss artificial intelligence in this volume although we hope to do some investigation about it in the
future volumes.
[110] The Eq1Cycle.cpp and Eq2Cycle.cpp codes in the Codes\CongSys1\Cycle folder should help in identifying these periods.
18.3 Congruence Equations and Systems 173
[111] Wehave 115 solutions for the first equation and 10 solutions for the second equation and hence we have 1150 combina-
tions.
Index
Absolute value, 4, 43, 96, 143 Divisibility, 28, 29, 34, 149, 152, 157
Abundant number, 125, 126 check (test), 57, 93
Algebra, 85 Divisor function, 5, 38, 125, 128
Algebraic manipulation, 11, 55, 86
Alternating sum, 103 Eavesdropper, 168
Arithmetic Elementary number theory, 1, 130
function, 24, 128 Elimination (for solving systems of equations), 86
mean, 100 Encoded message, 168
series, 23, 28, 35, 166 Encoding, 167, 168
Artificial intelligence, 172 function, 167, 168
ASCII (alphanumeric code), 169, 170 method, 167
Encrypted message, 167, 168, 170
Bezout theorem, 46, 140, 141 Encryption, 167, 170
Binomial exponent, 167
coefficient, 4, 42 method, 167
theorem, 34, 35, 145 system, 167–169
Bounding inequalities, 95 Euclid formula, 64
Euler
C++ (language, codes), 1, 171 criterion, 27–30, 101
Calculus, 96, 100 function, 5
Ceiling, 4, 135 theorem, 14, 16, 17, 22, 131, 153, 154, 161
Chinese remainder theorem, 36, 54, 112–117, 119, 121, 123, Even perfect number, 5
130, 132, 153, 156, 157, 168, 171–173 Exponential
Cipher text, 167, 168 congruence equation, 102, 106, 108, 110, 113, 115, 117,
Coding, 94–96, 171 121
Combination (of sets), 4 Diophantine equation, 69
Combinatorics argument, 40
Comparison (for solving systems of equations), 85, 86 Factorial, 4, 29, 41, 82, 95–98, 109, 147, 172
Complete residue system, 5, 104 Factorial power, 4
Completely multiplicative function, 24, 128 Fermat
Complex number, 4 last theorem, 58, 61, 94, 133
Composite number, 22, 35, 43–49, 56, 125–127, 143 little theorem, 16, 19, 23, 28, 48, 104, 107, 131, 132,
Composity check (test), 56, 93 151, 154, 155, 158, 165, 168
Computer code, 1, 41, 103, 137 number, 4, 48
Computing, 1, 103, 171 Floor, 4, 135
Conditional statement, 37 Fraction part, 6–8
Congruence equation, 101–104
Conjecture, 48, 49, 127 GCD, 140–144
Continued fraction, 4, 6–8, 11, 12, 58 Generating function, 40
ladder, 7, 11, 12, 58 Geometric
symbol, 4 mean, 100
technique, 11 series, 164, 165
Contradiction, 13, 17, 18, 48, 49, 51, 59, 64, 73, 81, 104, 132, Goldbach conjecture, 49
140 Graph, 88, 91, 92, 94, 96
Contraposition, 32, 34, 43, 126, 132 Greatest common divisor, 4, 140, 141
Converse (of conditional statement), 22, 32, 34, 85 Group, 13, 16
Coprimality, 20, 22, 32, 33, 48, 115, 123 theory, 13
Coprime, 44, 46, 49
Cryptography, 1, 167 Index of integer, 4, 19, 106, 156, 172
Induction, 97, 98
Decoding, 167, 168 Inequality, 52, 53, 90, 95–100, 135–137, 139
function, 167, 168 Integer number, 4, 5
method, 167 Integer part, 6, 7, 164, 165
Decryption, 167, 168 Internet, 169, 171
exponent, 167 Irrational number, 7, 76, 81
Digital signature system, 168, 169
Diophantine equation, 55–57 Jacobi symbol, 4, 27, 31–34, 36, 103
Discriminant (of quadratic polynomial), 5, 13, 46, 60, 67,
102, 106 Lagrange polynomial roots theorem, 20, 104, 132
Dividend, 28, 29 Last digit, 49, 58, 145, 147, 148
174
LCE theorem, 23, 102, 104 Pell equation, 10–13, 57, 58, 95
LCM, 140–144 Perfect number, 5, 43, 125–127
Least common multiple, 4, 105 Permutation, 5, 42, 67, 99, 152
Legendre symbol, 4, 23–28, 30–34, 103, 106, 107 phi function, 5
Lehmer totient Polynomial
conjecture, 127 congruence equation, 105, 109, 113–115, 120, 132
problem, 127 Diophantine equation, 56, 57, 69
Linear Polynomial-exponential congruence equation, 113, 116, 118,
algebra, 85, 86 122, 172
combination, 142 Polynomial-exponential Diophantine equation, 73
congruence equation, 102, 112, 114, 116–122, 130, 171, Power rule (for congruence), 101, 154, 161
172 Primality, 44
Logarithms, 19, 41 check (test), 56, 93
Prime
Magnitude check (test), 56, 86 factorization, 35, 41, 56, 101, 127, 133, 152, 155, 157
Mersenne number, 5, 44–46
number, 48, 49 Primitive
prime, 4, 48, 49 Pythagorean triple, 64, 67
Message text, 167–169 root, 4, 15–20, 22, 30, 102, 104, 108, 156, 158
Minimal solution, 10 Private key, 167, 168, 170
Mobius Programming, 96
function, 5, 37, 128, 129 Proof by example, 34
inversion, 37 Public
inversion formula, 38 key, 167, 168
Modular key cryptography, 167
arithmetic, 23, 25, 57, 94, 101–103, 112, 147, 167, 168, key encryption system, 167, 168
172 Pythagorean triple, 62, 64, 67, 69, 95
multiplication, 16
multiplicative inverse, 4, 15, 17–19, 27, 167 Quadratic
multiplicative inversion, 15 congruence equation, 27, 36, 103, 106, 132
Modularity, 26, 31 congruence theorem, 23, 28
check (test), 57, 86 non-residue, 20–23
inconsistency, 86 reciprocity, 30–32
inspection, 57 residue, 20–23
Modulo, 4
Modulus, 4 Random number, 103, 172
Multinomial coefficient, 4, 42 Rational
Multiplicative fraction, 6–12, 58
function, 24, 128 fraction approximation, 7–12, 58
group, 13 number, 5, 7, 8, 76, 81, 153
order, 13 Real number, 5, 6, 135, 139
Multiplicativity, 125 Receiver (of message), 167–169
Multivariate Reduced residue system, 5, 15–17
equation (or system of equations), 85, 90, 109, 116, 123 Relatively prime, 15, 124
inequality, 96, 99 Remainder, 153–156
Residue class, 24, 104, 109, 112, 149, 158
Natural number, 4 Restricted divisor function, 5
Negation, 4 RSA (public key encryption system), 167–169
Non-linear congruence equation, 115, 116 Rules of
Non-primitive Pythagorean triple, 67 cardinality of sets, 125
Number theory, 1, 6, 40, 55, 85, 96, 105, 130, 167, 171, 172 gcd, 49, 141, 142
Numeric libraries, 171 indices, 19
Legendre symbol, 25
Open problem, 127 logarithms, 19, 41
Order of integer, 5, 13
Ordinary Security of encryption, 167
arithmetic, 110, 111 Sender (of message), 167–169
equation, 94, 102 Sensibility checks, 56, 86, 87, 93
Sequence, 40, 103, 159–163, 172
Pairwise Series, 23, 28, 35, 40, 136, 138, 153, 154, 159–166
coprimality, 115 Sign
coprime, 151 bounds, 95
Parity, 35, 39, 55–57, 62, 64, 70–74, 86, 87, 89, 105, 134 check (test), 56, 86, 93
check (test), 56, 57, 86, 93 table, 39, 96
violation, 55, 62, 70–74, 86, 87, 89 Signature, 170
175
Signed message, 168, 170
Software packages, 94, 95, 171
Solvability, 31, 57, 85, 102, 103, 112, 118
Spreadsheet, 11, 41, 94–96, 103, 116, 137
Square free, 38, 44, 128
Substitution (for solving systems of equations), 85, 86
Summatory function, 37, 38, 128, 129
Symmetric, 15, 62
Symmetry, 15, 43, 51–53, 61, 67, 78, 81, 94, 99, 137, 152
System of
congruence equations, 105, 112, 114, 153, 154, 156, 157
Diophantine equations, 85–87, 89, 91, 94
equations, 86
inequalities, 135
linear congruence equations, 112, 114, 117–122, 130,
132, 172
polynomial-exponential congruence equations, 113, 116,
118, 122, 172
Univariate
equation (or system of equations), 39, 104, 112, 113,
123
inequality, 97
176