Number Theory KSOU Textbook
Number Theory KSOU Textbook
Course-MMDSE 3.4
Number Theory
M.Sc. MATHEMATICS (CBCS)
THIRD SEMESTER
COURSE EDITOR
The Registrar
Karnataka State Open University
Mukthagangothri, Mysuru-570006
Unit-5 Multiplicative Function τ And σ, M𝑜̈ bius Function And M𝑜̈ bius Inversion 51-61
Formula
Unit-6 The Greatest Integer Function, Euler’s Phi Function And Its Properties 62-69
Unit-13 Sum Of Two Squares & Sums Of More Than Two Squares 139-150
Unit-16 Infinite Continued Fraction, Periodic Continued Fraction And Pell’s Equation 166-184
BLOCK – I
0
UNIT – 1
THE FUNDAMENTAL THEOREM OF ARITHMETIC, EUCLID’S THEOREM
Structure:
1.0. Objective
1.1. Introduction
1.2. The Division Algorithm
1.3. The Greatest Common Divisor
1.4. The Least Common Multiple
1.5. The Linear Diophantine Equations
1.6. Summary
1.7. Keywords
1.8. Exercises
1.9. References
1.0. Objective:
This chapter discusses some of the basic properties of the integers, including the notions of
divisibility and primality, unique factorization into primes, greatest common divisors, and least
common multiples.
1.1. Introduction:
In this section we describe some preliminary tools we need before embarking into the core of
Number Theory.
1. Well Ordering Principle: Every non-empty set S of non-negative integers contains a
least element i.e, there exists an integer m such that m ≤ n .
2. Archimedean Property: If a and b are any two positive integers, then a positive
integer n such that na ≥ b.
3. First Principal of Mathematical Induction.
Let S be a set of positive integer satisfying the following properties:
(1) 1 S
(2) Whenever .
Then S is the set of all positive integers.
1
n n 1 2n 1
Example 1: We prove P(n) : 12 22 n2 (1)by mathematical
6
induction.
1 2 3
Proof: Suppose n = 1. Then LHS = 12=1 and RHS = 1.
6
Therefore LHS = RHS. So P(1) is true.
k k 1 2k 1
Suppose P(n) is true for n = k i.e, 12 22 k 2 (2)
6
Now we prove P(n) is true for n = k + 1.
Add (k + 1)2 to both sides of (2). Then
k (k 1)(2k 1)
12 22 k 2 (k 1) 2 (k 1) 2
6
(k 1)(2k 7k 6) (k 1)(k 2)(2k 3)
2
6 6
which is exactly the right hand side of (1) for n = k + 1. Hence P(n) is true for all positive
integers n.
4. Second Principal of finite induction :
Let S be a set of positive integer satisfying the following properties:
(1) S
(2) if k is a positive integer such that 1, 2, 3, …, .
Then S is the set of all positive integers.
Example 2: Consider the Lucas sequence: 1, 3, 4, 7, 11, 18, 29, 47, 76, …
Sequence is defined by the following relation:
a1 = 1
a2 = 3
an = an–1 + an–2 for all n ≥ 3.
Our proposition is an < (7 / 4)n holds for every positive integer n.
For n = 1 and 2, we have a1 = 1 < (7 / 4)n = 7 / 4 and a2 = 3 < (7/ 4)2 = 49 / 16 and hence the
inequality holds in these two cases. For the induction step, choose an integer k ≥ 3 and assume
that the inequality is valid for n = 1, 2, …, k – 1. Then, ak–1 < (7 / 4)k–1 and ak–2 < (7 / 4)k–2 .
By the way in which the Lucas sequence is formed, it follows that
7 / 4 7 / 4
k –1 k –2
ak ak –1 ak –2
= 7 / 4 7 / 4 1 7 / 4 11/ 4 7 / 4 7 / 4 7 / 4
k –2 k –2 k –2 2 k
.
2
Because the inequality is true for n = k whenever it is true for the integers 1, 2, …, k – 1, we
conclude by the second induction principal that an < (7 / 4)n for all n ≥ 1.
5. The Binomial Theorem
Let n be a positive integer and r another positive integer such that 0 ≤ r ≤ n. Then,
Binomial coefficients are denoted by nCr . We state some of the results connected with Binomial
coefficients.
b) Newton’s Identity: ( ) ( ) ( )( )
3
Corollary 1: If a and b are integers with b ≠ 0, then unique integers q and r such that
a = bq + r, 0 ≤ r < |b|.
Proof: We consider the case when b is negative. Clearly |b| > 0. Hence by Theorem (1)
unique integers q and r such that a = q'|b| + r, 0 ≤ r < |b|. Take q = -q' then a = bq + r, 0 ≤ r < |b|.
Definition 1: An integer n is called even if n = 2k and it is called odd if n = 2k + 1 for some
integer k.
Example 3: We prove square of any integer is of the form 4k or 4k + 1.
Proof: Any integer n is of the form 2m or 2m+1 by division algorithm. Hence square of n is
either 4m2 or 4m(m+1) + 1 which implies n is either of the form 4k or 4k+1.
Example 4: We prove that square of any integer is of the form 3k or 3k+1.
Proof: Let a be any integer. When a is divided by 3 it leaves the remainder 0, 1, or 2. a is of
the form 3q, 3q+1 or 3q+2. So, let a = 3q. Then a2 = 9q2 = 3·3q2 = 3k.
When a = 3q+1, then a2 = 9q2 + 6q+1= 3(3q2 +2)+1= 3k+1.
When a = 3q+2, then a2 = 9q2 + 12q+4= 3·(3q2 +4q+1)+1= 3k+1.
Hence a2 is of the form 3k or 3k+1.
Example 5: We show that n(n+1)(2n+1) / 6 is an integer for n ≥ 1.
Proof: When n is divided by 6 it leaves the remainder 0, 1, 2, 3, 4, or 5 by division algorithm.
Any integer n can be written in the form 6k, 6k+1, 6k+2, 6k+3, 6k+4 or 6k+5. So, when n = 6k,
n(n+1)(2n+1) is divisible by 6. When n = 6k+1, then
n(n+1)(2n+1) = (6k+1)(6k+2)(12k+3) = 6(6k+1)(3k+1)(4k+1)
which when divided by 6 gives an integer. Similarly we can prove the result in other cases.
Definition 2 (Divisibility): An integer b is said to be divisible by an integer a ≠ 0 if there exists
an integer c such that b = ac and we write it as a | b (a divides b). If b is not divisible by a then
we write it as a | b (a does not divides b).
(a) a | 0, 1 | a, a | a
(b) a | 1 if and only if a = ± 1
(c) if a | b and c | d then ac | bd
(d) if a | b and b | c then a | c
(e) a | b and b | a if and only if a = ±b
(f) if a | b and b ≠ 0 then |a| ≤ |b|
(g) if a | b and a | c then a | bx+cy for arbitrary integers x and y.
4
Proof: Proofs of (a) and (b) are very easy.
Let us prove (c). a | b ⇒ b = k1a and c | d ⇒ d = k2c, k1, k2 .
Multiplying these two, we obtain bd = (k1 k2)ac ⇒ ac | bd.
Proof of (d) : a | b ⇒ b = k1a and b | c ⇒ c = k2b, k1, k2 . Substituting for b in c = k2b, we
obtain c = k2 (k1a) i.e, c = (k1 k2)a ⇒ a | c.
Proof of (e) : a | b ⇒ b = k1a and b | a ⇒ a = k2b, k1, k2 . Hence a = (k1 k2)a ⇒ k1 k2 = ±1.
( ) |( )
Similarly we can show that a | bx-cy.
Property (g) of Theorem 2 can be extended by induction to sums of more than two terms. That is
if a | bk for k = 1, 2, 3, |
5
( ) ( ) ( )
If r were positive, then this representation would imply contradicting the fact that d
is the least integer in S. Therefore ⇒ ⇒ | Similarly we can prove that d | b.
Hence d is a common divisor of a and b.
Now if c is a positive integer such that c | a and c | b then c | ax + by Hence
| ( ) | | | | ⇒ Hence gcd(a, b) = d.
Corollary 2: If a and b are given integers, not both zero then the set
{ | }
is precisely the set of all multiples of d = gcd(a, b).
Proof: Since | | | Thus every element of T is a multiple of d.
Conversely since d is expressed as , any multiple nd of d is of the form
( ) ( ).
Hence nd is an element of T.
Definition 4: Two integers a and b, not both of which are zero are said to be relatively prime if
gcd(a, b) = 1.
Theorem 4: Let a and b be integers, not both zero. Then a and b are relatively prime if and
only if there exists integers x and y such that ax + by = 1.
Proof: Suppose gcd(a, b) = 1. Then by Theorem 3 there exists integers x and y such that 1=
ax + by.
Conversely suppose ax + by = 1 and let gcd(a, b) = d. Then | | ⇒ |
| . Since d is positive d = 1. This completes the proof.
Corollary 3: If ( ) ( ) .
Proof: Since gcd(a, b) = d, there exists integers x and y such that Dividing both
( ) ( ) Since d | a and d | b,
( ) .
6
Theorem 5 (Euclid’s Lemma): If | ( ) | .
Proof: | ( ) there exist
integers .
Since , we have ( ) ⇒ | .
Corollary 5: ( ) ( ) ( ) .
Proof: ( ) . Similarly (a, c) = 1, implies
there exists integers . Multiplying these two, we obtain
( )( )
i.e, ( ) ( ) .
This implies (a, bc) = 1.
The Euclidean Algorithm: There are several methods for finding gcd of two positive integers.
Among these Euclidean algorithm is the efficient algorithm. In fact, it is one of the fastest
algorithm to find gcd of two positive integers and most simple one.
First let us prove the following theorem.
Theorem 6: Let a and b be any two positive integers and r is the remainder when a is divided
by b. Then gcd(a, b) = gcd(b, r).
Proof : Let gcd(a, b) = d. Divide a by b. Then there exists unique integer q and r such that a =
bq + r, 0 ≤ r < b. Since | | | ⇒ | d is a common divisor of b and r.
Suppose c is a common divisor of b and r, then | ⇒ | . Hence c is a common
divisor of a and b. Since d is the gcd of a and b, by definition c ≤ d. Hence gcd(b, r) = d.
Now, we explain Euclid’s Algorithm. Let a and b be any two positive integers with a >
b. [If a = b then gcd(a, b) = a]. Then applying division algorithm repeatedly we have the
following sequence of equations:
,
,
,
7
By Theorem 6 we have,
( ) ( ) ( ) ( ) , the last two non-zero remainders.
Theorem 1.2.3 asserts that gcd(a, b) can be expressed in the form ax + by, but proof of
the theorem gives no hint as to how to find x and y. For this we use Euclidean Algorithm.
Starting with equation
We write .
Now solve preceding equation in the algorithm for and substitute to obtain
( )
( ) ( ) .
This represents as linear combination of and . . Continuing backward through
system of equations, we successively eliminate the remainders until a stage
is reached where ( ) is expressed as a linear combination of a and b.
Example 7: Let us find gcd of 256 and 1166.
Proof: Since
and
.
To represent 2 as a linear combination of 256 and 1166, consider
( )
( )
( ) ( )
( )
( )( )
( ).
.
Theorem 7: If k > 0 then gcd(ka, kb) = k·gcd(a, b).
Proof: Multiply each of the equations in Euclidean Algorithm by k.
Corollary 6: For any integer k ≠ 0, gcd(ka, kb) = |k| gcd(a, b).
8
1.4. Least Common Multiple
Definition 5: Let a and b be any two integers. Then least common multiple of a and b denoted
by lcm(a, b) is the positive integer c satisfying the following :
(a) a | m and b | m
(b) if a | c and b | c then m ≤ c.
Example 8: Consider a = 12 and b = 30. Then common multiples of a and b are 60, 120, 180,
240, ···. Among these 60 is the least. Therefore lcm(12, 30) = 60.
Theorem 7: For positive integers a and b
lcm(a, b) × gcd(a, b) = a·b.
Proof: Let d = gcd(a,b). Then we can find integers r and s such that .
Then m = as = rs. Hence m is a common multiple of a and b. Let c be any positive integer that is a
common multiple of a and b i.e, there exists integers u and v such that c = au = bv. Since d =
gcd(a, b) there exists integers x and y such that d = ax + by. Hence
( )
⇒ | ⇒ ( ) .
( ) ( )
1.5. Linear Diophantine Equation
Definition 6: An equation of the form ax + by = c, where a, b, c are integers and a, b
are not both zero is called linear Diophantine equation in two unknown.
A solution of this equation is a pair of integers that satisfy the above equation.
Theorem 8: The linear Diophantine equation ax + by = c has a solution if and only if d | c where
d = gcd(a, b). If ( ) is any particular solution, then all other solutions are given by
( ) ( )
9
This implies | ( ). Since gcd(r, s) = 1, by Euclid’s lemma, we have |( )
⇒ where t is an integer.
( )
Since ( ) ( ) we have ( ) ( ) ( )
or ( ) .
[ ( ) ] [ ( ) ]
( ) [ ]
where t is an integer.
Definition 7: An integer p > 1 is called a prime number if the only divisors of p are ±1 and ±p.
If p is not a prime then it is called composite.
For example 2, 3, 5, 7, 11, · · · are primes whereas 4, 6, 8, 9, 10, · · · are composite numbers.
Note that 2 is the only even prime.
10
Corollary 7: If p is prime and | | for some k, where 1 ≤ k ≤ n.
Proof: The proof is by induction on n. When n = 1, the stated conclusion obviously holds;
whereas when n = 2 the result true by Theorem 9. Suppose n > 2 and assume whenever p divides
a product of less than n factors, it divides at least one of the factors that if
| | for some k, 1 ≤ k ≤ n – 1.
Now suppose |( ) . Then, by Theorem 9, either | or
| . If | then the proof is complete. Otherwise, by induction hypothesis | for some k,
1 ≤ k ≤ n – 1. In any case, p divides one of the integers a1, a2, …, an.
Theorem 10: (Fundamental Theorem of Arithmetic): Every integer n > 1 can be expressed as
a product of primes in a unique way apart from the order of the prime factors.
Proof: We prove it by induction. Clearly the theorem is true for n = 2 (as 2 is prime). Suppose
that every integer less than n can be written as a product of primes. Now, we show that n can be
expressed as product of primes.
If n is prime, then there is nothing to prove. If not, there exists integers a and b such that
n = ab and 1 < a, b < n. By our induction hypothesis, a and b can be expressed as product of
primes and hence n can also be expressed as product of primes and that completes the first part.
p2 p3 pr = q2 q3 qs.
p3 p4 p5 pr = q3 q4 q5 qs.
11
If this process is continued and if r < s, then we would eventually arrive at
1 = qr+1 qr+2 qs
which is absurd, because each qj > 1. Hence r = s and p1 = q1, p2 = q2, … pr = qr making the two
fractorizations of n identical. The proof is now complete.
Corollary 9: Any positive integer n > 1 can be written uniquely in a canonical form
where, each ki is a positive integer and each pi is a prime, with p1 < p2 < < pr.
Proof: If √2 = a / b where a and b are integers with gcd(a, b) = 1. Then there exists integers r
and s satisfying ar + bs = 1. As a result,
1.9. References
1. Elementary Number Theory, David M. Burton, McGraw Hill Publication
2. Elementary Number Theory with Applications, Thomas Koshy, Elsevier
3. Basic Number Theory, S. B. Malik, Vikas Publications
4. Elementary Number Theory and its Applications, Kenneth H. Rosen, Addison Wesley
13
UNIT – 2
PRIME NUMBER THEOREM AND GOLDBACH CONJECTURE
Structure:
2.0. Objective
2.2. Trial Division
2.3. Sieve of Eratosthenes
2.4. Goldbach Conjecture
2.5. Prime Number Theorem
2.6. Summary
2.7. Keywords
2.8. Exercises
2.9. References
2.0. Objective
This chapter concerns itself with the question: how many primes are there? In this chapter we
prove that there are infinitely many primes; however, we are interested in a more quantitative
answer to this question; that is, we want to know how “dense” the prime numbers are and also
how they are distributed among integers.
Since an even integer is always divisible by 2, a prime number is always odd except 2. So, given
large odd integer, how can we determine whether n is prime or composite. The obvious
approach is dividing n by all primes less than n. If n is not divisible by any of them, then n must
be prime. Otherwise n is composite. This method is called Trial division. This method not
only determines whether n is prime or not, it also gives a non-trivial divisor of n, if n is
composite. But the following theorem show that there always exists a prime divisor p of n which
is less than or equal to √ if n is composite. This implies, to find whether n is prime or
composite, it is enough to divide n by all primes less than or equal to √ .
Theorem 1: Let n > 1 be a composite integer, then there exists a prime p such that p | n and p ≤
√ .
14
Proof: If n is composite then n = a·b for some integers a and b with 2 ≤ a,b < n and a ≤ b.
Since n = a·b ≥ a2, a ≤ √ . Now, by FTA, either a is a prime or has a prime divisor p. p|a⇒
p | n and p ≤ √ .
For example, take n = 271. Then 16 < √ 7 < 17 and 2, 3, 5, 7, 11 and 13 all do not
divide 271. Hence 271 is a prime number.
Even though the method looks very simple, it is not useful in practice. For example, if a
positive integer is less than a million is given, we can find all factors fairly quickly. If an integer
of the order of say 50 digits is given, then using best computers that exists today, finding a factor
would be impractical.
Suppose we want to list all primes p ≤ n, where n is an integer > 1. We know that if n is
composite then it is divisible by a prime p < √ . First, list all integers from 1 to n. Underline 2
and strike out all multiples of 2. The first of the remaining integers is 3. Underline 3 and strike
out all multiples of 3. The smallest integer after 3 that is left out is 5. Continuing this procedure,
suppose we have struck off all multiples of a prime p, the next integer left in the list is prime next
to p, say q. We continue repeating the process till q > √ and then quit. The remaining unstruck
integers are primes. For example, we list all primes ≤ 50.
1 2 3 4 5 6 7 8 9 10
11 12 13 14 15 16 17 18 19 20
21 22 23 24 25 26 27 28 29 30
31 32 33 34 35 36 37 38 39 40
41 42 43 44 45 46 47 48 49 50
Now the question arises. Are there infinitely many primes? Answer is yes and it was
proved by Euclid in his book ‘Elements’.
Proof: The proof is by contradiction. Suppose, there are only finitely many primes say
. Let . If P is prime then there is nothing to prove. If P is
composite the P has a non-trivial divisor, say .
15
Now, the next question is ‘Is there a simple formula for the nth prime pn, like 2n that
produces all even integers. Answer is no. Also given a large odd integer, it is difficult to find
whether the number is prime or composite. But, more difficult is finding the factors, if the
number is composite. More over their distribution with in the positive integers is most
mystifying and irregular. Sometimes they are very close together like 3 & 5, 11 & 13, 17 & 19
or 1000000000061 & 1000000000063 and at the same time there exists arbitrarily large gaps
between consecutive primes that is given any positive integer n, there exists n consecutive
integers, all of which are composite. To prove this, consider the integers, (n+1)!+2, (n+1)!+3,
···, (n+1)!+(n+1) where n! = n·(n – 1) ··· 3·2·1. Clearly each integer is composite: (n+1)!+2 is
divisible by 2, (n+1)!+3 is divisible by 3 and so on.
Another famous unsolved problem is “Goldbach conjecture”. It states that every even
integer is the sum of two numbers that are either primes or 1.
In the year 1742, Goldbach wrote a letter to Leonard Euler about his conjecture. In reply
Euler wrote to Goldbach another conjecture which states
“Any even integers (≥ 6) of the form 4n+2 is a sum of two numbers each being either a
prime of the form 4n+1 or 1.
All attempts to obtain a proof of Goldbach conjecture have been completely unsuccessful
so far. The first real progress on the conjecture is nearly 200 years was made by Hardy & Little
wood in 1922. On the basis of a certain unproved hypothesis, the so called generalized Riemann
hypothesis, they showed that every significantly large odd number is the sum of three odd
primes. In 1937, Russian mathematician Vinogradov showed that if A(x) is the number of even
integers n ≤ x that are not sum of two primes, then
( )
This shows that almost all even integers satisfy the conjecture.
Now, by division algorithm any integer can be written in the form 4n, 4n+1, 4n+2 or 4n+3.
Therefore all odd integers are of the form either 4n+1 or 4n+3.
16
Since all primes are odd, the primes must be of the form either 4n+1 or 4n+3. Let us
write down some of the primes of the form 4n+1 and 4n+3.
4n+3 : 3 7 11 19 23 31 43 47 59 67 71 79 83
4n+1 : 5 13 17 29 37 41 53 61 73 89 97.
Let us denote ( ) as the function which counts the number of primes of the form p = an+b
not exceeding x. Then
( ) ( )
⇒ ( ) ( )
In 1914, J.E. Littlewood showed that the inequality fails infinitely often. For x = 26,861,
( ) ( )
Number theorists often dream of finding formulas that generate primes for consecutive values of
the integral variable n. Euler found one such formula in 1772; E(n) = n2 – n + 41 yields a prime
for every positive integer n ≤ 40. But when n = 41, E(41) = 412 is not a prime.
Theorem 3: There is no polynomial f(n) with integral coefficients that will produce primes for
all integers n.
( )
Where ak ≠ 0. Let b be some integer. Since f(n) is always a prime, f(b) must be a prime p; that
is,
( ) (1)
( ) ( ) ( ) ( )
( ) ( )
( ) ( ) ( )
( )]
17
So p | f (b+tp). But every value of f is a prime, so f (b+tp) must be a prime and hence
f (b+tp) = p. Thus, f (b) = p = f(b+tp). This implies f takes on the same value infinitely many
times, since t is an arbitrary integer.
But f (n) is a polynomial of degree k, so it cannot assume the same value more than k
times, yielding a contradiction.
Thus, no polynomial with integral coefficients exists that will generate only primes. All
this shows that prime numbers are distributed irregularly among integers.
But the average distribution of primes is very regular, its density shows a steady but slow
decrease. The number of primes between 2 to 1000, 1001 to 2000, 2001 to 3000, 3001 to 4000
and 4001 to 5000 are 168, 135, 127, 120, and 119 and those in the last five blocks of 1000 below
10,000,000 are 62, 58, 67, 64 and 53.
x
lim 1 (That is, as x gets larger and larger, ( ) approaches x / ln x.)
x x / lnx
Gauss noticed the similarity between the values of ( ) and x/ln x, as x gets larger and
conjectured the theorem in 1793, but did not provide a proof. In 1850, the Russian
mathematician Pafnuty Lvovich Chebychev made significant progress toward a proof; he proved
that there are positive constants a and b, such that
( ) where x ≥ 2.
In 1896, the French mathematician Jacques Hadamard and the Belgian mathematician
Charles-Jean-Nicholas de la Vallee-Poussin, working independently, proved the theorem using
advanced mathematics. This proof was a milestone in the development of number theory. But in
1950, the Hungarian mathematician Paul Erdos and Norwegian mathematician Alte Selberg
proved the theorem using elementary calculus.
( ) ( )
Let us construct a table comparing with that of .
ln li
( ) ( )
x π(x)
ln l
103 168 1.160 0.9438202
104 1229 1.132 0.9863563
105 9592 1.104 0.9960540
106 78498 1.085 0.9983466
107 664579 1.071 0.9998944
108 5761455 1.061 0.9998691
109 50847534 1.054 0.9999665
1010 455052512 1.048 0.9999932
( ) ( )
From the table it is clear that approaches 1 more rapidly than .
li ln
2. 5. Summary
In this chapter we have studied the properties of primes which are considered as building blocks
of integers. We have seen in this chapter how haphazardly primes are distributed among integers
and also there exists no simple formula to find nth prime. At the end of the chapter we stated one
of the most important theorem “Prime number theorem”.
2.6. Keywords
Trial division, sieve, conjecture, polynomial.
2.7. Exercises:
1. Prove that if p is a prime such that p + 2 is also a prime then
(a) p(p + 2) + 1 is a perfect square
(b) 12 | p + (p + 2) whenever p > 3.
2. Determine whether the integer 1013 is prime by testing all primes p 1013 as possible
divisors.
19
5. Show that if n > 2, there exists a prime p such that p < n < 2p.
6. Prove that if p and p2 + 8 are primes, p3 + 4 is also prime.
p
7. If p is a prime and 1 k < p, then prove that p | .
k
8. Let p and q be successive odd primes and p + q = 2r, then prove that r is composite.
9. If n is composite then prove that 2n – 1 is composite.
10. Prove that the Goldbach conjecture that every even integer greater than 2 is the sum of
two primes is equivalent to the statement that every integer greater than 5 is the sum of
three primes.
11. Let pn denote the nth prime number. For n ≥ 3, prove that pn23 pn pn1 pn2 .
2.8. References:
1. An Introduction to Theory of Numbers, G. H. Hardy and E. M. Wright, Oxford
2. Elementary Number Theory, David M. Burton, McGraw Hill Publication
3. The New Book of Prime Number Record, Paulo Ribenboim, Springer Verlag
4. Elementary Number Theory with Applications, Thomas Koshy, Elsevier.
5. Elementary Number Theory and its Applications, Kenneth H. Rosen, Addison Wesley.
20
UNIT – 3
FERMAT’S FACTORIZATION AND FERMAT’S LITTLE THEOREM
Structure:
3.0. Objective
3.1. Congruences
3.2. Linear Congruences
3.3. System of Linear Congruences
3.4. Fermat’s Little Theorem
3.5. Fermat’s Factorization Technique
3.6. Summary
3.7. Keywords
3.8. Exercises
3.9. References
3.0. Objective
This chapter introduces the basic properties of congruences modulo n, along with the related
notion of congruence classes modulo n. Other items discussed include the Chinese remainder
theorem to solve a system of linear congruences, Fermat’s little theorem and Fermat’s
factorization technique.
3.1. Congruences
Definition 1: Let n be a fixed positive integer. Two integers a and b are said to be congruent
modulo n, symbolized by a b ( mod n) if n divides the difference a – b; that is provided that a –
b = kn for some integer k.
To fix the idea, consider n = 7. It is routine to check that
3 24 (mod 7) –31 11 (mod 7) –15 – 64(mod 7)
Because 3 – 24 = (–3) 7, (-31) –11 = (– 6) 7 , and –15 – (– 64) = 7 7.
When n | a b , we say that a is incongruent to b modulo n, and in this case we write a b
(mod n).
For a simple example: 25 12 (mod 7), because 7 fails to divide 25 – 12 = 13.
21
It is to be noted that any two integers are congruent modulo 1, whereas two integers are
congruent modulo 2 when they are both even or both odd. In as much as congruence modulo 1 is
not particularly interesting, the usual practice is to assume that n > 1.
Given an integer a, let q and r be its quotient and remainder upon division by n, so that
a = qn + r 0 r < n.
Then, by definition of congruence, a r (mod n). Because there are n choices for r, we see that
every integer is congruent modulo n to exactly one of the values 0,1,2,...,n – 1; in particular, a
0 (mod n) if and only if n | a. The set of n integers 0, 1, 2 ,…,n – 1 is called the set of least
nonnegative residues modulo n.
In general, a collection of n integers a1, a2,…, an is said to form a complete set of residues (or a
complete system of residues) modulo n if every integer is congruent modulo n to one and only
one of the ak. To put it another way, a1, a2 , …, an are congruent modulo n to 0, 1, 2 ,..., n – 1,
taken in some order. For instance,
–12, –4, 11, 13, 22, 82, and 91
constitute a complete set of residues modulo 7; here, we have
–12 2 –4 3 11 4 13 6 22 1 82 5 91 0
all modulo 7. An observation of some importance is that any n integers form a complete set of
residues modulo n if and only if no two of the integers are congruent modulo n. We shall need
this fact later.
Our first theorem provides a useful characterization of congruence modulo n in terms of
remainders upon division by n.
Theorem 1: For arbitary integers a and b, a b (mod n) if and only if a and b leave the same
nonnegative remainder when divided by n.
Proof. First take a b (mod n), so that a = b + kn for some integer k. Upon division by n, b
leaves a certain remainder r; that is, b = qn + r, where 0 r < n. Therefore.
( ) ( )
which indicates that a has the same remainder as b.
On the other hand, suppose we can write a = q1n + r and b = q2n + r, with the same remainder r
( 0 r < n). Then
a b q1n r q2n r q1 q2 n
22
Example 1: Because the integers –56 and –11 can be expressed in the form (– 56) = (–7)9+7
– 11 = (– 2)9+7 with the same remainder 7, Theorem 1 tells us that –56 –11 (mod 9). Going
in the other direction, the congruence – 31 11(mod 7) implies that – 31 and 11 have the same
remainder when divided by 7; this is clear from the relations –31 = (–5)7+4 and 11=1.7+4
Theorem 2: Let n >1 be fixed and a, b, c, d be arbitrary integers. Then the following properties
hold:
a) a a (mod n).
b) If a b (mod n), then b a (mod n).
c) If a b(mod n) and b c(mod n), then a c(mod n).
d) If a b(mod n) and c d(mod n), then a + c b + d(mod n) and ac bd(mod n).
e) If a b(mod n), then a +c b +c(mod n) and ac bc(mod n).
f) If a b(mod n), then ak bk(mod n) for any positive integer k.
Proof. For any integer a, we have a – a = 0 n, so that a a(mod n). Now if a b(mod n) , then
a – b = kn for some integer k. Hence, b – a = -(kn) = (-k)n and because – k is an integer, this
yields property (b).
Property (c) is slightly less obvious: Suppose that a b(mod n) and also b c(mod n).
Then there exists integers h and k satisfying a – b = hn and b – c = kn. It follows that
a – c = (a – b) + (b – c) = hn +kn = (h + k)n.
This implies n | a – c and hence a c(mod n) in congruence notation.
In the same vein, if a b (mod n) and c d(mod n), then we are assured that a – b = k1n
and c – d = k2n for some choice of k1 and k2. Adding these equations, we obtain
a c b d a b c d k1n k2n k1 k2 n
or, as a congruence statement, a+c b+d (mod n). As regards the second assertion of property
(d), note that
ac b k1n d k2n bd dk2 dk1 k1k2n n
23
(mod n) together imply that aak bbk (mod n) or equivalently ak+1 bk+1 (mod n). This is the
form the statement should take for k+1 and so the induction step is complete.
Before going further, we should illustrate that congruences can be a great help in carrying out
certain types of computations.
Example 2: Let us show that 41 divides 220 – 1. We begin by noting that 25 –9 (mod 41).
Whence (25)4 (–9)4 (mod 41) by Theorem 2 (f); in other words, 220 81 81(mod 41). But 81
–1 (mod 41), and so 81 81 1(mod 41). Using parts (b) and (e) of Theorem 2, we finally arrive
at
220 1 (81 81) 1 1 1 0 mod 41 .
24
Hence s|r(a – b) and gcd (r, s) = 1. Euclid’s lemna yields s|a – b, which may be written as a b
(mod s); in other words, a b (mod n /d).
Theorem 3 gets its maximum force when the requirement that gcd(c, n) = 1 is added, for then the
cancellation may be accomplished without a change in modulus.
Corollary 1: If ca cb (mod n) and gcd(c, n) = 1, then a b(mod n).
Corollary 2. If ca cb (mod p) and p | c and p a prime imply that gcd(c, p) = 1.
Example 4: Consider the congruence 33 15(mod 9) or, if one prefers, 3 11 3 5(mod 9).
Because gcd(3, 9) = 3, Theorem 3 leads to the conclusion that 11 5 (mod 3). A further
illustration is given by the congruence – 35 45 (mod 8), which is the same as 5 (–7) 5 9 (mod
8). The integers 5 and 8 being relatively prime, we may cancel the factor 5 to obtain a correct
congruence –7 9(mod 8).
3.2. Linear Congruences
Congruence of the form ax b(mod n) where a, b, n are integers and x is unknown is called
linear congruence. The solution of this linear congruence is an integer x0 such that
a x0 b(mod n).
Theorem 4: The linear congruence ax b(mod n) has a solution if and only if d |b, where d =
gcd (a, n). If d | b, then it has d mutually incongruent solutions modulo n.
Proof. We already have observed that the given congruence is equivalent to the linear
Diophantine equation ax – ny = b. From Theorem 8 of Chapter 1, it is known that the latter
equation can be solved if and only if d | b; moreover, if it is solvable and x0, y0 is one specific
solution, then any other solution has the form
n n
x x0 t, y y0 t , for some choice of t.
d d
Among the various integers satisfying the first of these formulas, consider those that occur when
t takes on the successive values t = 0, 1, 2,…,d – 1:
x0 , x0
n 2n
, x0 , ...... x0
d 1 n
d d d
We claim that these integers are incongruent modulo n, and all other such integers x are
n n
congruent to some one of them. If it happened that x0 t1 x0 t2 mod n , where 0 t1 <
d d
n n
t2 d –1, then we would have t1 t2 mod n .
d d
25
Now gcd(n /d, n) = n /d, and therefore by Theorem 3 the factor n /d could be canceled to arrive
at the congruence t1 t2(mod d) which is to say that d |t2 – t1. But this is impossible in view of the
inequality 0 < t2 – t1 < d.
It remains to argue that any other solution x0+(n /d)t is congruent modulo n to one of the d
integers listed above. The Division Algorithm permits us to write t as t = qd+r, where 0r
d – 1. Hence
n n
t x0 qd r
x0
d d
n
x0 nq r
d
n
x0 r mod n
d
with x0+(n /d)r being one of our d selected solutions. This ends the proof.
The argument that we gave in Theorem 4 brings out a point worth starting explicitly; If x0
is any solution of ax b(mod n), then the d = gcd(a, n) incongruent solutions are given by
n n n
x0 , x0 , x0 2 , , x0 d 1
d d d
Corollary 3: If gcd(a, n) = 1, then the linear congruence ax d(mod n) has a unique solution
modulo n.
Given relatively prime integers a and n, the congruence ax 1(mod n) has a unique
solution. This solution is sometimes called the (multiplicative) inverse of a modulo n.
We now pause to look at two concrete examples.
Example 5: First consider the linear congruence 18x 30 (mod 42). Because gcd(18, 42) = 6
and 6 divides 30, Theorem 4 guarantees the existence of exactly six solutions, which are
incongruent modulo 42. By inspection, one solution is found to be x = 4. Our analysis tells us
that the six solutions are as follows:
x 4 + (42/6)t 4+7t(mod 42), t = 0, 1,…,5
or, plainly enumerated,
x 4, 11, 18, 25, 32, 39(mod 42).
Example 6: Let us solve the linear congruence 9x 21(mod 30). At the outset, because gcd(9,
30) = 3 and 3 | 21, we know that there must be three incongruent solutions.
One way to find these solutions is to divide the given congruence throughout by 3,
thereby replacing it by the equivalent congruence 3x 7(mod 10). The relative primeness of 3
26
and 10 implies that the latter congruence admits a unique solution modulo 10. Although it is not
the most efficient method, we could test the integers 0, 1, 2,…,9 in turn until the solution is
obtained. A better way is this: Multiply both sides of the congruence 3x 7(mod 10) by 7 to get
21x 49 (mod 10) which reduces to x 9(mod 10). (This simplification is no accident, for the
multiples 0 3, 1 3, 2 3,…,9 3 form a complete set of residues modulo 10; hence, one of them is
necessarily congruent to 1 modulo 10). But the original congruence was given modulo 30, so that
its incongruent solutions are sought among the integers 0, 1, 2,…,29. Taking t = 0, 1, 2 in the
formula.
x = 9+10t
we obtain 9, 19, 29 whence
x 9 (mod 30) x 19 (mod 30) x 29 (mod 30)
are the required three solutions of 9x 21 (mod 30).
A different approach to the problem is to use the method that is suggested in the proof of
theorem 4. Because the congruence 9x 21 (mod 30) is equivalent to the linear Diophantine
equation
9x – 30y = 21
we begin by expressing 3 = gcd(9, 30) as a linear combination of 9 and 30. It is found, either by
inspection or by using the Euclidean Algorithm, that 3 = 9(–3) +30 1, so that,
21 = 7 3 = 9 (–21) – 30 (–7)
Thus, x = –21, y = –7 satisfy the Diophantine equation and, in consequence, all solutions of the
congruence in question are to be found from the formula
x = –21 + (30/3)t = –21 +10t.
The integers x = –21 + 10t, where t = 0, 1, 2, are incongruent modulo 30 (but all are congruent
modulo 10); thus, we end up with the incongruent solutions.
x –21(mod 30) x –11(mod 30) x –1(mod 30)
or, if one prefers positive numbers, x 9, 19, 29 (mod 30).
3.3. System of linear Congruences
Having considered a single linear congruence, it is natural to turn to the problem of solving a
system of simultaneous linear congruences:
a1x b1(mod m1), a2x b2(mod m2),…, arx br (mod mr).
We shall assume that the moduli mk are relatively prime in pairs. Evidently, the system will
admit no solution unless each individual congruence is solvable; that is, unless dk|bk for each k,
27
where dk = gcd (ak, mk). When these conditions are satisfied, the factor dk can be canceled in the
kth congruence to produce a new system having the same set of solutions as the original one:
a1x b1 mod n1 , a2 x b2 mod n2 , , ar x br mod nr
x ar (mod nr)
has a simultaneous solution, which is unique modulo the integer n1n2,…,nr.
Proof: We start by forming the product n=n1n2…nr. For each k = 1, 2,…, r, let
n
Nk n1...nk 1nk 1....nr
nk
In words, Nk is the product of all the integers ni with the factor nk omitted. By hypothesis, the ni
are relatively prime in pairs, so that gcd(Nk, nk) = 1. According to the theory of a single linear
congruence, it is therefore possible to solve the congruence Nkx 1(mod nk); call the unique
solution xk. Our aim is to prove that the integer
x a1N1 x1 a2 N 2 x2 .... ar N r xr
is a simultaneous solution of the given system.
28
First, observe that Ni ≡ 0(mod nk) for i k, because nk | Ni in this case. The result is
x a1N1 x1 ...... ar N r xr ak N k xk (mod nk)
But the integer xk was choosen to satisfy the congruence, NK x 1(mod nk), which forces
x ak .1 ak mod nk
and so nk | x x for each value of k. Because gcd(ni, nj) = 1, Corollay 4 of Chapter 1 supplies
us with the crucial point that n1n2 ….. nr| x x; hence x x mod n . With this, the Chinese
29
Multiplication of both sides of this congruence by 3 gives us
k 9k 3 (mod 4)
so that k = 3 +4j, where j is an integer. Then x = 3(3+4j) = 9+12j
For x to satisfy the last congruence, we must have
17(9+12j) 9 (mod 23)
or 204j –144 (mod 23), which reduces to 3j 6(mod 23); in consequence, j 2 (mod 23). This
yields j = 2 + 23t, with t an integer, whence
x = 9 +12 (2 + 23t) = 33 + 276t
All in all, x 33 (mod 276) provides a solution to the system of congruences and, in turn, a
solution to 17x 9 (mod 276).
Let us now consider linear congruences in two variables; that is congruences of the form
ax+by c(mod n).
In analogy with Theorem 4 such a congruence has a solution if and only if gcd(a, b, n) divides c.
The condition for solvability holds if either gcd(a, n) = 1 or gcd(b, n) = 1, say gcd(a, n) = 1.
When the congruence is expressed as
ax c – by(mod n)
the Corollary 3 guarantees a unique solution x for each of the n incongruent values of y. Take as
a simple illustration 7x + 4y 5(mod 12), that would be treated as 7x 5 – 4y(mod 12).
Substitution of y 5 (mod 12) gives 7x –15 (mod 12); but this is equivalent to –5x –15 (mod
12) so that x 3 (mod 12), y = 5(mod 12) is one of the 12 incongruent solutions of 7x + 4y
5(mod 12). Another solution having the same value of x is x 3 (mod 12), y 8 (mod 12).
The focus of our concern here is how to solve a system of two linear congruences in two
variables with the same modulus. The proof of the coming theorem adopts the familiar procedure
of eliminating one of the unknowns.
Theorem 6: The system of linear congruences
ax by r mod n
cx dy s mod n
has a unique solution modulo n whenever gcd(ad – bc, n) = 1.
Proof. Let us multiply the first congruence of the system by d, the second congruence by b, and
subtract the lower result from the upper. These calculations yield
ad bc x dr bs mod n (2)
30
The assumption gcd (ad – bc, n) = 1 ensures that the congruence
(ad – bc) z 1(mod n)
possesses a unique solution; denote the solution by t. When congruence (2) is multiplied by t, we
obtain.
x t (dr – bs) (mod n)
A value for y is found by a similar elimination process. That is, multiply the first congruence of
the system by c, the second one by a, and subtract to end up with
(ad – bc) y as – cr (mod n).
Multiplication of this congruence by t leads to
y t (as – cr) (mod n).
A solution of the system is now established.
We close this section with an example illustrating Theorem 6
Example 9: Consider the system
7x + 3y 10(mod 16)
2x + 5y 9(mod 16)
Because gcd(7 5 – 2 3, 16) = gcd(29, 16) = 1, a solution exists. It is obtained by the method
developed in the proof of Theorem 6. Multiplying the first congruence by 5, the second one by
3, and subtracting, we arrive at
29x 5.10 – 3.9 23(mod 16)
or, what is the same thing, 13x 7 (mod 16). Multiplication of this congruence by 5 (noting that
5 13 1(mod 16)) produces x 35 3(mod 16). When the variable x is eliminated from the
system of congruences in a like manner, it is found that
29y 7 9 – 2 10 43(mod 16)
But, then 13y 11 (mod 16), which upon multiplication by 5, results in y 55 7(mod 16). The
unique solution of our system turns out to be
x 3 (mod 16) y 7 (mod 16)
3.4. Fermat’s Little Theorem
Theorem 7: Let p be a prime and suppose that p | a. Then
ap-1 1 (mod p).
Proof. We begin by considering the first p-1 positive multiples of a ; that is, the integers
a, 2a, 3a, …(p – 1)a.
31
None of these numbers is congruent modulo p to any other, nor is any congruent to zero. Indeed,
if it happened that
ra sa (mod p) 1 r < s p – 1,
then a could be canceled to give r s (mod p). Hence a, 2a, …, (p – 1)a mod p are the integers
1, 2, 3, …, (p – 1) arranged in some different order. Therefore,
ap-1(p – 1)! (p – 1)!(mod p)
Once (p – 1)! is canceled from both sides of the preceding congruence (this is possible because
p | p 1! ) our line of reasoning culminates in the statement that ap-1 1(mod p), which is
Fermat’s theorem.
This result can be stated in a slightly more general way in which the requirement that p | a is
dropped.
Corollary 4: If p is a prime, then ap a (mod p) for any integer a.
Proof. When p | a, the statement obviously holds; for, in this setting, ap 0 a(mod p). If p | a ,
then according to Fermat’s theorem, we have ap-1 1(mod p). When this congruence is
multiplied by a, the conclusion ap a(mod p) follows.
Theorem 8: Let p1, p2, … , pk be any distinct primes, a any positive integer, and l = [p1 – 1,
p2 – 1, …, pk – 1]. Then al + 1 ≡ a(mod p1p2…pk).
Proof: By Fermat’s theorem, a pi 1 1(mod pi ), where 1 i k. Since pi – 1 | l, this implies
(a pi 1 )l /( pi 1) 1(mod pi ); that is, al ≡ 1(mod pi). Thus al + 1 ≡ a(mod pi). Consequently, al + 1 ≡
as desired. Another use of Fermat’s theorem is as a tool in testing the primality of a given integer
n. If it could be shown that the congruence a n a mod n fails to hold for some choice of a,
then n is necessarily composite. As an example of this approach, let us look at n = 117. The
computation is kept under control by selecting a small integer for a, say, a = 2. Because 2117
32
We have 2117 1116 25 121 25 48 25 221 mod 117 .
8
Proof. The last corollary tells us that a q a q mod p , whereas aq a(mod p) holds by
p
Thus, 211 2 210 2 1 2 mod 31 and 231 2 210 2 13 2 mod 11
3
After cancelling a factor of 2, we pass to 2340 1 mod 341 , so that the converse to Fermat’s
theorem is false.
3.5. Fermat’s Factorization Technique
In Chapter 2, we have seen that in order to find the factors of an odd composite integer, trial
division could be used. But trial division becomes impractical if the number has more than
twelve digits.
Fermat’s factorization scheme has at its heart the observation that the search for factors of
an odd integer n is equivalent to obtaining integral solutions x and y of the equation
n x2 y2 (3)
33
Conversely, when n has the factorization n = ab, with a ≥ b ≥ 1, then we may write
ab ab
2 2
n .
2 2
Moreover, because n is taken to be an odd integer, a and b are themselves odd; hence (a + b) / 2
and (a – b) / 2 will be non-negative integers.
For example, consider n = 8051. Now, 8051 can be written as 8051 = 902 – 72. Hence, 8051 =
83 × 97.
Observe that (3) can be written as x 2 n y 2
Set k = [n] + 1, where [ ] denotes the greatest integer function. Then, look successively at the
numbers k2 – n, (k+1)2 – n, (k+2)2 – n, (k+3)2 – n, … until a value of m is found such that m2 – n
is a square. The process cannot go on indefinitely, because we eventually arrive at
n 1 n 1
2 2
n .
2 2
The representation of n corresponding to the trivial factorization n = n 1. In this case, we have
trivial divisors 1 and n and hence n is prime.
Fermat used the procedure just described to factor
2027651281 = 44021 46061
in only 11 steps, as compared with making 4580 divisions by the odd primes up to 44021.
Example 10: Let n = 10541. Then [ n ] 1 103. Therefore, we have to consider the values
k2 – 10541 for k ≥ 103. Taking k = 103, 104, … we have
1032 – 10541 = 68
1032 – 10541 = 275
1032 – 10541 = 484 = 222.
Last relation gives
10541 = 1032 – 222 = (105 + 22) (105 – 22) = 127 × 83.
Example 11: Let n = 23449. [ n ] 1 154. Therefore, we have to consider the values k2 –
23449 for k ≥ 154. Taking k = 154, 155, … we have
1542 – 23449 = 267
1552 – 23449 = 576 = 242.
The last relation gives
23449 = 1552 – 242 = (155 + 24) (155 – 24) = 179 × 131.
34
In the 1920s Maurice Kraitchik came up with an interesting enhancement of Fermat’s
difference-of-squares technique, and it is this enhancement that is at the basis of most modern
factoring algorithms. Instead of trying to find integers a and b with a2 – b2 equal to n, Kraichik
reasoned that it might suffice to find a and b with a2 – b2 equal to a multiple of n, that is a2 ≡ b2
(mod n). Such a congruence can have uninteresting solutions, those where a ≡ ±b(mod n), and
interesting solutions, where a b(mod n) . In fact, if n is odd and divisible by at least two
different primes, then at least half of the solutions to a2 ≡ b2 (mod n), with ab coprime to n, are of
the interesting variety. And for an interesting solution a, b, the greatest common factor of
gcd(a – b, n) must be a non-trivial factor of n. Indeed, n divides a2 – b2 = (a – b)(a + b) but
neither factor. So n must be somehow split between a – b and a + b.
Example 12: Let us use Kraitchik’s method to factor n = 2041. [ n ] 1 462. Consider the
35
A short search reveals that
1122 – 12499 = 45
1172 – 12499 = 1190
1212 – 12499 = 2142
Or, written as congruences,
1122 ≡ 32 · 5 (mod 12499)
1172 ≡ 2 · 5 · 7 · 17 (mod 12499)
1212 ≡ 2 · 32 · 7 · 17 (mod 12499)
Multiplying these together results in the congruence
(112 · 117 · 121)2 ≡ (2 · 32 · 5 · 7 · 17)2 (mod 12499)
that is,
15855842 ≡ 107102 (mod 12499)
But we are unlucky with this square combination. Because
1585584 ≡ 10710 (mod 12499)
only a trivial divisor of 12499 will be found. To be specific,
gcd(1585584 + 10710, 12499) = 1
gcd(1585584 – 10710, 12499) = 12499
After further calculation, we notice that
1132 ≡ 2 · 5 · 33 (mod 12499)
1272 ≡ 2 · 3 · 5 · 112 (mod 12499)
which gives rise to the congruence
(113 · 127)2 ≡ (2 · 32 · 5 · 11)2 (mod 12499)
This reduces modulo 12499 to
18522 ≡ 9902 (mod 12499)
and fortunately 1852 990(mod12499) . Calculating
gcd(1855 – 990, 12499) = gcd(862 , 12499) = 431
produces the factorization 12499 = 29 · 431.
3.6. Summary
In this chapter we studied the properties of congruences and learned to solve a system of linear
congruences using Chinese remainder theorem. Also, we proved one of the most celebrated
theorem “Fermat’s little theorem”. At the end of the chapter we learned to factorize a given
integer using Fermat’s factorization technique.
36
3.7. Keywords
Congruence, modulo, residue, remainder, linear congruence, incongruent solution, pairwise
relatively prime.
3.8. Exercises
1. Prove that if a ≡ b(mod m) and n | m, then a ≡ b(mod n). Also prove that gcd(a, m) =
gcd(b, m).
2. Find the remainder when 214 is divided by 17 and 3100 is divided by 5.
3. Compute the multiplicative inverse of 160 modulo 841.
4. What is the remainder when
15 + 25 + 35 + … + 995 + 1005
is divided by 4?
5. Prove that the integer 53103 + 10353 is divisible by 39.
6. Give an example to show that ak ≡ bk(mod n) and k ≡ j(mod n) need not imply that aj ≡
bj(mod n).
7. Find the last two digits in the decimal value of 17761976.
8. Prove that n2 + n ≡ 0(mod 2).
9. Solve the following linear congruences:
a. 25x ≡ 10(mod 29)
b. 5x ≡ 2(mod 26)
c. 140x ≡ 133(mod 301)
d. 9x ≡ 12(mod 15)
e. 30x ≡ 52(mod 49).
10. Solve each of the following sets of simultaneous congruences:
a. x ≡ 1(mod 3), x ≡ 2(mod 5), x ≡ 3(mod 7)
b. x ≡ 5(mod 11), x ≡ 14(mod 29), x ≡ 15(mod 31)
c. 2x ≡ 1(mod 5), 3x ≡ 9(mod 6), 4x ≡ 1(mod 7), 5x ≡ 9(mod 11).
11. Solve the linear congruence 17x ≡ 3(mod 2 3 5 7).
12. Prove that the congruences x ≡ a(mod n) and x ≡ b(mod m) admits a simultaneous
solution if gcd(n, m) | a – b.
13. Find the solutions of the system of congruences:
3x + 4y ≡ 5(mod 13)
2x + 5y ≡ 7(mod 13).
37
14. Use Fermat’s theorem to verify that 17 divides 11104 + 1.
15. If 7 | a , then prove that either a3 + 1 or a3 – 1 is divisible by 7.
16. Prove that 18351910 + 19862061 ≡ 0(mod 7).
17. Employ Fermat’s theorem to prove that if p is an odd prime, then
a. 1p – 1 + 2p – 1 + 3p – 1 + … + (p – 1)p – 1 ≡ –1(mod p)
b. 1p + 2p + 3p + … + (p – 1)p ≡ 0(mod p).
18. Use Fermat’s method to factor each of the following numbers: (a) 2279 (b) 10541
19. For any integer a
a. a7 ≡ a(mod 42)
b. a19 ≡ a(mod 57)
c. a31 ≡ a(mod 77).
20. Use Kraichik’s mdthod to factor 20437.
3.9. References
1. Elementary Number Theory, David M. Burton, McGraw Hill Publication
2. Elementary Number Theory with Applications, Thomas Koshy, Elsevier
3. Basic Number Theory, S. B. Malik, Vikas Publications
4. Elementary Number Theory and its Applications, Kenneth H. Rosen, Addison Wesley
38
UNIT – 4
EULER’S THEOREM AND WILSON’S THEOREM
Structure:
4.0. Objective
4.1. Wilson’s Theorem
4.2. Euler’s Totient Function
4.3. Euler’s Theorem
4.4. Summary
4.5. Keywords
4.6. Exercises
4.7. References
4.0. Objective:
The objective of this chapter is to prove two important theorems, one is Wilson’s theorem and
another is Euler’s theorem. In order to prove Euler’s theorem which has many applications, we
introduce Euler’s Totient function and study some of its properties.
39
congruences are multiplied together and the factors rearranged, we get 2 3 … (p – 2) 1 (mod
p) or rather (p – 2)! 1(mod p).
Now multiply by p – 1 to obtain the congruence ( p 1)! p 1 1(mod p) as was to be
proved.
Example 1: A concrete example should help to clarify the proof of Wilson’s theorem.
Specifically, let us take p = 13. It is possible to divide the integers 2, 3,…,11 into (p – 3) /2 = 5
pairs, each product of which is congruent to 1 modulo 13. To write these congruences out
explicitly:
2 7 1(mod 13)
3 9 1 (mod 13)
4 10 1 (mod 13)
5 8 1 (mod 13)
6 11 1 (mod 13)
Multiplying these congruences gives the result
11! = (2 7) (3 9) (4 10) (5 8) (6 11) 1(mod 13),
and so,
12! 12 –1(mod 13)
Thus, (p – 1)! –1(mod p), with p = 13.
The converse of Wilson’s theorem is also true. If (n – 1)! –1(mod n), then n must be
prime. For, if n is not a prime, then n has a divisor d with 1 < d < n. Furthermore, because d n
– 1, d occurs as one of the factors in (n – 1)!, whence d | (n – 1)!. Now we are assuming that n |
(n – 1)!+1, and so d | (n – 1)!+1, too. The conclusion is that d | 1, which is nonsense.
Taken together, Wilson’s theorem and its converse provide a necessary and sufficient
condition for determining primality; namely, an integer n > 1 is prime if and only if (n – 1)!
–1(mod n). Unfortunately, this test is of more theoretical than particle interest because as n
increases, (n – 1)! rapidly becomes unmanageable in size.
We now give an application of Wilson’s theorem to the study of quadratic congruences. [It is
understood that quadratic congruence means a congruence of the form ax 2 bx c 0 mod n ,
40
Proof. Let a be any solution of x 2 1 0 mod p , so that a 2 1 mod p . Because p | a the
1 a p1 a 2
p 1/2 p 1/2
1 mod p
The possibility that p = 4k +3 for some k does not arise. If it did, we would have
1
p 1 /2
1
2 k 1
1
Hence, 1 –1(mod p). The net result of this is that p | 2, which is false. Therefore, p must be of
the form 4k+1.
Now, for the opposite direction, in the product
p 1 p 1
p 1! 1 2... . ... p 2 p 1
2 2
we have the congruences
p 1 1(mod p )
p 2 2 mod p
p 1 p 1
mod p .
2 2
Rearranging the factors produces
p 1 p 1
p 1! 1 1 .2. 2 ... . mod p
2 2
p 1
2
p 1 /2
1 1.2... mod p .
2
Because there are (p – 1)/2 minus sings involved, it is at this point that wilson’s theorem can be
brought to bear. For, (p – 1)! –1(mod p), whence
2
p 1/2 p 1
1 1 2 ! mod p .
If we assume that p is of the form 4k +1, then (-1)(p-1)/2 =1, leaving us with the congruence
2
p 1
1 ! (mod p).
2
The conclusion is that the integer p 1 / 2 ! satisfies the quadratic congruence x2+1 = 0 (mod p).
41
4.2. Euler’s Totient Function
Let us now prove another famous theorem “Euler’s Generalized Theorem”. To prove this
theorem we need some preparations.
Definition 1: For n 1, let (n) denote the number of positive integers not exceeding n that are
relatively prime to n.
As an illustration of the definition, we find that (30) = 8; for, among the positive
integers that do not exceed 30, there are eight that are relatively prime to 30; specifically, 1, 7,
11, 13, 17, 19, 23, and 29.
Similarly, for the first few positive integers, the reader may check that
(1) = 1, (2) = 1, (3) = 2, (4) = 2, (5) = 4, (6) = 2, (7) = 6, …
Notice that (1) =1, because gcd(1, 1) = 1. In the event n > 1, gcd(n, n) = n 1, so that (n) can
be characterized as the number of integers less than n and relatively prime to it. The function is
usually called the Euler’s phi - function (sometimes, the indicator or totient) after its originator.
The functional notation (n), however, is credited to Gauss.
If n is a prime number, then every integer less than n is relatively prime to it; whence,
(n) = n – 1. On the other hand, if n > 1 is composite, then n has a divisor d such that 1 < d < n. It
follows that there are at least two integers among 1,2,3, …, n that are not relatively prime to n,
namely, d and n itself. As a result, (n) n – 2. This proves that for n > 1, (n) = n – 1 if and
only if n is prime.
The first item on the agenda is to derive a formula that will allow us to calculate the value
of (n) directly from the prime-power factorization of n. A large step in this direction stems from
Theorem 3.
Theorem 3. If p is a prime and k > 0, then
1
p k p k p k 1 p k 1
p
Proof. Clearly gcd(n, pk) = 1 if and only if p | n . There are pk-1 integers between 1 and pk
divisible by p, namely, p, 2p, 3p ,…, (pk-1)p. Thus, the set {1,2,…,pk} contains exactly pk –pk–1
integers that are relatively prime to pk, and so by the definition of the phi-function, (pk) = pk –
pk-1.
For an example, we have 9 32 32 3 6 the six integers less than and
relatively prime to 9 being 1, 2, 4, 5, 7, and 8. To give a second illustration, there are 8 integers
42
that are less than 16 and relatively prime to it; they are 1, 3, 5, 7, 9, 11, 13, and 15. Theorem 3
yields the same count; 16 24 24 23 16 8 8 . We now know how to evaluate the
phi-function for prime powers, and our aim is to obtain a formula for (n) based on the
factorization of n as a product of primes. The missing link in the chain is obvious; show that is
a multiplicative function. We pave the way with an easy lemma.
Lemma 1: Given integers a, b, c, gcd(a, bc) =1 if and only if gcd (a, b) =1 and gcd (a, c) =
Proof: First suppose that gcd(a, bc) =1, and put d = gcd(a, b). Then d | a and d | b whence d | a
and d | bc. This implies that gcd(a, bc) d, which forces d = 1. Similar reasoning gives rise to the
statement gcd(a, c)=1.
For the other direction, take gcd(a, b) =1 = gcd(a, c) and assume that gcd(a, bc) = d1 > 1.
Then d1 must have a prime divisor p. Because d1 | bc, if follows that p | bc; in conseqence, p | b or
p | c. If p | b, then (by virtue of the fact that p | a) we have gcd(a, b) p, a contradiction. In the
same way, the condition p | c leads to the equally false conclusion that gcd(a, c) p. Thus, d1 = 1
and the lemma is proven.
Note: Any function whose domain of definition is the set of positive integers is said to be a
number-theoretic (or arithmetic) function.
Definition 2: A number-theoretic function f is said to be multiplicative if
f(mn) = f(m)f(n)
whenever gcd(m, n) = 1.
Theorem 4: The function is a multiplicative function.
Proof: It is required to show that (mn) = (m) (n), whenever m and n have no common factor.
Because (1) = 1, the result obviously holds if either m or n equals 1. Thus, we may assume that
m > 1 and n > 1. Arrange the integers from 1 to mn in m columns of n integers each, as follows:
1 2 r m
m 1 m2 mr 2m
2m 1 2m 2 2m r 3m
(n 1)m 1 ( n 1)m 2 ( n 1) m r nm
We know that (mn) is equal to the number of entries in this array that are relatively prime to
mn: by virtue of the lemna, this is the same as the number of integers that are relatively prime to
both m and n.
43
Before embarking on the details, it is worth commenting on the tactics to be adopted; Because
gcd(qm + r, m) = gcd(r, m), the numbers in the rth column are relatively prime to m if and only if
r itself is relatively prime to m. Therefore, only (m) columns contains integers relatively prime
to m, and every entry in the column will be relatively prime to m. The problem is one of showing
that in each of these there are exactly (n) integers that are relatively prime to n: for then
altogether there would be (m)(n) numbers in the table that are relatively prime to both m and n.
Now the entries in the rth column (where it is assumed gcd(r, m) = 1) are
r, m+r, 2m+r, …, (n – 1)m+r.
There are n integers in this sequence and no two are congruent modulo n. If
km+r jm +r (mod n) with 0 k < j < n,
it would follow that
km jm (mod n).
Because gcd(m, n) = 1, we could cancel m from both sides of this congruence to arrive at the
contradiction that k j (mod n).
Thus, the numbers in the rth column are congruent modulo n to 0, 1, 2,…,n – 1 in some order.
But if s t(mod n), then gcd(s, n) = 1 if and only if gcd(t, n) = 1. The implication is that the rth
column contains as many integers that are relatively prime to n as does the set (0, 1, 2,…,n-1),
namely, (n) integers. Therefore, the total number of entries in the array that are relatively prime
to both m and n is (m) (n). This completes the proof of the theorem.
With these preliminaries in hand, we now can prove Theorem 5.
Theorem 5: If the integer n > 1 has the prime factorization n p1k1 p2k2 prkr , then
1
n p1k p1k 1 p2k p2k 1 .... prk prk
1 1 2 2 r r 1
n 1 p1 1 p1 1
1 2 pr
Proof: We intend to use induction on r, the number of distinct prime factors of n. By Theorem 3,
result is true for r =1. Suppose that it holds for r = i. Because
gcd p1k1 p2k2
piki , piki 11 1
p
k1
1
p1ki piki 11 p1k1
piki piki 11 p1k1 piki p ki 1
i 1 piki 11 1
Invoking the induction assumption, the first factor on the right-hand side becomes
p1k p2k
1 2
piki p1k1 p1k11 p2k2 p2k21 p
ki
i piki 1
44
and this serves to complete the induction step, and the proof.
Example 2: Let us calculate the value (360),for instance. The prime power decomposition of
360 is 23. 32.5, and Theorem 5 tells us that
1 1 1
360 360 1 1 1
2 3 5
1 2 4
360. . . 96
2 3 5
Apart from (1) and (2), the values of (n) in our examples are always even. This is no
accident, as the next theorem shows.
Theorem 6: For n > 2, (n) is an even integer.
Proof: First, assume that n is a power of 2, let us say that n = 24, with k 2. By Theorem 5
1
n 2k 2k 1 2k 1
2
an even integer. If n does not happen to be a power of 2, then it is divisible by an odd prime p;
we therefore may write n as n = pkm, where k 1 and gcd (pk, m) = 1. Exploiting the
multiplicative nature of the phi-function, we obtain
n p k m p k 1 p 1 m , which again is even because 2 | p-1.
generalizing Fermat’s theorem from the case of a prime p to an arbitrary positive integer n. This
n
landmark result states: If gcd(a, n) = 1, then a 1 (mod n).
For example, for n = 30 and a = 11, we have
45
Proof: Observe that no two of the integers aa1, aa2,…,aa(n) are congruent modulo n. For if aai
aaj(mod n), with 1 i < j (n), then the cancellation law yields ai aj (mod n), and thus ai = aj,
a contradiction. Furthermore, because gcd(ai, n) = 1 for all i and gcd(a, n) = 1, the Lemma 1
guarantees that each of the aai is relatively prime to n.
Fixing on a particular aai, there exist a unique integer b, where 0 b < n, for which aai
b(mod n). Because gcd(b, n) = gcd (aai, n) =1, b must be one of the integers a1, a2,…,a(n). All
this proves that the numbers aa1, aa2,…, aa(n) and the numbers a1, a2,…,a(n) are identical
(modulo n) in a certain order.
Theorem 7: (Euler) If n 1 and gcd (a, n) = 1, then a(n) 1 (mod n).
Proof: There is no harm in taking n > 1. Let a1, a2,…,a(n) be the positive integers less than n that
are relatively prime to n. Because gcd (a, n) =1, it follows from the lemma that aa1, aa2,…,aa(n)
are congruent, not necessarily in order of appearance, to a1, a2,…,a(n) Then,
aa1 a1 mod n
aa2 a2 mod n
where a1 , a2 .....a n are the integers a1, a2,…,a(n) in some order. On taking the product of these
and so
a n a1a2 ...a n a1a2 ...a n mod n .
Because gcd (ai, n) = 1 for each i, the Lemma 1, implies that gcd(a1a2 ...a(n), n) = 1. Therefore,
we may cancel both sides of the foregoing congruence by the common factor a1a2 ....a(n),
1 mod n .
n
leaving us with a
For example, let n = 9. Then the positive integers less than and relatively prime to 9 are
1, 2, 4, 5, 7, and 8. These play the role of the integers a1, a2, …, a(n) in the proof of Theorem 7.
If a = –4, then the integers aai are –4, –8, –16, –20, –28, –32 where, modulo 9,
–4 5 –8 1 –16 2 –20 7 –28 8 –32 4
When the above congruences are all multiplied together, we obtain.
(–4) (–8) (–16) (–20) (–28)(–32) 5 1 2 7 8 4 (mod 9),
46
which becomes
(1 2 4 5 7 8) (–4)6 (1 2 4 5 7 8 4) (mod 9).
Being relatively prime to 9, the six integers 1, 2, 4, 5, 7, and 8 may be canceled successively to
give
(–4)6 1 (mod 9).
The validity of this last congruence is confirmed by the calculation:
(–4)6 46 (64)2 12 1 (mod 9).
Note that Theorem 7 does indeed generalize the one credited to Fermat, which we proved earlier.
For if p is a prime, then (p) = p – 1; hence, when gcd(a, p) = 1, we get
1 mod p
p
a p1 a
and so we have the following corollary.
Corollary 1: (Fermat) If p is a prime and p | a then a p1 1 mod p
Example 3: Euler’s theorem is helpful in reducing large powers modulo n. To cite a typical
example, let us find the last two digits in the decimal representation of 3256. This is equivalent to
obtaining the smallest nonegative integer to which 3256 is congruent modulo 100. Because
gcd(3, 100) = 1 and
1 1
100 22 52 100 1 1 40
2 5
Euler’s theorem yields 340 1(mod 100). By the Division Algorithm, 256= 6 40+16: whence
3256 36 40+16 (340)6316 316(mod 100) and our problem reduces to one of evaluating 316,
modulo 100. The method, of successive squaring yields the congruences.
32 9 mod 100 34 81 mod100 38 61 mod100 316 21 mod100 .
Hence, 2 and 1 are the last two digits in the decimal representation of 3256.
Corollary 2: Let gcd (a, n) = 1 and n have the prime–power factorization n p1k1 p2k2 ... prkr . Then
a n 1 mod piki i 1,2, ,r
Proof: In view of what already has been proved, each of the congruences
1 mod p k
a
pi ki
i
i
i 1, 2, ,r (1)
47
holds. Noting that (n) is divisible by piki , we may raise both sides of Eq(1) to the power
(n) / pik i
and arrive at
a n 1 mod piki i 1,2, ,r
Inasmuch as the moduli are relatively prime, this leads us to the relation
a n 1 mod piki p2k2 .... prkr
1 mod n .
n
or a
Corollary 3: Let a be any integer and n p1k1 p2k2 ... prkr . Let l [ ( piki ), ( p2k2 ), , ( prkr )] . Then
al + 1 ≡ a(mod n).
4.4. Summary
In this chapter we proved two important theorems: Wilson’s theorem and Euler’s generalization
of Fermat’s theorem. Also we studied some of the properties of Euler’s Phi function.
4.5. Keywords
Phi function, quadratic congruence, number theoretic function, multiplicative function.
4.6. Exercises
1. Find the remainder when 15! Is divided by 17.
2. Show that 18! ≡ –1(mod 437).
3. If p is prime number, then prove that (p – 1)! ≡ (p – 1)(mod 1 + 2 + 3 + + (p – 1)).
4. If p is a prime, prove that for any integer a,
p | ap + (p – 1)! a and p | ap (p – 1)! + a.
5. Using Wilson’s theorem, prove that for any odd prime p,
12 32 52 (p – 2)2 ≡ (–1)(p + 1)/2(mod p).
6. Prove that the odd prime divisors of the integer n2 + 1 are of the form 4k + 1.
7. Find ϕ(360), ϕ(1001), ϕ(5040).
8. Prove in each of the following cases:
a. If n is an odd integer, then ϕ(2n) = ϕ(n)
b. If n is an even integer, then ϕ(2n) = 2ϕ(n)
c. ϕ(3n) = 3ϕ(n) if and only if 3 | n.
9. Prove that if the integer n has r distinct prime factors, then 2r | ϕ(n).
10. Prove that the equation ϕ(n) = ϕ(n + 2) is satisfied by n = 2(2p – 1) whenever p and
2p – 1 are both odd primes.
48
11. Prove or disprove each:
a. ϕ(gcd(a, b)) = gcd(ϕ(a), ϕ(b))
b. ϕ([a, b]) = [ϕ(a), ϕ(b)].
12. Use Euler’s theorem to establish the following: For any integer a
a. a37 ≡ a(mod 1729)
b. a13 ≡ a(mod 2730)
c. a33 ≡ a(mod 4080).
13. Using Euler’s theorem, prove that for n ≥ 0
51 | 1032n + 9 – 7.
14. Using Euler’s theorem find the remainder when 71020 is divided by 15.
15. If m and n are relatively prime positive integers, prove that mϕ(n) + nϕ(m) ≡ 1 (mod mn).
4.7. References
1. Elementary Number Theory, David M. Burton, McGraw Hill Publication
2. Elementary Number Theory with Applications, Thomas Koshy, Elsevier
3. Basic Number Theory, S. B. Malik, Vikas Publications
4. Elementary Number Theory and its Applications, Kenneth H. Rosen, Addison Wesley
49
BLOCK – II
50
UNIT – 5
5.0. Objective
5.1. (n) and (n) functions
5.2. Multiplicative function
5.3. The MÖbius inversion formula
5.4. Summary
5.5. Keywords
5.6. Exercises
5.7. References
5.0. Objective
The objective of this chapter is to study a special class of functions on the set of integers
called multiplicative functions. These functions play an important role in the study of
divisibility properties of integers and the distribution of primes.
to mean, “sum the values f(d) as d runs over all the positive divisors of the positive integer n”.
For instance, we have f d f 1 f 2 f 4 f 5 f 10 f 20
d |20
51
With this understanding, and may be expressed in the form
n 1 & n d .
d |n d |n
The notation d |n 1, in particular, says that we are to add together as many 1’s as there are
positive divisors of n. To illustrate; the integer 10 has the four positive divisors 1, 2, 5, 10.
Whence
10 1 1 1 1 1 4 and 10 d 1 2 5 10 18.
d |10 d |10
Theorem 1: If n p1k1 p2k2 ... prkr is the prime factorization of n > 1, then the postive divisors of
n are precisely those integers d of the form d p1a1 p2a2 ... prar , where 0 ai ki i 1,2, ,r
Proof. Note that the divisor d = 1 is obtained when a1 = a2= … = ar = 0, and n itself occurs
when a1 = k1, a2 = k2 = … = ar = kr. Suppose that d divides n nontrivially; say, n = dd′,
where d > 1, d′ > 1. Express both d and d′ as products of (not necessarily distinct) primes:
d = q1q2 … qs d′ =t1t2 … tu
with qi, tj prime. Then
p1k1 p2k2 prkr q1 qst1 tu
are two prime factroization of the positive integer n. By the uniqueness of the prime
factorization, each prime qi must be one of the pj. Collecting the equal primes into a single
integral power, we get.
d q1q2 qr p1a1 p2a2 ... prar
where the possibility that ai = 0 is allowed.
Conversely, every number d p1a1 p2a2 ... prar 0 ai ki turns out to be a divisor of n. For we
can write
n p1k1 p2k2 ... prkr
p1a1 p2a2 ... prar p1k1 a1 p2k2 a2 ... prkr ar
dd
with d p1k1 a1 p2k2 a2 .... prkr ar and ki ai 0 for each i. Then d 0 and d | n
We put this theorem to work at once.
Theorem 2: If n p1k1 p2k2 .... prkr is the prime factroization of n > 1, then
52
Proof. According to Theorem 1, the positive divisors of n are precisely those integers
d p1a1 p2a2 ... prar
where 0 ai ki. There are k1 + 1 choices for the exponent a1; k2 + 1 choices for a2, … ; and
kr + 1 choices for ar. Hence, there are k1 1 k2 1 ... kr 1 possible divisors of n.
1 p p
1
2
1 .... p1k1 1 p2 p22 ... p2k2 .... 1 pr pr2 ... prkr .
Applying the formula for the sum of a finite geometric series to the ith factor on the right-
hand side, we get,
piki 1 1
1 pi p ... p
2 ki
.
pi 1
i i
It follows that
p1k1 1 p2k2 1 1 prkr 1
n .
p1 1 p2 1 pr 1
Corresponding to the ∑ notation for sums, the notation for products may be defined using ,
the Greek capital letter pi. The restriction delimiting the numbers over which the product is to
be made is usually put under the sign. Examples are
f d f 1 f 2 f 3 f 4 f 5
1 d 5
f d f 1 f 3 f 9
d |9
f p f 2 f 3 f 5.
d |30
p prime
With this convention, the conclusion to Theorem 2 takes the compact form: If
n p1k1 p2k2 ..... prkr is the prime factorization of n > 1, then
piki 1 1
n ki 1 and n .
1i r 1i r pi 1
Example 1: The number 180 = 22∙ 32 ∙5 has
(180) = (2+1) (2+1) (1+1) = 18
positive divisors. These are integers of the form 2a1 3a2 5a3
where a1 = 0, 1, 2; a2 = 0, 1, 2; and a3 = 0, 1 specifically, we obtain
1, 2, 3, 4, 5, 6, 9, 10, 12, 15, 18, 20, 30, 45, 60, 90, and 180.
The sum of these integers is
23 1 33 1 52 1 7 26 24
180 7 13 6 546.
2 1 3 1 5 1 1 2 4
53
One of the more interesting properties of the divisor function is that the product of the
positive divisors of an integer n >1 is equal to n n /2 .
It is not difficult to get at this fact: Let d denote an arbitrary positive divisor of n, so
that n = dd′ for some d′. As d ranges over all (n) positive divisors of n, (n) such equations
occur. Multiplying these together, we get,
d d .
n
n
d |n d |n
2
d Or equivalently n ( n )/2 d .
n
The situation is now this: n
d |n d |n
The reader might (or, at any rate, should) have one lingering doubt concerning this equation.
For it is by no means obvious that the left-hand side is always an integer. If (n) is even, there
is certainly no problem. When (n) is odd, n turns out to be a perfect square say, n = m2; thus
d 16
d |16
16 / 2
165/2 45 1024.
Multiplicative functions arise naturally in the study of the prime factorization of an integer.
Before presenting the definition, we observe that
(2∙10) = (20) = 6 2∙4 = (2)∙(10)
At the same time, (2∙10) = (20) = 42 3∙8 = (2)∙(10)
These calculations bring out the nasty fact that, in general, it need not be true that
(mn) = (m)(n) and (mn) = (m)(n).
But, equality always holds provided m and n are relatively prime integers. This circumstance
is what prompts Definition 2. We are once again giving this definition.
54
Multiplicative functions have one big advantage for us: they are completely determined once
their values at prime powers are known. Indeed, if n > 1 is a given positive integer, then we
can write
n p1k1 p2k2 ... prkr
in canonical form; because the piki are relatively prime in pairs, the multiplicative property
ensures that f n f p1k1 f p2k2 .... f prkr .
If f is a multiplicative function that does not vanish identically, then there exists an integer n
such that f(n) 0. But f (n) = f (n∙1) = f (n) f (1).
Being nonzero, f(n) may be canceled from both sides of this equation to give f (1) = 1. The
point to which we wish to call attention is that f (1) = 1 for any multiplication function not
identically zero.
We now establish that and have the multiplicative property.
Theorem 3: The functions and are both mutiplicative functions.
Proof: Let m and n be relatively prime integers. Because the result is trivially true if either m
or n is equal to 1, we may assume that m > 1 and n > 1. If m p1k1 p2k2 ... prkr and n qiji q2 j ...qsjs
j
are the prime factorizations of m and n, then because gcd(m, n) =1 no pi can occur among the
qj . It follows that the prime factorization of the product mn is given by
mn p1k1 .... prkr q1ji ....qsjs .
Appealing to Theorem 2, we obtain
mn k1 1 ... kr 1 j1 1 ... jr 1
m n
55
Hence, any positive divisor d of mn will be uniquely representable in the form
d p1a1 ... prar q1b1 ....qsbs 0 ai ki , 0 bi ji
This allows us to write d as d = d1d2, where d1 p1a1 ... prar divides m and d 2 p1b1 ... psbs
divides n. Because no pi is equal to any qj, we surely must have gcd(d1, d2) = 1.
Theorem 4: If f is a multiplicative function and F is defined by
F n f d
d |n
It follows that
F mn f (d1 ) f (d 2 ) F mn f d1 f d 2 F m F n .
d1|m ,d 2 |m d1|m d2 |n
It might be helpful to take time out and run through the proof of Theorem 6.4 in a concrete
case. Letting m = 8 and n = 3, we have
F 8 3 = f d
d |24
F 8 F 3.
Theorem 4 provides a deceptively short way of drawing the conclusion that and are
multiplicative.
Corollary 1: The functions and are multiplicative functions.
Proof: We have mentioned that the constant function f(n) = 1 is multiplicative, as is the
identity function f(n) = n. Because and may be represented in the form
n 1 and n d
d |n d |n
56
5.3. The MÖbius inversion formula
We introduce another naturally defined function on the positive integers, the mobius
function.
Definition 3: For a positive integer n, define by the rules
1 if n 1
n 0 if p 2 | n for some prime p
1 if n p1 p2 .... pr , where pi are distinct primes
r
Put somewhat differently Definition 3 states that (n) = 0 if n is not a square free integer,
whereas n 1 if n is square free with r prime factors. For example: (30) = (2∙3∙5) =
r
mn p1 pr q1...qs 1
rs
1 1 m n
r s
d 1 1.
d |1
To prepare the ground, we first calculate F(n) for the power of a prime say, n = pk. The
positive divisors of pk are just the k +1 integers 1, p, p2,…, pk, so that
F p k d 1 p p 2 pk
d | pk
1 p 1 1 0.
57
Because is known to be a multiplicative function, an appeal to Theorem 4 is legitimate; this
result guarantees that F also is multiplicative. Thus, if the canonical factorization of n is
n p1k1 p2k2 .... prkr , then F(n) is the product of the values assigned to F for the prime powers in
this representation:
1 if n 1
d 0
d |n if n 1
where d runs through the positive divisors of n.
For an illustration of this last theorem, consider n =10. The positive divisor of 10 are 1, 2, 5,
and 10 and the desired sum is
The full significance of the mobius -function should become apparent with the next
theorem.
Theorem 7: (MÖbius inversion formula) Let F and f be two number–theoretic functions
related by the formula
F n f d .
d |n
Then,
n n
f n d F F d .
d |n d d |n d
Proof: The two sums mentioned in the conclusion of the theorem are seen to be the same
upon replacing the dummy index d by d′ = n / d; as d ranges over all positive divisors of n, so
does d′.
Carrying out the required computation we get
n
d F d d f c d f c (1)
d |n d |n c | n/d d |n c | n/d
It is easily verified that d | n and c | (n / d) if and only if c | n and d | (n / c). Because of this,
the last expression in Eq. (1) becomes.
d f c f c d f c d (2)
d |n c | n/d c |n d | n/c c|n d | n/c
58
In compliance with Theorem 6, the sum (d ) must vanish except when n / c = 1 (that is
d |( n / c )
when n = c), in which case it is equal to 1; the upshot is that the right hand side of Eq (2)
simplifies to f c d f c .1 f n
c/n d | n/c c n
the situation around, one might ask whether the multiplicative nature of F forces that of f.
Surprisingly enough, this is exactly what happens.
multiplicative.
Proof: Let m and n be relatively prime positive integers. We recall that any divisor d of mn
can be uniquely written as d = d1d2, where d1 | m, d2 | n, and gcd(d1, d2) = 1. Thus, using the
inversion formula,
59
mn
f mn d F
d |mn d
mn
d1|m d1d 2 F
d 2 |n d1d 2
m n
d1|m d1 d 2 F F
d 2 |n d1 d 2
m n
d1 F d 2 F
d1|m d1 d2 |n d2
f m f n
which is the assertion of the theorem. Needles to say, the multiplicative character of and of
F is crucial to the previous calculation.
5.4. Summary
In this chapter we have studied four important multiplicative functions which have played a
significant role in the development of number theory: ϕ, τ, σ, μ.
5.5. Keywords
Multiplicative function, Mobius inversion formula, divisor function.
5.6. Exercises
1. Evaluate τ(n) for n = 987, 3655. Also find σ(n).
1 (n)
2. Prove that d
d |n n
for each integer n ≥ 1.
3. Let n be a square free integer having r prime factors. Prove that τ(n) = 2r.
4. Find all positive integers n such that τ(n) = 10 and σ(n) = 10.
60
11. Compute μ(n) for each n, where n = 101, 496, 2047 and 11319.
12. For each positive integer n, show that
μ(n) μ(n + 1) μ(n + 2) μ(n +3) = 0.
n
13. For any integer n ≥ 3, show that (k !) 1 .
k 1
14. If an integer n > 1 has a prime factorization n p1k1 p2k2 prkr , then prove that
a. (d ) (d ) (1)
d |n
r
b. (d ) (d ) (1) p p
d |n
r
1 2 pr .
(n) (d )
15. Prove that .
n d |n d
5.7. References:
61
UNIT – 6
6.0. Objective
6.1. The greatest integer function
6.2 Some properties of the Euler’s phi-function
6.3 Summary
6.4 Keywords
6.5 Exercises
6.6 References
6.0. Objective
The objective of this chapter is to study greatest integer or “bracket” function [ ] which is
especially suitable for treating divisibility problems.
6.1. The greatest integer function
Definition 1: For an arbitrary real number x, we denote by [x] the largest integer less than or
equal to x; that is [x] is the unique integer satisfying x – 1 < [x] x.
By way of illustration, [ ] assumes the particular values
3 / 2 2 2 1
1 / 3 0 3 4
The important observation to be made here is that the equality [x] = x holds if and only if x is
an integer. Definition 1 also makes plain that any real number x can be written as x = [x] +
for a suitable choice of , with 0 < 1.
We now plan to investigate the question of how many times a particular prime p appears in
n!. For instance, if p = 3 and n = 9, then
9! = 1∙2∙3∙4∙5∙6∙7∙8∙9 = 27∙34 ∙5∙7
so that the exact power of 3 that divides 9! is 4. It is desirable to have a formula that will give
this count, without the necessity of always writing n! in canonical form. This is accomplished
by Theorem 1.
Theorem 1: If n is a positive integer and p a prime, then the exponent of the highest power
of p that divides n! is
n
p
k 1
k k
k , where the series is finite, because [n / p ] = 0 for p > n.
62
Proof: Among the first n positive integers, those divisible by p are p, 2p, …, tp, where t is the
largest integer such that tp n; in other words, t is the largest integer less than or equal to n /
p (which is to say t = [n / p]). Thus, there are exactly [n / p] multiples of p occurring in the
product that defines n!, namely,
n
p, 2 p, ..., p (1)
p
The exponent of p in the prime factorization of n! is obtained by adding to the number of
integers in Eq (1) the number of integers among 1,2, …, n divisible by p2, and then the
number divisible by p3, and so on. Reasoning as in the first paragraph the integers between 1
and n that are divisible by p2 are
n
p 2 ,2 p 2 ,..., 2 p 2
p
which are [n / p2] in number. Of these, [n / p3] are again divisible by p:
n
p 3 ,2 p 3 ,..., 3 p 3
p
After a finite number of repetitions of this process, we are led to conclude that the total
number of times p divides n! is
n
p
k 1
k
This result can be cast as the following equation, which usually appears under the name of
the Legendre formula:
n / pk
n ! p k 1
pn
Example 1: We would like to find the number of zeros with which the decimal
representation of 50! terminates. In determining the number of times 10 enters into the
product 50!, it is enough to find the exponents of 2 and 5 in the prime factorization of 50!,
and then to select the smaller figure. By direct calculation we see that
50 / 5 50 / 52 10 2 12
and so the highest power of 5 dividing 50! is 12. This means that 50! ends with 12 zeros.
63
Theorem 2: If n and r are positive integers with 1 r < n, then the binomial coefficient,
n n!
r r! n r !
is also an integer.
Proof. The argument rests on the observation that if a and b are arbitrary real numbers, then
a b a b. In particular, for each prime factor p of r!(n – r)!.
n r n r
pk pk pk k 1, 2,...
Adding these inequalities, we obtain
n r n r
p
k 1
k
k k (2)
k 1 p k 1 p
The left-hand side of Eq. (2) gives the exponent of the highest power of the prime p that
divides n!, where as the right hand side equals the highest power of this prime contained in
n!
r!(n – r)!. Hence, p appears in the numerator of at least as many times as it occurs
r ! n r !
in the denominator. Because this holds true for every prime divisor of the denominator, r!(n
– r)! must divide n!, making r!(n – r)! an integer.
Corollary 1: For a positive integer r, the product of any r consecutive positive integers is
divisible by r!.
Proof: The product of r consecutive positive integers, the largest of which is n, is
n n 1 ,..., n r 1 . We have
n!
n n 1 ,..., n r 1
r ! n r !
r!
Because n! / r!(n – r)! is an integer by Theorem 2, it follows that r! must divide the product
n(n – 1) … (n – r + 1), as asserted.
Having introduced the greatest integer function, let us see what it has to do with the study of
number- theoretic functions. Their relationship is brought out by Theorem 3.
Theorem 3: Let f and F be number theoretic functions such that
F n f d
d |n
64
Proof: We begin by noting that
N N
F n f d
n 1 n 1 d |n
(3)
The strategy is to collect terms with equal values of f(d) in this double sum. For a fixed
positive integer k N , the term f(k) appears in f (d ) if and only if k is a divisor of n.
d |n
(Because each integer has itself as a divisor, the right hand side of eq(3) includes f(k), at least
once). Now, to calculate the number of sums f (d ) in which f(k) occurs as a term, it is
d |n
sufficient to find the number of integers among 1, 2,…,N, which are divisible by k. There are
exactly [N / k] of them:
N
k , 2k , 3k ,..., k .
k
Thus, for each k such that 1 k N , f k is a term of the sum f (d ) for [N / k] different
d |n
positive integers less than or equal to N. Knowing this, we may rewrite the double sum in eq
(3) as
N N
N
f d f k k
n 1 d |n k 1
Proof. Noting that (n) = 1 , we may write for F and take f to be the constant function
d |n
N N
N
Corollary 3: If N is a positive integer, then n n
n 1 n 1 n
These last two corollaries, can perhaps, be clarified with an example,
Example 2: Consider the case N = 6. The definition of tells us that
6
n 14
n 1
6
6
From Corollary 2, n 6 3 2 3 / 2 6 / 5 1 6 3 2 1 1 1 = 14,
n 1
65
as it should. In the present case, we also have
6
n 33
n 1
Now gcd(m, n) = d if and only if gcd(m /d , n /d) =1. Thus, the number of integers in the class
Sd is equal to the number of positive integers not exceeding n /d that are relatively prime to
n /d; in other words, equal to (n /d). Because each of the n integer in the set {1, 2,…,n} lies
in exactly one class Sd, we obtain the formula.
n
n
d /n d
These contain (10) = 4, (5) = 4, (2) = 1, and (1) = 1 integers, respectively, Therefore,
66
d 10 5 2 1 4 4 1 1 10
d /10
We should mention in passing that there is another interesting identity that involves the phi-
function.
Theorem 5: For n > 1, the sum of the positive integers less than n and relatively prime to n is
1
n n .
2
Proof: Let a1, a2 ,…, a(n) be the positive integers less than n and relatively prime to n. Now
because gcd(a, n) =1 if and only if gcd(n – a, n) = 1, the numbers n – a1, n – a2 ,…, n – a(n)
are equal in some order to a1, a2 ,…, a(n). Thus,
a1+a2+ … + a(n) = (n – a1) + (n – a2) + … + (n – a(n)) = (n)n – (a1+a2+ … +a(n)).
Hence 2(a1+a2 + … + a(n)) = (n)n leading to the stated conclusion.
Example 4: Consider the case when n = 30. The (30)=8 integers that are less than 30 and
relatively prime to it are 1, 7, 11, 13, 17, 19, 23, and 29.
In this setting, we find that the desired sum is
1
1+7+11+13+17+19+23+29=120= 30 8
2
Also note the pairings
1 + 29 = 30 7 + 23 = 30 11 + 19 = 30 13 + 17 = 30
This is a good point at which to give an application of the Mobius inversion formula.
Theorem 6: For any positive integer n
d
n n
d |n d
Proof: The proof is deceptively simple. If we apply the inversion formula to
F n n d
d |n
the result is
n n
n d F d .
d |n d d
d |n
Let us again illustrate the situation where n = 10. As easily can be seen
d 2 5 10
10 10 1
d |n d 2 5 10
1 1 12 1 1 1 2
10 1 10 1 10. 4 10
2 5 10 2 5 10 5
67
Starting with Theorem 6, it is an easy matter to determine the value of the phi-function for
any positive integer n. Suppose, that the prime power decomposition of n is n = p1k1 p2k2 ... prkr ,
and consider the product
pi pik
i
P n 1
pi |n pi piki
Multiplying this out, we obtain a sum of terms of the form
1 p1a p2a .... pra
1 2 r
a1 a2 ar
0 ai ki
p p
1 2 p r
(d )
where the summation is over the set of divisors d p1a1 p2a2 ... prar of n. Hence P .
d |n d
It follows from Theorem 6 that
d pi pik i
n n n 1 .
d pi |n pi piki
d |n
But piai 0 , whenever ai 2. As a result, the last-written equation reduces to
pi 1
n n 1 n 1
pi |n pi pi |n pi
which agrees with the formula established earlier by different reasoning. What is significant
about this argument is that no assumption is made concerning the multiplicative character of
the phi-function, only of .
6.3. Summary
In this chapter we have studied greatest integer function which is also called bracket function
and some properties of Euler’s Phi function.
6.4. Keywords
Greatest integer function, phi function.
6.5. Exercises
1. Find the highest power of 7 dividing 1000! and highest power of 5 dividing 500!
2. For any integer n ≥ 0, show that [n / 2] – [–n / 2] = n.
3. For n ≥ 1 and p is a prime, prove that (2n)! / (n!)2 is an even integer.
68
4. Let x and y be real numbers. Then prove that
a. [x + n] = [x] + n, for any integer n
b. [x] + [–x] = 0 or –1 according as x is an integer or not
c. [x + y] ≤ [x] + [y].
5. Find an integer n ≥ 1 such that the highest power of 5 contained in n! is 100.
2 (d ) n
6. For a positive integer n, prove that
d |n ( d )
(n)
.
n
7. Verify the formula (d )[n / d ] n(n 1) / 2 for any positive integer n.
d 1
6.6. References
69
UNIT – 7
APPLICATIONS TO CRIPTOGRAPHY
Structure:
7.0. Objective
7.1. Introduction
7.2. Cryptography
7.3. Affine, Vigenere and Hill ciphers
7.4. RSA Public-key cryptosystem
7.5. Summary
7.6. Keywords
7.7. Exercises
7.8. References
7.0. Objective
The objective of this chapter is to study a very important application of number theory to
cryptography. We will study some simple cryptosystems and also cryptanalyze them. Also
we see that how RSA cryptosystem leads to the study of another important mathematical
problem “Factorization”.
7.1. Introduction
The proliferation of computers and communication systems in the 1960s brought with it a
demand from the private sector for means to protect information in digital form and to
provide security services. In this age of universal electronic connectivity, of viruses and
hackers, of electronic eavesdropping and electronic fraud, there is indeed no time at which
security does not matter. Two trends have come together to make the topic of vital interest.
First, the explosive growth in computer systems and their interconnections via networks has
increased the dependence of both organizations and individuals on the information stored and
communicated using these systems. This, in turn, has led to a heightened awareness of the
need to protect data and resources from disclosure, to guarantee the authenticity of data and
messages, and to protect systems from network-based attacks. Second, the disciplines of
cryptography and network security have matured, leading to the development of practical,
readily available applications to enforce network security.
70
Security attacks : The following figure shows 4 types of typical security attacks.
71
7.2. Cryptography
→ →
Any such set-up is called a cryptosystem.
The first step in inventing a cryptosystem is to “label” all possible plaintext message
units and all possible ciphertext message units by means of mathematical objects from which
functions can be easily constructed. These objects are often simply the integers in some
range. For example,if our plaintext and ciphertext message units are single letters from the
26- letter alphabet A-Z, then we can label the letters using the integers 0, 1, 2,…, 25, which
we call their “numerical equivalents”. Thus, in place of A we write 0, in place of S we write
18, in place of X we write 23, and so on. As another example, if our message units are
digraphs in the 27- letter alphabet consisting of A-Z and a blank, we might first let the blank
have numerical equivalent 26 (one beyond Z), and then label the digraph whose two letters
correspond to x, y { }.
Thus, we view the individual letters as digits to the base 27 and we view the digraph as a
2-digit integer to that base. For example, the digraph “NO” corresponds to the integer 27. 13
+ 14 = 365. Analogously, if we were using trigraphs as our message units, we could label
72
them by integers 729x+27y+z { } In general, we can label blocks of k letters
in an N-letter alphabet by integers between 0 and N k – 1 by regarding each such block as a k-
digit integer to the base N.
Examples. Let us start with the case when we take a message unit (of plaintext or of
ciphertext) to be a single letter in an N-letter alphabet labeled by the integers 0, 1, 2,…, N – 1.
Then, by definition, an enciphering transformation is a rearrangement of those N integers.
To facilitate rapid enciphering and deciphering, it is convenient to have a relatively
simple rule for performing such a rearrangement. One way is to think of the set of integers
{ } as Z/NZ, and make use of the operations of addition and multiplication
modulo N.
Suppose we are using the 26–letters alphabet A – Z with numerical equivalents 0 –
25. Let the letter P { }, stand for a plaintext message unit. Define a function f
from the set { } to itself by the rule
f(P) = {
≥
In other words, f simply adds 3 modulo 26: f (P) The definition using
modular arithmetic is easier to write down and work with. Thus, with this system, to encipher
the word “YES” we first convert to numbers: 24 4 18, then add 3 modulo 26: 1 7 21, then
translate back to letters: “BHV.” To decipher a message, one subtracts 3 modulo 26. For
example, the ciphertext “ZKB” yields the plaintext, “WHY.” This cryptosystem was
apparently used in ancient Rome by Julius Caesar, who supposedly invented it himself.
The above example can be generalized as follows. Suppose we are using an N-letter
alphabet with numerical equivalent 0, 1,··· , N – 1. Let b be a fixed integer. By a shift
transformation we mean the enciphering function f defined by the rule C = f (P) P + b mod
N. Julius Caesar’s cryptosystem defined by the rule C = f (P) P + b mod N. Julius
Caesar’s cryptosystem was the case N = 26, b = 3. To decipher a ciphertext message unit C
{ } we simply compute P = f -1(C) Here b is the encryption
key and is usually deonated by e and N – b is the decryption key and is denoted by d.
Definition 2: A cryptosystem is called a block cipher if its plaintext space and its ciphertext
space are the set all possible message units of a fixed length n. The block length n is a
positive integer. A simple example of a block cipher is the Caesar cipher. It has block length
1. In general, block ciphers with block length 1 are called substitution ciphers.
73
Symmetric and Asymmetric Cryptosystems
We briefly explain the difference between symmetric and asymmetric cryptosystems.
If Veena wants to send an encrypted message to Varun, then she uses an encryption key e and
Varun uses the corresponding decryption key to recover the plaintext. If in a cryptosystem
the encryption key e is always equal to the decryption key d, or if d can be easily computed
from e, then the cryptosystem is called symmetric. If Veena and Varun use a symmetric
cryptosystem, they must exchange the secret key e before they start their communication.
Secure key exchange is a major problem. The key e must be kept secret since anybody who
knows e can determine the corresponding decryption key d. The Caesar cipher is an example
of a symmetric cryptosystem. The keys for encryption and decryption are equal in this
system.
In asymmetric cryptosystems, the keys d and e are distinct, and the computation of d
from e is infeasible. In such systems, the encryption key can be made public. If Varun wants
to receive encrypted messages, he publishes an encryption key e and keeps the corresponding
decryption key d secret. Anybody can use e to encrypt messages for Varun. Therefore, e is
called the public key. But only Varun can decrypt the messages, so d is called the private key.
Asymmetric cryptosystems are also called public-key cryptosystems.
To make attacks on cryptosystems more difficult, one can keep the cryptosystem
secret. However, it is not clear how much security is really gained in this way because an
attacker has many ways of finding out which cryptosystem is used. He can try to tell from
intercepted ciphertexts which system is used. He can also try to get information from people
who have information about the encryption scheme in use. Modern cryptanalysis therefore
assumes that an attacker knows which cryptosystern is used. Only the (private) keys and the
plaintexts are assumed to be secret. The attacker tries to recover plaintexts from ciphertexts
or even tries to find out which keys are used. There are the following types of attacks:
Ciphertext-only attack. The attacker knows ciphertexts and tries to recover the
corresponding plaintexts or the key.
74
Known-plaintext attack: The attacker knows a plaintext and the corresponding
ciphertext or several such pairs. He tries to find the key used or to decrypt other
ciphertexts.
Chosen-plaintext attac:. The attacker is able to encrypt plaintexts but does not know
the key. He tries to find the key used or to decrypt other ciphertexts.
Adaptive chosen-plaintext attack: The attacker is able to encrypt plaintexts. He is
able to choose new plaintexts as a function of the ciphertexts obtained but does not
know the key. He tries to find the key used or to decrypt other ciphertexts.
Chosen-ciphertext attack: The attacker can decrypt but does not know the key. He
tries to find the key.
There are many ways to mount these attacks. A simple ciphertext-only attack consists
of decrypting the ciphertext with all possible keys. This attack is called exhaustive search.
The correct plaintext is among the few sensible texts that the attacker obtains. Given the
speed of modern computers, this attack is successful for many cryptosystems. It works, for
example, for the DES (Data Encryption Standard) system, which until recently was the U.S.
encryption standard. A known-plaintext attack may use the statistical properties of the
plaintext language. For example, if we apply the Caesar cipher, then for a fixed key any
plaintext symbol is replaced by the same ciphertext symbol. The most frequent plaintext
symbol is encrypted to the most frequent ciphertext symbol. Since we know the most
frequent symbol of the plaintext language, we have a good guess how to decrypt the most
frequent ciphertext symbol. Analogously, the frequency of other individual symbols, of pairs,
triplets, etc., in the plaintext may be reflected in the ciphertext and can be used to decrypt the
ciphertext or to recover the key.
Let us cryptanalyse the the Caesar cipher. The most frequently occurring letter in the
ciphertext correspond to those in the plaintext. For example, E is the most frequently
occurring letter in an arbitrary text, occurring about 12.5% of the time; the next three letters
are T, A, and O, occurring about 9%, 8%, and 8% of the time, respectively.
Consider the ciphertext message:
SLABZ ULCLY ULNVA PHALV BAVMM LHYIB
ASLAB ZULCL YMLHY AVULN VAPHA L
The most frequently occurring letter in the ciphertext is L, so our best guess is that it must
correspond to the plaintext letter E. Since their ordinal numbers are 11 and 4, this implies
; that is, k = 7. Then . Using this congruence, we
75
can determine the ordinal number of each letter in the plaintext. After obtaining the ordinal
number of each plaintext letter, the plaintext message reads as
LET US NEVER NEGOTIATE OUT OF FEAR BUT LET US NEVER FEAR TO
NEGOTIATE
where a is a positive integer ≤ 25 and (a, 26) = 1. Since (a, 26) = 1, inverse of a exists and so
.
Since (a, 26) = 1, there are = 12 choices for a, so there are 12·26 = 312 affine ciphers.
One of them is the identity transformation corresponding to a = 1 and k = 0.
When a = 5 and k = 11, . If P = 8, then ∙
, so under the affine cipher , the letter I is transformed into
Z and letter Q into N. Table shows the plaintext letters and the corresponding ciphertext
letters created by this affine cipher, which shifts A to L and in which each successive letter is
paired with every fifth letter.
Plaintext A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
letter
00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
Ciphertext 11 16 21 00 05 10 15 20 25 04 09 14 19 24 03 08 13 18 23 02 07 12 17 22 01 06
letter
L Q V A F K P U Z E J O T Y D I N S X C H M R W B G
Hence, under the above affine transformation, the plaintext message THE MOON IS MADE
OF CREAM CHEESE will be transformed into THEMO ONISM ADEOF CREAM CHEES
E (grouping into 5 letters).
To decipher the message, we use the congruence
.
Let us cryptanalyze the ciphertext BYTUH NCGKN DUBIH UVNYX HUTYP QNGYV
IVROH GSU that was generated by an affine cipher.
First make the frequency analysis of the letters in the ciphertext. According to it U
occurs 5 times, H, N, and Y occurs 4 times each. It is reasonable to assume that the letter U
corresponds to the letter E in the plaintext message, that is, . If we
assume H corresponds to T, then . Solving this linear system, we get
76
, so . But (13, 26) ≠ 1, so
this is not a valid cipher. Thus, our guess that H corresponds to T was not a valid one.
So let us assume that N corresponds to T. This yields the linear system
and . Solving this system,
. Since (3, 26) = 1, this yields a valid cipher
.
Ciphertext A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
letter
00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
Plaintext 06 15 24 07 16 25 08 17 00 09 18 01 10 19 02 11 20 03 12 21 04 13 22 05 14 23
letter
G P Y H Q Z I R A J S B K T C L U D M V E N W F O X
Using this table, we can translate the given ciphertext message as POVER TYIST HEPAR
ENTOF REVOL UTION ANDCR IME, that is, POVERTY IS THE PARENT OF
REVOLUTION AND CRIME.
For example, using the keyword CIPHER and a Vigenere cipher, let us encrypt the message
CRYPTOGRAPHY IS FUN. Since the ordinal numbers of the letters C, I, P, H, E, and R are
02, 08, 15, 07, 04 and 17, respectively, they serve as the shift factors for each shift cipher for
every block. So the six shift ciphers are , where k = 2, 8, 15, 7, 4 and
17.
Since the keyword is a six-letter word, first we group the letters of the plaintext into
blocks of length six: CRYPTO GRAPHY ISFUN.
Now apply the ith cipher to the letter wi in each block, where 1 ≤ i ≤ n. For instance,
consider the first CRYPTO. Since the ordinal number are 02, 17, 24, 15, 19 and 14,
respectively, add to them the key values 2, 8, 15, 7, 4 and 17 in that order modulo 26. The
resulting numbers are 4, 25, 13, 22, 23 and 4, and the corresponding letters are E, Z, N, W, X,
and F, respectively, so the first ciphertext block is EZNWXF. Thus the resulting ciphertext is
EZNWXF IZPWLP KAUBR.
77
Hill Cipher: The above cryptosystems are very weak in the sense they can be easily
cryptanalyzed. Let us try block ciphers of length 2 and they are called digraphs. In such a
system, we group the letters of the plaintext into blocks of length 2, adding a dummy letter X
at the end, if necessary, to make all blocks of the same length, and then replace each letter
with its ordinal number. Each plaintext block P1P2 is then replaced by a numeric ciphertext
block C1C2, where C1 and C2 are different linear combinations of P1 and P2 modulo 26:
(1)
where (ad – bc, 26) = 1. This condition is necessary to uniquely solve the linear system of P1
and P2. Then we translate each number into a ciphertext letter, the resulting text is the
ciphertext.
The following example illustrates this algorithm.
Using the 2 x 2 linear system
. (2)
encipher the message SLOW AND STEADY WINS THE RACE.
SOLUTION
Step 1 Assemble the plaintext into blocks of length two:
SL OW AN DS TE AD YW IN ST HE RA CE
Step 2 Replace each letter by its cardinal number:
18 11 14 22 00 13 03 18 19 04 00 03
24 22 08 13 18 19 07 04 17 00 02 04
Step 3 Using the linear system (2), convert each block into a ciphertext numeric block:
When P1 = 18 and P2 = 11, we have
So the first block 18 11 is converted into 25 18. Transforming the other blocks in a similar
fashion yields the numeric string.
25 18 18 22 13 00 15 21 17 25 13 02
16 00 01 24 25 06 09 15 07 25 10 00
Step 4 Translate the numbers into letters.
The resulting ciphertext is ZS SW NA PV RZ NC QA BY ZG JP HZ KA.
78
Matrices are useful in the study of Hill cryptosystems. For example, that the linear system
can be written as
[ ] [ ][ ] .
inverse [ ] modulo 26. So the deciphering procedure can be effected using the
congruence
[ ] [ ][ ] (3)
[ ] [ ][ ] [ ]
It is obvious from the preceding two examples that the size of a block can be any size
n ≥ 2, and that the enciphering and deciphering tasks can be accomplished by choosing an
nxn enciphering matrix A modulo 26 such that (|A|, 26) = 1, where |A| denotes the
determinant of A. Let P1, P2, …, Pn be the ordinal numbers of an arbitrary plaintext block
and C1, C2, …, Cn the corresponding ciphertext numbers. Let
[ ] [ ].
79
Let M be the message to be sent where M is a positive integer less than and relatively
prime to n. If we keep M less than both p and q,then we will be safe. In practice, if is enough
to keep M less than n for the probability than a random M is divisible by p or q is so small as
to be negligible. A plaintext message is easily converted to a number by using, say,
Blank = 99, A = 10, B = 11, , Z = 35,
So that HELLO becomes 1714212124. If necessary, the message can be broken into blocks of
smaller messages:
17142 12124.
The encoder computes and sends the number E = M e MOD n.
which we know from Algorithm 3.3 can be done very quickly. To decode, we simply
compute
Ed MOD n.
By Theorem 3.4 and our equation (4.1) we have that
Ed (Me)d Me x d M(multiple of ϕ(n)) + 1 (mod n)
1xM M (mod n).
d
Since M and E MOD n both lie between 0 and n, they must be equal.
If e has been chosen relatively prime to , then we know that there exists d,
uniquely such that
e×d 1 (mod .
As we shall prove later in this chapter, if we know the factorization of n, namely n = p x q
where p and q are distinct primes, then we can easily compute by
= (p – 1) x (q – 1).
There is no simpler way of computing . In fact, knowing ϕ (n) equivalent to knowing the
factorization becase we can find p + q:
and the p – q is
√ √
√ ,
and finally:
[ ] [ ]
The problem of finding d, the decryption key, has been reduced to find the factorization of n.
For this example, the keys were generated as follows:
1. Select two prime numbers, p = 17 and q = 11.
2. Calculate n = pq = 17 × 11 = 187.
80
3. Calculate = (p – 1)(q – 1) = 16 × 10 = 160.
4. Select e such that e is relatively prime to = 160 and less than ; we choose e = 7.
5. Determine d such that de 1 (mod 160) and d < 160.
The correct value is d = 23, because 23 × 7 = 161 = (1 × 160) + 1; d can be calculated
using the extended Euclid’s algorithm. The resulting keys are public key PU = {7, 187} and
private key PR = {23, 187}. The example shows the use of these keys for a plaintext input of
M= 88.
For encryption, we need to calculate C = 887 mod 187. Exploiting the properties of
modular arithmetic, we can do this as follows:
887 mod 187 = [(884 mod 187) × (882 mod 187) × (881 mod 187)] mod 187
881 mod 187 = 88
882 mod 187 = 7744 mod 187 = 77
884 mod 187 = 59,969,536 mod 187 = 132
887 mod 187 = (88 × 77 × 132) mod 187 = 894,432 mod 187 = 11
For decryption, we calculate M = 1123 mod 187:
1123 mod 187 = [(111 mod 187) × (112 mod 187) × (114 mod 187) × (118 mod 187) × (118
mod 187)] mod 187
111 mod 187 = 11
112 mod 187 = 121
114 mod 187 = 14,641 mod 187 = 55
118 mod 187 = 214,358,881 mod 187 = 33
1123 mod 187 = (11 × 121 × 55 × 33 × 33) mod 187 = 79,720,245 mod 187 = 88
The Security of RSA
Four possible approaches to attacking the RSA algorithm are
• Brute force: This involves trying all possible private keys.
• Mathematical attacks: There are several approaches, all equivalent in effort to
factoring the product of two primes.
• Timing attacks: These depend on the running time of the decryption algorithm.
• Chosen ciphertext attacks: This type of attack exploits properties of the RSA
algorithm.
The defense against the brute-force approach is, to use a large key space. Thus, larger the
number of digits in d, the better. However, because the calculations involved, both in key
generation and in encryption/decryption, are complex, the larger the size of the key, the
slower the system will run.
81
THE FACTORING PROBLEM We can identify three approaches to attacking RSA
mathematically.
1. Factor n into its two prime factors. This enables calculation of = (p - 1) × (q - 1),
which in turn enables determination of d e-1 (mod .
2. Determine directly, without first determining p and q. Again, this enables
determination of d e-1 (mod ).
3. Determine d directly, without first determining .
7.5. Summary
In this chapter we studied several cryptosystems and how to cryptanalyse them. We note
here that in this generation of networking how important is to protect data from intruders.
7.6. Keywords
Computer, communication, cryptosystem, cryptanalysis, factorization, plaintext, ciphertext,
symmetric and asymmetric keys, enciphering and deciphering keys, encryption and
decryption, RSA cryptosystem.
7.7. Exercise
82
7 18 19
7. Using deciphering matrix 15 1 19 decipher the cipher text: ZTH QLJ MOA
17 17 0
NLG GPN EXA OCA QTY.
8. Using RSA enciphering key (e, n) = (11, 2867), encrypt each message SEAFOOD and
OPEN DOOR.
9. Each ciphertext below was generated by the RSA enciphering key (e, n) = (11, 2867).
Decipher each:
a. 1420 0614 1301 1694
b. 1959 1384 1174 2050
10. Let n = pq, where p and q are primes with p > q. Show that p + q = n – ϕ(n) + 1.
7.9. References
1. Elementary Number Theory, David M. Burton, McGraw Hill Publication
2. Elementary Number Theory with Applications, Thomas Koshy, Elsevier
3. A Course in Number Theory and Cryptography, Neal Koblitz, Springer
4. Elementary Methods in Number Theory, Melvyn B. Nathanson, Springer
5. Handbook of Applied Cryptography, A. Menezes, P. van Ooschot and S. Vanstone,
CRC Press, Inc.
83
UNIT – 8
8.0. Objective
8.1. Dirichlet product
8.2. Averages of Arithmetical Functions
8.3. The big O (oh) notatin
8.4. Euler’s Summation Formula
8.5. Some Elementary Asymptotic Formulas
8.6. The Average Order of d(n), 𝝈(n), and ϕ(n)
8.7. Summary
8.8. Keywords
8.9. Exercises
8.10. References
8.0. Objective
The objective of this chapter is to study Dirichlet product of arithmetical functions and also
asymptotic behavior of arithmetical functions.
Definition 1: If f and g are two arithmetical functions we define their Dirichlet product to be the
arithmetical function h defined by the equation
n
( f * g )(n) h(n) f (d ) g
d /n d
Theorem 1: Dirichlet multiplication is commutative and associative
where a and b vary over all positive integers whose product is n. This definition of Dirichlet
product clearly shows product is commutative.
( f * A)(n )
ad n
f (a ) A d
ad n
f (a ) g ( b) k ( c )
bc d
abc n
f ( a ) g ( b)k ( c )
84
In the same way, if we let B = f * g and consider B * k we are led to the same formula for
(B * k)(n). Hence f * A = B * k which means that Dirichlet multiplication is associative.
1 1 if n 1
I (n)
n 0 if n 1
Proof: We have
n d
I (n ) f (d ) I f (d ) f ( n)
d |n d d |n n
Dirichlet inverses :
1 1 n
f 1 (1) , f 1 (n) f f 1 (d ) for n 1
f (1) f (1) d |n d
d n
Proof: Given f, we shall show that the equation f * f 1 (n) I (n) has a unique solution for
the function values f -1(n). For n = 1 we have to solve the equation
f * f (1) I (1)
1
which reduces to
f (1) f 1 (1) 1
1
Since f(1) ≠ 0 there is one and only one solution, namely f (1) 1/ f (1). Assume now that the
1
function values f (k ) have been uniquely determined for all k < n. Then we have to solve the
equation f * f 1 (n) I (n) , or
n
f d f d 0
d |n
1
85
1
If the values f (d ) are known for all divisors d < n, there is a uniquely determined values for
f 1 (n), namely
1 n 1
f 1 (n ) f
f (1) d |n
f d ,
d
d n
m n
f (a ) g f (b) g h(m)h(n ).
a|m a b|n b
This completes the proof.
86
1. If mn = 1 then f(1) ≠ f(1)f(1) so f(1) ≠ 1. Since h(1) = f(1)g(1) = f(1) ≠ 1, this shows that h
is not multiplicative.
2. If mn > 1, then we have f(ab) = f(a)f(b) for all positive integers a and b with gcd(a, b) = 1
and ab < mn. Now, we argue as in the proof of Theorem 4, except that in the sum defining
h(mn) we separate the term corresponding to a = m, b = n.
We then have
mn m n
h(mn ) f ab g ab f (mn) g (1)
a|m a|m
f (a ) f (b) g g f (mn )
a b
b|n b|n
ab mn ab mn
m n
f (a ) g f (b) g f (m) f (n ) f (mn )
a|m a b|n b
h(m)h( n ) f (m) f (n ) f (mn ).
Since f(mn) ≠ f(m)f(n) this shows that h(mn) ≠ h(m)h(n) so h is not multiplicative.
Proof: This follows at once from Theorem 5 since both g and g * g-1 = I are multiplicative.
will prove later that the average d (n ) grows like log n for large n; more precisely,
d (n)
lim 1 (1)
n log n
87
To study the average of an arbitrary function f we need a knowledge of its partial sums
n
f (k ) .
k 1
Sometimes it is convenient to replace the upper index n by an arbitrary positive real
Here it is understood that the index k varies from 1 to [x], the greatest integer ≤ x. If 0 < x < 1
the sum is empty and we assign it the value 0. Our goal is to determine the behavior of this
sum as a function of x, especially for large x.
For the divisor function we will prove a result obtained by Dirichlet in 1849, which is
stronger than (1), namely
d (k ) x log x (2C 1) x O(
k n
x) (2)
constant times x . This is an example of the “big oh” notation which is defined as follows.
An equation of the form f(x) = g(x) + O(g(x)) means that f(x) – g(x) = O(g(x)). We note that
f ( x)
Definition 5: If lim 1 we say that f (x) is asymptotic to g(x) as x →∞, and we write
x g ( x)
f (x) ~ g(x) as x →∞.
In equation (2) the term xlogx is called the asymptotic value of the sum; the order two terms
represent the error made by approximating the sum by its asymptotic value. If we denote this
error by E(x), then (2) states that
E ( x) (2C 1) x O( x ). (4)
This could also be written E(x) = O(x), an equation which is correct but which does not convey
the more precise information in (4). Equation (4) tells us that the asymptotic value of E(x) is
(2C – 1)x.
88
8.4. Euler’s Summation Formula
Sometimes the asymptotic value of a partial sum can be obtained by comparing it with an
integral. A summation formula of Euler gives an exact expression for the error made in such an
approximation. In this formula [t] denotes the greatest integer ≤ t.
Theorem 7: If f has a continuous derivative f on the interval [y, x], where 0 < y < x, then
x x
f (n) f (t )dt (t [t ]) f (t )dt f ( x )([ x ] x ) f ( y )([ y ] y ) (5)
y y
y n x
=kf ( k ) mf ( m)
y n x
f ( n),
hence
k
f (n ) [t ] f (t )dt kf (k ) mf (m)
m
y n x
x
= [t ] f (t )dt kf ( x ) mf ( y ). (6)
y
1 x1 s
( s) lim if 0 s 1.
x
n s 1 s
89
Theorem 8: If x ≥ 1 we have:
1 1
(a) n log x C O x .
n x
x1s
( s) O x s if s 0, s 1.
1
(b)
n x n
s
1 s
1
(c) s O x1s if s 1.
n x n
x 1
(d) O x if 0.
n
n x 1
Proof: For part (a) we take f (t) = 1/t in Euler’s summation formula to obtain
1 dt x t [t ] x [ x]
n
x
2
dt 1
n x
1 t 1 t x
x t [t ] 1
log x dt 1 O
x
2
1 t
t [t ] t [t ] 1
log x 1 dt dt O .
x
2 2
1 t x t
t [t ] 1
Since t – [t] ≤ 1, the improper integral 1 t2
dt exists since 1 t2
dt converges. Also,
t [t ] 1 1
0 2
dt 2 dt
1 t 1 t x
so the last equation becomes
1 t [t ] 1
n log x 1
n x
1 t 2
dt O .
x
This proves (a) with
t [t ]
C 1 dt .
1 t2
Letting x → ∞ in (a) we find that
1 t [t ]
lim log x 1 dt ,
x
n x n 1 t2
so C is also equal to Euler’s constant.
To prove part (b) we use the same type of argument with f(x) = x–s, where s > 0, s ≠ 1. Euler’s
summation formula gives us
1 dt x t [t ] x [ x]
n
x
s
s
s s 1
dt 1
n x
1 t 1 t x
x1 s 1 t [t ] 1
1 s s 1
dt O s .
1 s s 1 1 t x
1 x1 s
Therefore
n x n
s
1 s
C ( s) O( x s ), (7)
90
1 t [t ]
Where C ( s) 1 s dt.
s 1 1 t s 1
If s > 1, the left member of (7) approaches ζ(s) as x → ∞ and the terms s1–s and x–s both approach
0. Hence C(s) = ζ(s) if x > 1. If 0 < x < 1, x–s → 0 and (7) shows that
1 x1 s
lim s C ( s).
x
n x n 1 s
Therefore C(s) is also equal to ζ(s) if 0 < s < 1. This proves (b).
=
x 1
1
1 1
x
O t 1dt O ( x )
1
x 1
= O( x ).
1
This is a double sum extended over n and d. Since d | n, we can write n = qd and extend the sum
over all pairs of positive integers q, d with qd ≤ x. Thus
d (n) 1.
n x q ,d
(9)
qd x
(A lattice point is a point with integer co-ordinates). The lattice points with qd = n lie on a
hyperbola, so the sum in (9) counts the number of lattice points which lie on the hyperbolas
corresponding to n = 1, 2, …, [x]. For each fixed d ≤ x we can count first those lattice points
on the horizontal line segment 1≤ q ≤ x / d, and then sum over all d ≤ x. Thus (9) becomes
d (n) 1.
n x d x q x / d
(10)
91
Now we use Theorem 2 (d) with α = 0 to obtain
x
1 d O(1).
q x / d
x 1
d (n) d O(1) x d O( x)
n x d x d x
x log x C O ( x ) O ( x ) x log x O ( x ).
1
d (n)
n x
x log x x
To prove the more precise formula (8) we return to the sum (9) which counts the number of
lattice points in a hyperbolic region and take advantage of the symmetry of the region about
the line q = d. The total number of lattice points in the region is equal to twice the number
below the line q = d plus the number on the bisecting line segment. Therefore,
x
d (n) 2 d d O(1) O(
n x
x)
d x
1
2x 2 d O( x )
d x d d x
x
2
2 x log x C O ( x 1/2 ) 2 O ( x ) O ( x )
x log x (2C 1) x O ( x ).
1
(n) 2 (2) x
n x
2
O( x log x ). (11)
2
Note: It can be shown that (2) . Therefore (11) shows that the average order of σ(n)
6
2n
is .
12
Proof: The method is similar to that used to derive the weak version of Theorem 3. We have
92
(n) q q q
n x n x q|n q ,d d x q x /d
qd x
1 x 2 x x
2
1 1
O 2 O x
d x 2 d d 2 d x d d x d
x 2 1 1 1
(2) O 2 O ( x log x ) (2) x O ( x log x ),
2
2 x x 2
The asymptotic formula for the partial sums of Euler’s totient involves the sum of the series
(n)
n 1 n
2
.
This series converges absolutely since it is dominated by n 1
n 2 . It can be proved that
(n) 1 6
n 1 n 2
2.
(2)
(12)
(n)
(n ) (n )
n x n 2
n 1 n 2
n x n2
6 1 6
O 2 2 O ( x 1 )
2
n x n
by part (c) of Theorem 2. We now use this to obtain the average order of ϕ(n).
3n
so the average order of ϕ(n) is .
2
n
Proof: We have (n) (d ) .
d |n d
Therefore
n
(n) (d ) d (d )q (d ) q
n x n x d |n q ,d d x q x /d
qd x
1 x
2
x
x2 (d ) 1
(d ) O 2 O x
d x 2 d
d
2 d x d d x d
x2 6 1 3 2
2 O O ( x log x ) 2 x O ( x log x ).
2 x
93
8.7. Summary
In this chapter we introduced Dirichlet product and studied some properties of Dirichlet
product. Also we studied asymptotic behavior of some arithmetical functions.
8.8. Keywords
9. Dirichlet product, asymptotes, average order.
8.9. Exercises
1 1
b. log(log x ) B O , where B is a constant
2 n x n log n x log x
4. If x ≥ 2, prove that
d (n) 1
n x n
log2 x 2C log x O 1 , where C is Euler’s constant.
2
8.10. References
94
BLOCK – III
PRIMITIVE ROOTS
&
QUADRATIC RECIPROCITY LAW
95
UNIT – 9
ORDER OF AN INTEGER MODULO N, PRIMITIVE ROOTS FOR PRIMES
Structure:
9.0. Objective
9.1. Order of an integer modulo n
9.2. Primitive Root
9.3. Primitive roots for primes
9.4. Summary
9.5. Keywords
9.6. Exercises
9.7. References
9.0. Objective
Gauss defined primitive roots in his book Disquisitions Arithmeticae (1801), where he credited
Euler coining the term. Primitive roots are often used in Cryptography. In this chapter we study
two important concepts: the order of an element a and the primitive root modulo m. Also, we
will then identify those positive integers that possess primitive roots and study some interesting
applications.
96
Example 2: The order of 7 mod 13 is 12.
Consider
.
Theorem 1: Let an integer a has order h modulo m that is . Then the following
holds:
(i) If , for some integer k then h | k.
(ii) If , then b has order h modulo m.
(iii) if and only if .
Proof of (i) : By the definition of order of a , we have k ≥ h. Also by division algorithm
integers q and r such that
Consider .
[
Hence . This is a contradiction if Hence
r = 0.
Proof of (ii) : Let Then for any positive integer t, . This
implies
Proof of (iii): Consider where i and j are positive integers. Suppose i > j.
Then . By (i) we have
Note: By (iii) we have are mutually incongruent modulo m.
Theorem 2: If a has order h modulo m, then has order , where d = gcd(h, k).
( ) (1)
Consider . Hence
( ) (2)
97
From (1) and (2) and since t and are positive t = . This completes the proof.
.
Example 4: We show that every odd prime divisor of is of the form 4k + 1.
Also we show that every odd prime divisor of is of the form 8k + 1.
Given where p is an odd prime. Hence This implies
. This implies for some integer k.
Similarly, we can prove the other result.
98
Let a1, a2, …, is a reduced residue system modulo m. Let r be an integer coprime
to m. Then (r, m) = 1 and
for some unique j, . (3)
Hence, for each k, , there exist a unique t such that Thus
for some unique h, . Hence
. (4)
Hence from (3) and (4) 1, a, a2, …, is a RRS mod m.
Proof of (ii) and (iii) : If a is a primitive root modulo m, then { } is a reduced
residue modulo m. Hence if b is any other primitive root modulo m, then there exists a unique k,
such that such that
By Carollary 1, is primitive root if (k, ) = 1. Thus there are ( ) such k exists.
Hence there are ( ) primitive roots modulo m.
Example 7: If 5 is a primitive root modulo 54, then we find the remaining incongruent primitive
roots.
Solution: By above result, 54 has ( ) primitive roots mod 54. Hence 54 has
( ) 6 primitive roots. Since 5 is a primitive root, the remaining roots are of
the form 5k with (k, 18) = 1. Hence, the positive integers < 18 and relatively prime to 18 are 1,
5, 7, 13 and 17. Therefore, primitive roots are 51, 55, 57, 511 and 513 mod 54 i.e, 5, 47, 41, 29, 23,
and 11 respectively. Thus, the remaining primitive roots are 11, 23, 29, 41 and 47.
99
Clearly if then and hence β is also a solution of
. For example, consider . It has two
incongruent solutions, namely 4 and 10.
Theorem 4: [Lagrange's theorem] Given a prime p, let f(x) = a0 + a1x + … + anxn; ai Z be a
polynomial of degree n such that (mod p): Then the polynomial congruence f(x) 0
(mod p) has at most n solutions.
Proof: We prove this theorem by induction. Since (mod p), the equation a1x + a0 0
(mod p) has a unique solution. Thus, the theorem is true for n = 1. Suppose that the theorem is
true for polynomials of degree n – 1. Assume, also, that the equation
a0 + a1x + … + an xn 0 (mod p); (mod p)
has n + 1 incongruent solutions mod p; say x0, x1, … , xn: We have
∑
where degree of g(x) is n – 1 and the leading coefficient of g(x) is cn which is (mod p). We
observe that for every 1 ≤ k ≤ n, f(xk) f(x0) (mod p).
Thus, f(xk) – f(x0) = (xk – x0) g(xk) 0 (mod p).
Since xk and x0 are incongruent (mod p), we get g(xk) 0 (mod p)
for every 1 ≤ k ≤ n. Thus, g(x) 0 (mod p) has n incongruent solutions (mod p), which
contradicts our induction hypothesis that it can have at most n – 1 solutions. Therefore,
a0 + a1x + … + an xn 0 (mod p); (mod p)
has at most n solutions. By induction, we have proved the result for all n ≥ 1.
Corollary 2: If p is a prime number and d | p – 1, the congruence
100
Theorem 5: If p is a prime number and d | p – 1, then there are exactly incongruent
integers having order d mod p.
Proof: Let d | p – 1 and denote the number of integers k, with that have
order d mod p. Because each integer between 1 and p – 1 has order d for some d | p – 1,
d 1 2 3 6 9 18
1 1 2 2 6 6
1 1 2 2 6 6
9.5. Keywords
Order of an element, primitive root, polynomial, incongruent solution.
9.5. Exercises
1. Compute the order of 2 with respect to the prime moduli 3, 5, 7, 11, 13, 17, and 19.
2. Compute the order of 10 with respect to the modulus 7.
3. Find a primitive root modulo 23.
4. Find a primitive root modulo 41.
5. Prove that 2 is a primitive root modulo 101.
6. What is the order of 3 modulo 101? Is 3 a primitive root modulo 101?
7. Prove that 2 is a primitive root modulo 53.
8. Let g be a primitive root modulo the odd prime p. Prove that −g is a primitive root
modulo p if and only if p ≡ 1 (mod 4).
9. Suppose the exponent of an integer a modulo m is m – 1. Prove that m is a prime.
10. If a has order hk mod n, then prove that ah has order k modulo n.
11. If a has order n – 1 mod n, then n is a prime.
12. Show that the odd prime divisors of the integer n2 + n + 1 that are different from 3 are of
the form 6k + 1.
13. Prove that there are infinitely many primes of the form 4k + 1 and 8k + 1.
14. Let p and q be odd primes such that q | ap – 1. Then prove that either q | p – 1 or q =
2kp + 1 for some integer k.
15. Verify that each of the congruences x2 ≡ 1(mod 15) and x2 ≡ -1(mod 65) has four
incongruent solutions and hence Lagrange’s theorem need not hold if the modulus is a
composite number.
16. Determine all the primitive roots of the primes 11, 19 and 23.
102
17. Let r be a primitive root of the odd prime p. Prove the following:
a. If p ≡ 1(mod 4), then –r is also a primitive root of p
b. If p ≡ 3(mod 4), then –r has order (p – 1) / 2 mod p.
9.6. References:
103
UNIT –10
COMPOSITE NUMBERS HAVING PRIMITIVE ROOTS
Structure:
10.0. Objective
10.1. Composite Numbers Having Primitive Roots
10.2. Theory of Indices
10.3. Summary
10.4. Keywords
10.5. Exercises
10.0. Objective
In the last chapter, we saw that all the prime numbers have primitive roots. In this chapter, our
aim is to find all composite numbers which have primitive roots.
Similarly, 4 22 22 21 4 2 2 and 12 1 mod 4 and 32 1 mod 4 . This shows
that 3 is the primitive root of 4. Thus, 2 and 4 possess one primitive root each which are 1 and 3
respectively.
Theorem 2: Integer of the form 2n has no primitive root for n 3.
Proof: Let a be an odd integer. We will show that a 2 n2 1 mod 2n for n 3.
For n = 3 we have
a 2 1 mod 8
1 mod 2m
m2
a2
m2
This implies a 2 1 2m .
104
Consider,
m 1 2
1 2
m 1 m2 2
m 2
a2 a2 a2 1 2 2m 2 22 m
m 1
Therefore, a 2 1 2m1 2 22 m
1 2m1 2 2m1 2m1
1 mod 2m1 or a 2 1 mod 2m1 .
m 1 m 1 2
Therefore, a 2
This shows that the result is true for n = m+1. Hence, by mathematical induction the result is
true for all values of n.
Also, the integers relatively prime to 2m are the odd integers and 2m 2m1. Therefore
a (2 1 mod 2m and hence there is no primitive root of 2n.
m
)/2
Theorem 3: If m, n > 2 and gcd(m, n) = 1 then there exists no primitive root (mod mn).
Proof: Suppose, if possible a is a primitive root to mn. Then (a, mn) = 1 and a has order (mn)
(mod mn).
Now (a, mn) = 1 (a, m) = 1 and (a, n) = 1.
Let
m n
h (1)
d
m n mn
Hence, h (mn)
2 2
n
Now a a h
m
d
1 mod m (3)
m
and a a h
n
d
1 mod n (4)
From (3) and (4), we have a h 1 mod mn gcd m, n 1 . This contradicts the assumption
that order of a is (mn). This contradiction proves that mn has no primitive root.
105
Lemma 1: If p is an odd prime, then there exists a primitive root r of p such that
r p1 1 mod p 2 .
Proof: Since p is an odd prime it has a primitive root. Let r be a primitive root of p. If
r p1 1 mod p 2 then the proof is complete. If r p1 1 mod p 2 we replace r by r1 given by r1
r1 p 1 r p
p 1
r p 1 p 1 pr p 2 mod p 2
1 pr p 2 mod p 2 r p 1 1 mod p 2
Since r is a primitive root of p, we have (r, p) = 1. Therefore,
Corollary 1: If p is an odd prime then p2 has a primitive root. In other words for a primitive
root r of p, either r or r + p is a primitive root of p2.
Proof: If r is a primitive root of p, then the order of r modulo p2 is either p – 1 or p(p – 1) =
(p2). If r has order p – 1 modulo p2, then r + p is a primitive root of p2.
Lemma 2: If p is an odd prime and r a primitive root of p such that r p-1 1 mod p 2 , then for
each positive integer k 2, r p p-1
1 mod p k .
k -2
Proof: For k = 2 the result is true by the hypothesis. Let the result be true for k > 2. We shall
show that the result is true for k + 1.
Since gcd r, p k 1 gcd r, p k 1, by Euler s theorem we have,
1 mod p k 1 .
r
p k 2 p 1
r
pk 1
Therefore, there exists an integer a such that
p k 2 p 1
r 1 ap k 1 , p | a
1 ap k 1 1 ap k mod p k 1
p k 1 p 1 p
r
Since p | a, p k 1 | ap k . Hence
1 mod p k 1 .
k 1
( p 1)
rp
106
This shows the result is true for k + 1. Hence, by mathematical induction the given result will be
true for all values of k 2.
Theorem 4: There exists a primitive root for pk when p is an odd prime and k 1.
Proof: Let p be an odd prime. If k = 1 then there exists a primitive root (mod p). Suppose
k > 1. By Lemma 1 and 2 there exists a primitive r (mod p) such that
1 mod p k .
k 2
( p 1)
rp
In fact, any integer satisfying the condition r p 1 1 mod p 2 will do. We will show that r is a
we can write
1 mod p k .
k 2
( p 1)
rp
should divide 2 p k 2 p k p k . Now, r n 1 mod 2 p k r n 1 mod p k .
Therefore, p k | n and so n 2 p k . Hence r is a primitive root of 2pk.
107
We have 24 1 mod 15 , 44 1 mod 15 , 74 1 mod 15 , 84 1 mod 15 , 114 1 mod 15 ,
108
ii) Now, if r = indabc then bc ≡ ar (mod n). Therefore, r1 + r2 ≡ r (mod ϕ(n)) and hence
ind a bc ind ab ind a c(mod (n)).
iii) We have,
ind a bk =ind a (b b ... k times)
ind a b ind a b upto k times(mod ( n)) [using (ii)
=k inda a b(mod (n)).
iv) Putting k = 0 in (iii), we have
inda1 ≡ 0 (mod (n)).
Theorem 6: If r is the smallest primitive root of n and rh a (mod n) then h indra (mod n).
Proof: We have, r h a mod n a r indr a mod n . Now, order of r (mod n) is (n).
r ind.a1 a1 mod n
r ind.a2 a2 mod n
r ind.ak ak mod n .
Therefore,
r ind.a1 inda2 ind. ak
a1a2 ak mod n .
The theory of indices is applicable for the modulii having primitive roots. However, the table of
indices may be prepared for each modulus. The theory of indices can be used to solve the
congruences.
Theorem 8: The congruence
xk a(mod n) k 2
where n is a positive integer having a primitive root and gcd(a, n) = 1, has no solution if
d | ind a and exactly d incongruent solutions if d | ind a where d = gcd(k, (n)).
109
Proof: By properties ii) and iii) of Theorem 5, xk a(mod n) can be written as a linear
congruence
k ind x ind a(mod (n))
in the unknown ind x. Hence if d | ind a , there is no solution. But if d | ind a then there are
exactly d incongruent solutions.
Theorem 9: Let n be an integer possessing a primitive root and let gcd(a, n) = 1. Then the
congruence xk a(mod n) has a solution if and only if
a ( n )/d 1(mod n)
where d = gcd(k, (n)); if it has solution, there are exactly d solutions modulo n.
111
ind2x 3(mod 4)
= 3, 7, 11.
The integers corresponding to these indices will be 8, 11 and 7. Therefore, the required solutions
are
x 7, 8 and 11 (mod 13).
Example 8: Solve the congruence 17 x 20 19 mod 37
112
513 3 (mod 17),
514 15 (mod 17),
515 7 (mod 17).
Thus, we have the following index 516 1 (mod 17) table.
a 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
ind.a 0 6 13 12 1 3 15 2 10 7 11 9 4 5 14 8
Example 10: Show that the congruence x18 5 (mod 73) is not solvable.
Solution : Here
n 73 72
d n, n 18,72 18
n
Therefore, a d 54 1mod 73.
2 6 7mod19
1mod 19
113
Therefore, 2 is the smallest primitive root of 19. Now we will find an integer h such that
2h 7mod19, 0 h 18.
ky h mod n
15 y 6mod 18.
This gives y 4,10,16mod 18.
10.3. Summary
In this chapter we completely answered the question “what kind of integers have primitive
roots?” which was asked in Chapter 9 by showing 2, 4, pk and 2pk are the only integers having
primitive roots. Also we introduced index of a modulo n and used to solve some congruence
equation.
10.4. Keywords
Primitive root, Index of an element.
10.5. Exercises:
1. Verify that 3 is a primitive root mod 52, 53, and 72.
2. Find a primitive root modulo p2 for each odd prime 11, 13, 17, and 19.
3. Find a primitive root modulo pk for each odd prime p and k ≥ 2:
a) p = 3, k = 4 b) p =5, k = 3.
4. Determine whether each integer has a primitive root: 46, 486, 1024 and 2187.
5. If p is an odd prime, then prove that pk and 2pk have the same number of primitive roos.
6. Assume that r is a primitive root of the odd prime p and (r tp) p1 1(mod p 2 ) . Show
that r + tp is a primitive root of pk for each k ≥ 1.
7. Using a table of indices for a primitive root of 11, solve the following congruences:
a) 7x3 ≡ 3(mod 11) b) 3x4 ≡ 5(mod 11) c) x8 ≡ 10(mod 11).
114
8. Solve each of the congruences using indices:
a) 7x ≡ 13(mod 18)
b) 2x4 ≡ 5(mod 13)
c) 85x ≡ 5(mod 13)
d) 34x + 1 ≡ 10(mod 19).
9. Using indices, determine the remainder when the first integer is divided by the second:
(a) 231001, 13 (b) 517 719, 13
10. Let α be a primitive root modulo a positive integer m > 2. Then indα(m – 1) = ϕ(m) / 2.
11. Let α be a primitive root modulo a positive integer m > 2 and gcd(a, m) = 1. Then
indα(m – a) = indα(a) + ( ϕ(m) / 2).
12. Let p be an odd prime. Then the congruence x2 ≡ –1(mod p) is solvable if and only if p
is of the form 4k + 1.
10.6. References:
115
UNIT –11
EULER’S CRITERION, LEGENDRE SYMBOL AND ITS PROPERTIES
Structure:
11.0. Objective
11.1. Euler’s Criterion
11.2. Legendre Symbol
11.3. Summary
11.4. Keywords
11.5. Exercises
11.6. References
11.0. Objective
We studied solvability of linear congruences in chapter 3. In this chapter we study quadratic
congruences. This includes quadratic residue, Legendre symbol and its properties and we prove
Gauss Lemma.
The supposition that p is an odd prime implies that gcd(4a, p) = 1. Thus, the
quadratic congruence in Eq. (1) is equivalent to
4(ax 2 bx c) 0 (mod p) .
116
Thus, the problem of finding a solution to the quadratic congruence in Eq. (1) is equivalent to
that of finding a solution to a linear congruence and a quadratic congruence of the form
Whenever x 2 a(mod p) has a solution x = x0, there is also a solution x = p – x0. This second
congruence is not congruent to the first. For, x0 ≡ p – x0(mod p) implies that 2x0 ≡ 0(mod p),
which is impossible. By Lagrange’s Theorem of Chapter 9, x 2 a(mod p) has exactly two
solutions. Therefore, Eq. (3) has either no solutions or exactly two incongruent solutions.
Example 1: Solve the quadratic congruence 3x 2 4 x 7 0 (mod 13) .
Solution: Multiply both sides by 4 3 = 12. Then, we get
36 x 2 48x 84 0 (mod 13)
that is,
(6 x 4)2 (16 84) (mod 13)
(6 x 4)2 10 (mod 13)
Let y = 6x – 4. Then y2 ≡ 10(mod 13). This congruence has exactly two solutions, namely 6 and
7.
Therefore, the solutions of the original congruence are given by those of the linear
congruences 6x – 4 ≡ 6(mod 13) and 6x – 4 ≡ 7(mod 13), namely, x ≡ 6, 4(mod 13).
117
Theorem 1: (Euler’s criterion) Let p be an odd prime and gcd(a, p) = 1. Then a is a quadratic
residue of p if and only if a ( p1)/2 1(mod p).
Proof: Let a be a quadratic residue mod p and (a, p) = 1. Then the quadratic congruence x2 ≡
a(mod p) has a solution, say x0.
Thus, x02 a(mod p) where gcd( x0 , p) 1 (8)
Therefore,
a ( p 1)/2 x02
( p 1)/2
x0p 1 (mod p )
1(mod p ). [from (2)
Conversely, suppose a ( p1)/2 1(mod p). Then, by Corollary 3 of Chapter 9, primitive root mod
p exists. Let r be a primitive root mod p. Then 1, r, r2, …, rp–1 forms a reduced residue system
mod p and a r k (mod p) for some integer k such that , 1 ≤ k ≤ p – 1.
Now, we have,
1 a ( p 1)/2 r k
( p 1)/2
(mod p )
k ( p 1)
r 2
(mod p ).
As r is a primitive root mod p, order of r is p – 1. This implies ( p 1) | k ( p21) . This implies that
k must be an even integer, say 2t. Therefore, a r 2t (mod p). This shows rt is a solution of
x 2 a(mod p).
Corollary 1: Let p be an odd prime and gcd(a, p) = 1. Then a is a quadratic residue or non-
residue of p according to whether
a ( p1)/2 1(mod p) or a ( p1)/2 1(mod p).
Proof: If p is an odd prime and gcd(a, p) = 1. Then,
(a ( p1)/2 1)(a ( p1)/2 1) a ( p1) 1 0(mod p)
by Fermat’s theorem. Hence, either
a ( p1)/2 1(mod p) or a ( p1)/2 1(mod p)
118
but not both. If both holds, then we would have 1 1(mod p) , or equivalently, p | 2, which is
impossible. By Euler’s criterion, a quadratic non-residue of p does not satisfy a ( p1)/2 1(mod p)
Theorem 2. Let p be an odd prime, and let a, b Z such that gcd(a, b) = 1. Then, we have
(i) (a / p) ≡ a(p−1)/2 (mod p); in particular, (−1 / p) = (−1)(p−1)/2;
(ii) (a / p)(b / p) = (ab / p);
(iii) a ≡ b (mod p) implies (a / p) = (b / p);
(iv) (a2 / p) = 1.
Proof of (i) : If p divides a, then both sides of the congruence are 0. If p does not divide a, then,
by Fermat’s theorem,
a
( p 1)/2 2
a p1 1(mod p) ,
and so
a(p−1)/2 ≡ ±1 (mod p).
Applying Corollary 1, we have
a(p−1)/2 ≡ 1 (mod p) if and only if (a | p) = 1
and so
a(p−1)/2 ≡ −1 (mod p) if and only if (a | p) = −1.
119
Proof of (ii): Using part (i), we have
(ab / p) (ab)( p1)/2 a ( p1)/2b( p1)/2 (a / p)(b / p)(mod p).
Part (iii) is clear from the definition.
Proof of part (iv): Clearly a satisfies the congruence x 2 a 2 (mod p) and hence (a2 / p) = 1.
Corollary 2: If p is an odd prime, then
1 if p 1(mod 4)
( 1 / p)
1 if p 3(mod 4)
Proof: Because (p – 1)/2 is even for a prime p of the form 4k + 1 and odd for p of the form 4k +
3, part (i) of Theorem 2, proves the required result.
Example 4: Consider the congruence x 2 46(mod 17). Applying part (i) and (ii) of Theorem
2, we have,
(–46 / 17) = (–1 / 17)(46 / 17) = (46 / 17). [17 ≡ 1(mod 4)
Because 46 ≡ 12(mod 17), it follows that
(46 / 17) = (12 / 17). [by part (iii)
2
Now, (12 / 17) = (3 2 / 17) = (3 / 17).
But
(3 / 17) 3(171)/2 38 812 ( 4)2 1(mod 17).
Therefore, (–46 / 17) = –1.. Hence the quadratic congruence x 2 46(mod 17) has no solution.
Theorem 3: If p is an odd prime, then
p 1
(a / p) 0.
a 1
Hence, there are precisely (p – 1)/2 quadratic residues and (p – 1)/2 quadratic non-residues of p.
Proof: Let r be a primitive root of p. Then 1, r, r2, …, rp–1 are just a permutation of the integers
1, 2, …, p – 1. Thus, for any a lying between 1 and p – 1, inclusive, there exists a unique
positive integer k (1 ≤ k ≤ p – 1), such that a r k (mod p) . By appropriate use of Euler’s
criterion, we have
120
where, because r is a primitive root of p, r ( p1)/2 1(mod p) . But (a / p) and (–1)k are equal to
either 1 or -1, so that equality holds in Eq. (6). Now add up the Legendre symbols in question to
obtain
p 1 p 1
(a / p) ( 1) 0
k
a 1 a 1
which is the desired conclusion.
Corollary 3: The quadratic residues of an odd prime p are congruent mod p to the even powers
of a primitive root r of p; the quadratic non-residues are congruent to the odd powers of r.
Theorem 4: (Gauss Lemma): If p is an odd integer, a is an integer such that (a, p) = 1 and n is
the number of integers in the set
p 1
a, 2a,...., a (11)
2
Proof: Since (a, p) =1, each integer of (7) is co-prime to p and no two of them are congruent to
each other (mod p). Let r1, r2,…,rm be the remainder on division by p such that 0 < ri < p/2 and
s1,s2,...sn be the remainders such that p/2 < si < p. Then m + n = (p – 1) / 2, and the integers
We shall show that these integers are distinct. Suppose if possible p – si =rj for som i and
j. Then there exist integers h and k with 1 h, k ( p 1) / 2 such that si ha (mod p) and ri ka
But this is not possible because 1 < h + k p – 1. Hence r1, r2,…,rm, p – s1,…,p – sn are all
distinct. Thus, r1, r2,…,rm, p – s1,…, p – sn are simply the integers 1, 2,…, ( p 1) / 2 . Therefore,
their product is
[( p 1) / 2]! r1, r2 ...rm p s1 ... p sn
r1.r2 ...rm s1 ... sn mod p
1 r1r2 ...rm s1...sn.
n
121
But r1, r2,...,rm, s1, s2,…,sn are congruent (mod p) to a, 2a,…, [( p 1) / 2] a in some order.
Hence,
p 1 p 1
! 1 a 2a a mod p
n
2 2
p 1
p 1
1 a ! mod p
n 2
2
Because [(p – 1) / 2]! is relatively prime to p, we have
p 1
1 1 a mod p
n 2
p 1
a 1 mod p .
2 n
p 1
(a / p) a 1 mod p (a / p) 1 .
2 n n
1 if p 1 mod 8 or p 7 mod 8
(2 / p)
1 if p 3 mod 8 or p 5 mod 8
p 2 1
Hence, (2 / p) 1 8
(2 / p) 1
n
122
Since p is an odd prime it must have any one of the form 8k+1, 8k+3, 8k+5 or 8k+7.
Now,
if p = 8k + 1 then n = 4k –[2k + (1/4)] = 4k – 2k = 2k
if p = 8k + 3 then n = 4k + 1 – [2k + (3/4)] = 4k +1 – 2k = 2k + 1
if p = 8k + 5 then n = 4k + 2 – [(2k +1) + (1/4)] = 4k + 2 – (2k + 1) = 2k + 1
and if p = 8k + 7 then n = 4k +3 – [(2k +1) + (3/4)] = 4k +3 – (2k + 1) = 2k + 2.
Thus, we see that n is even when p is of the form 8k+1 or 8k + 7 and therefore (2 / p) 1
and if p is of the form 8k + 3 or 8k + 5 then n is odd which gives (2 / p) 1.
Further
8k 1 1
2
1 8 if p 8k 1
8k 3 1
2
1 8 if p 8k 3
p 2 -1
1 8 =
8k 5 1
2
1 8 if p 8k 5
8k 7 1
2
1 8 if p 8k 7
64 k 16 k
2
1 8 if p 8k 1
64 k 48k 8
2
1 if p 8k 3
8
64 k 80 k 24
2
1 8 if p 8k 5
64 k 112 k 48
2
1 8 if p 8k 7
1 if p 1mod 8
1 if p 3mod 8
=
1 if p 5mod8
1if p 7mod 8
1 if p 1mod p
=
1 if p 3mod p
p 2 -1
Hence, (2 / p) 1 8 .
123
p1
Theorem 6: If p and 2p+1 are both odd primes then 1 2 2 is a primitive root of 2p+1.
Proof: We put q = 2p+1. Since p and 2p+1 are both odd primes, we have either p 1(mod 4) or
p 3 (mod 4).
p1
If p 1 (mod 4) then 1 2
2 2 . Now (q) = q – 1 = 2p, the order of 2 modulo q is any one
2
But q 3 (mod 8), there for 1.
q
Hence, 2p –1(mod q). This shows that 2 cannot have order p modulo q. Also 2 cannot have
order 1 and 2 because 22 1(mod q) implies q /3 which is impossible. So the order of 2 modulo q
is 2p. This shows that 2 is a primitive root of q.
( p 1)/2
If p 3mod 4 then 1 2 2 and
N 4 p1 p2 ... pn 2.
2
Obviously N is an integer of the form 2(8k – 1). Therefore, it will have an odd prime divisor, say
p. So, N 0(mod p). This implies that x2 2(mod p) has a solution 4p1p2…pn (mod p).
Therefore, (2 / p) 1 .
Hence, p must be of the forms 8k + 1 or (8k – 1) by Theorem 5. Since p and 2, p1, p2,…,
pn are coprime, p cannot be of the form 8k – 1. So it is of the form 8k + 1. This shows that all
124
prime divisors of N are of the form 8k + 1. This implies that N is of the form 8k + 1. This is a
contradiction. Hence, there are infinitely many primers of the form 8k – 1.
Theorem 8: If p is an odd prime and a an odd integer, with gcd(a, p) = 1, then
p 1
2
ka
(a / p) 1 p
k 1 .
Proof: We shall employ the same notation as in the proof of Gauss’ lemma. Consider the set of
integers
p 1
S = a, 2a,...., a
2
Divide each of these multiples of a by p to obtain
ka = qkp + tk 1 tk p–1
Then ka / p = qk + tk / p, so that [ka / p] = qk. Thus, for 1 k (p – 1) / 2, we may write ka in
the form
ka
ka p tk (12)
p
If the remainder tk < p / 2, then it is one of the integers r1, r2, … ,rm; on the other hand, if tk >
p / 2, then it is one of the integers s1, s2, …, sn.
Taking the sum of the (p – 1) / 2 equations in (8), we get the relation
( p 1)/2( p 1)/2 ka m n
ka p rk sk (13)
k 1 k 1 p k 1 k 1
( p 1)/2 ( p 1)/2 ka n
(a 1) k n 2 sk (15)
k 1
k 1 p k 1
125
Let us use the fact that p ≡ a ≡ 1(mod 2) and translate this last equation into a congruence
modulo 2:
( p 1)/2 ( p 1)/2 ka
0 k 1 n (mod 2)
k 1
k 1 p
or
( p 1)/2 ka
n (mod 2)
k 1 p
as we desired to show.
Example 5: Evaluate (504 / 23).
Solution : We have (504 / 23) (62 14 / 23) (62 / 23)(14 / 23) (14 / 23) 6, 23 1
(168 /11) (23 3 7 /11) (2 /11)3 (3 /11)(7 /11) 1 1 1 1.
3
126
Example 6: Evaluate n of Gauss Lemma for (11 / 23). .
p 1 23 1
Solution: Here, a = 11 and p = 23, Therefore, 11. So, S = {11, 22, 33, 44, 55,
2 2
66, 77, 88, 99, 110, 121}. With respect to modulo 23 the members of S will become 11, 22, 10,
p 23
21, 9, 20, 8, 19, 7, 18, and 6. Five of these numbers are greater than . Therefore, n = 5.
2 2
11.3. Summary
In this chapter, we studied quadratic congruences and quadratic residues through Legendre
symbol.
11.4. Keywords
Quadratic congruence, Quadratic residue, Legendre symbol.
11.5. Exercise
1. Solve the quadratic congruences:
a) x2 + 5x + 3 ≡ 0(mod 11)
b) x2 + 3x + 11 ≡ 0(mod 13)
2. Determine which of the following congruences are solvable:
a) x2 ≡ –10(mod 127)
b) x2 ≡ 73(mod 173)
c) x2 ≡ 2(mod 59)
3. Find all quadratic residues mod 19, given that 2 is a primitive root mod 19.
4. Verify that the quadratic residues of 17 are 1, 2, 4, 8, 9, 13, 15, and 16.
5. Show that 3 is a quadratic residue of 23, but a non-residue of 31.
6. Given that a is a quadratic residue of the odd prime p, prove the following:
a) a is not a primitive root of p
b) The integer p – a is a quadratic residue or non-residue of p according as p ≡
1(mod 4) or p ≡ 3(mod 4).
7. If p = 2k + 1 is prime, verify that every quadratic non-residue of p is a primitive root of p.
8. Evaluate the following Legendre symbol:
(a) (3 / 31) (b) (2 / 31) (c) (3 / 73) (d) (–23 / 59)
127
9. Use Gauss lemma to evaluate each of the Legendre symbol:
(a) (8 / 11) (b) (7 / 13) (c) (11 / 23) (d) (6 / 31)
10. For an odd prime p, prove that there are (p – 1)/2 – ϕ(p – 1) quadratic non-residues of p
that are not primitive roots of p.
11.6. References:
128
UNIT –12
QUADRATIC RECIPROCITY LAW AND QUADRATIC CONGRUENCES
Structure:
12.0. Objective
12.1. Quadratic Reciprocity Law
12.2. Quadratic Congruences with Composite Moduli
12.3. Summary
12.4. Keywords
12.5. Exercises
12.6. References
12.0. Objective
In the last two chapters, we have seen how quadratic congruences leads to the definition of
quadratic residues and then to the study of Legendre symbol and its properties. In this chapter
we prove one of the most fascinating law “quadratic reciprocity law” which deals with the
solvability of quadratic congruences. Also, we study the quadratic congruences with composite
moduli.
Proof : We consider a rectangular region R (excluding the boundaries) with vertices (0,0),
p q p q
,0 , 0, and , .
2 2 2 2
129
y
q
0, p q
2 B 2, 2
C
O (0,0) D (k,0) A p x
,0
2
A lattice point (whose coordinates are integers) (m, n) inside the boundary OABC satisfies
p 1 q 1
1 m and1 n .
2 2
We will count these lattice points. Since p and q are odd integers, the number of such points will
be
p 1 q 1
. (16)
2 2
q
Now the equation of diagonal OB is given by y x. We will show that no lattice point lies on
p
the diagonal OB. Suppose if (m, n) lies on OB. Then
q
n m pn qm p | qm
p
p | m. gcd p, q 1
p 1
This is not possible because m . Therefore no lattice point lies on the diagonal OB. Let R1
2
be the portion of R below OB and R2 the portion of R above OB. We will count the lattice points
inside these two regions. We consider a point D(k, 0) on OA. Let the perpendicular on D meets
kq
the diagonal on E. The number of lattice points lying on DE will be .
p
p 1
2
kq
Therefore, the number of lattice points lying in R1 will be p .
k 1
130
q 1
2
kp
Similarly, the number of lattice points lying in R2 will be q . Thus, the total number of
k 1
lattice points lying in R will be
p 1 q 1
2
kq 2
kp
p q (17)
k 1 k 1
From (1) and (2) we have
p 1
p 1 q 1 2
kp
.
2 2
q (18)
k 1
By Theorem 7 of Chapter 11, we have
q 1 p 1
2 2
kq kp
( p / q)( q / p) 1
k 1
p
1
k 1
q
p 1 q 1
1
2 2
.
Proof: We have
p 1 q 1
( p / q)( q / p ) 1 .
2 2
p 1 q 1
1 if . iseven
2 2
1if p 1 . q 1 isodd
2 2
1if at least one of p or q 4k 1
1if both p and q 4k 3
1if p 1mod 4 or q 1mod 4
1if p q 3 mod 4
Example 1: Show that, (113 / 43) (43 / 113).
Solution : Here 43 and 113 are both odd primes and 113 is of the form 4k+1 and 43 is of the
form 4k+3 (113 / 43) (43 / 113).
131
Example 2: Show that, (43 / 23) (23 / 43).
Solution: Here, we have 23 and 43 both are odd primes and both
23 4 5 3
43 4 10 3
are of the form 4k + 3. Therefore, (43 / 23) (23 / 43).
Example 3: Evaluate (59 / 131).
Solution : Here 59 and 131 both are odd primes and
59 = 4 14 + 3
131 = 4 32 + 3
are of the form 4k + 3. Therefore,
(59 / 131) (131 / 59) (13 / 59)
(59 / 13) 13 1 mod 4
(7 / 13) (13 / 7) ( 1 / 7)
( 1) 1.
Example 4: Evaluate (71 / 73).
Solution: We have
Theorem 2: If p is an odd prime and a is any integer such that (a, p) = 1 then the congruence
x02 a mod p n
p n | x02 a
p | x02 a
x 2 a mod p has a solution
132
Therefore, by Euler’s criterion (a / p) 1. Conversely, suppose (a / p) 1. Then by Euler’s
criterion x 2 a mod p . This shows that the given statement is true for n =1. Now we assume
that x 2 a mod p m has a solution. We shall show that x 2 a mod p m1 also has a solution.
Let x0 be the solution of x 2 a mod p m . Then x02 a bp m for some integer b. Obviously
(2x0, p) = 1. Therefore the linear congruence 2x0y –b(mod p) has a solution say y0.
Let x1 x0 y0 p m .
Then
x12 ( x0 y0 p m )2 x02 2 x0 y0 p m y02 p 2 m
a (b 2 x0 y0 ) p m y02 p m1 p m1
Since p | (b + x0y0), pm+1 | (b + x0y0)pm, it follows that
This shows that x1 is a solution of x2 a(mod pm+1). Hence, by mathematical induction we have
that x2 a (mod pn) has a solution for n 1.
Proof:
i) We have a 1 (mod 2) [ a is an odd integer ]
Therefore 1 is the solution of x2 a (mod 2).
ii) Since a is an odd integer we have a 1 or 3 (mod 4) , Also, b2 1 (mod 4), where b is an
odd integer. Now the congruence x2 a (mod 4) has a solution b if a 1(mod 4). Also, if
a 1(mod 4), then 1 and 3 both satisfy x2 1(mod 4).
iii) Suppose a 1(mod 8). Then we have to show that x2 a (mod 2n), n 3 has a solution.
For n = 3 we have x2 1 (mod 8). Obviously 1, 3, 5, and 7 satisfy this congruence. Thus,
the given congruence has a solution for n = 3. Suppose the congruence x2 a(mod 2n) has
a solution x0 for n 3. Then, x02 a b 2n for someinteger t.
133
Let x1= x0 + y02n-1 is a solution of x2 a(mod 2n+1), because
x12 ( x0 y0 2n 1 )2 x02 x0 y0 2n y02 22 n 2
a (b x0 y0 )2n y02 2n 32n 1
By the way y0 was chosen, 2 | (b + x0y0); hence x12 ( x0 y0 2n1 )2 a(mod 2n1 ) has a
solution for n 3.
Conversely, suppose x2 a (mod 2n) has a solution x0 for each n 3 then we have
x02 a mod 2n
x02 a mod 8 .
Theorem 4: Let n 2k0 p1k1 prkr be the prime factorization of n > 1 and let gcd(a, n) = 1. Then
Proof: Since the problem of solving the quadratic congruence x 2 a mod n is equivalent to
x 2 a mod 2k0
x2 a mod p k1
1
x 2 a mod prkr
the last two theorems may be combined to solve the quadratic congruence x 2 a mod n .
134
Therefore, the given congruence has no solution.
Example 2: Show that the congruence x2 9 (mod 40) is solvable.
Solution: We have, x2 9(mod 40) which is equivalent to the following simultaneous quadratic
congruences
x2 9 (mod 8)
and x2 9 (mod 5).
Now 9 1 (mod 8) therefore, x2 9(mod 8) has a solution.
Also, (9 / 5) (32 / 5) . Therefore, x2 9 (mod 5) has a solution. Hence, the given quadratic
congruence has a solution.
Example 3: Show that the congruence x2 105 (mod 199) has no solution
Solution: Here 199 is a prime. We have
(105 / 199) (3 5 7 / 199) (3 / 199)(5 / 199)(7 / 199)
( 1)(199 / 3)(199 / 5)( 1)(199 / 7)
[ 199 4 49 3, 3 4 0 3, 5 4 1 1 and 7 4 1 3]
(1 / 3)(4 / 5)(3 / 7) 1 1 ( 1) (7 / 3) ( 1)(1 / 3) 1 1 1
Therefore, the given congruence has no solution.
Example 4: Show that the congruence x2 608 (mod 743) is solvable.
Solution: Here 743 is a prime. We have
20
1 1 4 1 1 1.
5
135
We know that any solution of x2 91(mod 33) is also a solution of x2 91(mod 3).
Now
x2 91(mod 3)
x2 1(mod 3).
Obviously 1 is a solution of this congruence. Let x0 = 1.
Now,
x02 1 91 90
91 3 30 .
Therefore, b = –30. Consider the congruence 2y 30(mod 3). Then, y 0(mod 3). Hence
y0 = 0. We have x1 = x0 + y032. Hence x1 = 1 + 0 32 = 1. Therefore x1 = 1 is a solution of
x2 91(mod 9).
Since, x12 1 91 90
91 9 10 ,
b = –10. Consider the linear congruence 2y 10(mod 9). Then, 2y 1(mod 9). Clearly y1 = 5 is
a solution of this congruence. Therefore, x2 = x1 + y132 = 1 + 5 9 = 46 19(mod 27). Hence, x2
= 19 is a solution of the congruence x2 91(mod 27).
12.3. Summary
In this chapter we explored the theory of quadratic congruences via quadratic residue and
established several criteria for determining the solvability of the congruence x2 a(mod p) where
p is an odd prime p | a.
12.4. Keywords
Quadratic Reciprocity Law, Composite Moduli.
12.5. Exercise:
1. Let p = 11 and q = 7. Using the notation in the proof of the law of quadratic reciprocity
Theorem, we have m + n + M + N = |S × T| = 15. Compute the numbers m, n,M, and N.
Check that (7 / 11) = (−1)m and (11 / 7) = (−1)n.
2. Use quadratic reciprocity to compute (7 / 43). Find an integer x such that x2 ≡ 7 (mod 43).
3. Use quadratic reciprocity to compute (19 / 101). Find an integer x such that x2 ≡ 19 (mod
101).
136
4. Prove that the congruence (x2 − 2)(x2 − 17)(x2 − 34) ≡ 0 (mod p) has a solution for every
prime number p.
5. Use quadratic reciprocity to find all primes p for which −2 is a quadratic residue.
6. Use quadratic reciprocity to find all primes p for which 3 is a quadratic residue.
7. Find all primes for which −3 is a quadratic residue.
8. Find all primes for which 5 is a quadratic residue.
9. Find all primes for which −5 is a quadratic residue.
10. Let x1 = 3. Costruct integers xk such that xk2 ≡ 2 (mod 7k) and xk ≡ xk −1 (mod 7k −1) for k =
2, 3, 4.
11. Let p be a prime, p ≠ 3, and let a be an integer not divisible by p. Prove that if a is a
cubic residue modulo p, then a is a cubic residue modulo pk for every k ≥ 1.
12.6. References:
137
BLOCK – IV
REPRESENTATION OF INTEGERS,
FIBONACCI NUMBERS & CONTINUED
FRACTIONS
138
UNIT – 13
SUM OF TWO SQUARES & SUMS OF MORE THAN TWO SQUARES
Structure:
13.0. Objective
13.1. Sum of two squares
13.2. Method of expressing a prime p = 4k+1 as sum of two squares
13.3. Sum of more than two squares
13.4. Summary
13.5. Keywords
13.6. Exercises
13.7. References
13.0. Objective
Mathematicians throughout history have been interested in problems regarding the representation
of integers as sums of squares. Diophantus, Fermat, Euler, and Lagrange are among the
mathematicians who made important contributions to the solution of such problems. There are
two main questions. First one is, which integers can be expressed as sums of two squares?
Second one is, what is the smallest value of n such that every positive integer can be written as
the sum not more than n squares? In this chapter, we shall discuss the problems of representing
numbers as sum of squares of two or more integers.
a12a22 a12b22 b12a22 b12b22 2a1a2b1b2 2a1b2a2b1 a1a2 b1b2 a1b2 a2b1 .
2 2
This shows that the product mn can be expressed as sum of two squares.
139
Corollary 1: If m1, m2,…, mr are integers such that mi ai2 bi2 ,1 i r then m1.m2…mr = a2 +
ax y : 0 x m 1, 0 y m 1
contains m2 elements. Since ax – y can take atmost p values, there exists integers (x1, y1) and (x2,
y2) such that
ax1 y1 ax2 y2 mod p
where x1 x2 or y1 y2 . Thus, we can write,
a( x1 x2 ) y1 y2 mod p
Setting x0 x1 x2 and y0 y1 y2 we see that (x0, y0) satisfies the given congruence and
0 x0 x1 x2 m 1 p p and 0 y0 y1 y2 m 1 p p
x 2 1 mod p
140
Therefore, the linear congruence ax y (mod p) has a solution (x0, y0) such that
0 x0 p and 0 y0 p
This gives that there exists an integer k > 0 such that x02 y02 kp
p p
2 2
Now, kp x02 y02 2 p.
Thus, we have, 0 kp 2 p 0k 2
Now, p 2 a 2 b2 c 2 d 2 ad bc ac bd
2 2
p 2 ac bd .
2
Let, (a1 – a2, b2 – b1) = d. Since a1 – a2 and b2 – b1 both are even integers, we have d is an even
integer.
Let, a1 – a2 = rd
b2 – b1 = sd (3)
for some integers r and s. Obviously gcd(r, s) =1. From (2) and (3) we have
r(a1 + a2) = s(b2 + b1) (4)
From (4) we see that s | (a1 + a2) and r | (b2 + b1)
Therefore, a1 + a2 = st (5)
for some integer t. Then from (4) we have
b2 + b1 = rt (6)
Since (r, s) = 1, we see from (1) and (2) that t = gcd(a1 + a2, b2 + b1).
Since a1 + a2, b2 + b1 both are even, t is even.
Therefore,
d 2 t 2
r d s t s d r t r s d t . Hence, n r s .
2 2 2 2 2 2 2 2 2 2 2 2 2 2
2 2
142
n x 2 y 2 x02 y02 d 2
n
Now, x02 y02 . (9)
d2
Since s1 is odd, q1 divides x02 y02 to an odd power.
Further gcd x0 , q1 gcd y0 , q1 1.
Let, y0t x0 mod q1 (10)
Obviously it has a unique solution t ≡ t1 (mod q1).
n
Therefore, 2 x02 y02 y02t12 y02 mod q1
d
This gives
y02 1 t12 0 mod q1 .
1 t12 0 mod q1
y q 1
0, 1
x 1 mod q1
2
n 2r p1r1 .... plrl q1s1 ....qmrm a 2 b2 c12 d12 ... cl2 d l2 q1sl /2 .... qm sm /2
2 2
which is again sum of two square and which completes the proof.
We use the continued fraction method to express p = 4k +1 as sum of two squares. The method is
as follows.
1 p P1 p P1 where P1 p
p P1
2 , Q1 p P1
Q1
p P2
3 , Q2 p P2
Q2
p Pn
n1 , Qn p Pn
Qn
If Qr Qr 1 then p Pr21 Qr21
143
Theorem 7: A positive integer n can be expressed as the difference of two squares iff n is not of
the form 4k +2.
Proof: We know that a2 0 or 1 (mod 4) for all integers a. Therefore a 2 b2 0, 1 or 3 (mod 4).
n 1 n 1
2 2
Solution : We have, 1225 52 49 52 72 42 32 72 282 212
144
Thus, we have,
Q2 Q3 13. Here P3 38
14 3 7 2 14 2 7 3
2 2
562 7 2.
Example 6: Express 333 as the sum of two squares.
Solution: We have 333=32·37
This prime factorization contains no odd power of a prime congruent 3 modulo 4. Therefore, it
can be expressed as sum of two squares. Now
145
317 15 317 15 317 8
5 1
317 152
23 23
4
317 8 317 8 317 14
6 2
317 8 2
11 11
23
317 14 317 14
7
317 14 2
11
11
Thus Q6 = Q7. Here P7 =14 Therefore,
317 P72 Q72 142 112.
Example 8: Express 153 as the difference of two squares.
Solution: We have, 153 1 (mod 4).
Therefore,
n 77 76 .
2 2
2 2 2 2 2
0 or 4 mod 8 if a iseven.
Similar, behavior is that of b2 and c2. Therefore, a2 +b2+c2 will be congruent (mod 8) to one of
the integers 0, 1, 2, 3, 4, 5, 6 and not to 7. This contradicts (12). Hence, n = 8q +7 is not
expressible as sum of three squares.
Theorem 9: Any integer of the form n 4m 8q 7 for integers m and q 0 is not a sum of
three squares.
Proof: For m = 0 the statement reduces to Theorem 8.
146
Suppose if possible
n 4m 8q 7 a 2 b2 c2
(13)
for m 1 and integers a, b, c.
Therefore, a2 + b2 + c2 0 (mod 4) (14)
Now
a2 1 (mod 4) if a is odd
0 (mod 4) if a is even
It is obvious that a, b, c all are even integers. Therefore, from (11) we have
2 2 2
a b c
4 8q 7
m 1
2 2 2
Thus, we see that if 4m 8q 7 is the sum of three squares then 4m1 8q 7 is also a sum of
three squares. Repeating the same procedure we see that 4m2 8q 7 , ,40 8q 7 is the sum
of three squares. But 40 8q 7 is not the sum of three squares. Thus, we have a contradiction.
Theorem 10: (Euler) : If the integers m and n are each the sum of four squares then mn is also
the sum of four squares.
Proof: Let m a12 b12 c12 d12 and n a22 b22 c22 d 22 .
Now
mn a12 b12 c12 d12 a22 b22 c22 d 22
p 1
2
p 1
2
S1 0,12 ,22 ,...., and S2 1, 1 1 , 1 2 ,
2 2
, 1 .
2 2
Then the integers of S1 and S2 are all incongruent (mod p). The total numbers of integers in
S1 S2 is p+1. Therefore, there will be at least two integers among these p+1 integers which are
147
congruence to each other (mod p). So at least one number of S1 say a2 is congruent (mod p) to
p p
some number say –1 – b2 of S2 such that 0 a and 0 b .
2 2
Thus, we have a 2 1 b2 mod p a 2 b2 1 hp
for some positive integers h. Also
1 2 1 p2 p2
h a b2 1 1 p.
p p 4 4
Theorem 12: A prime p can be expressed as the sum of four squares.
1 1 1 1
These gives that a b , a b , c d and c d are all integers.
2 2 2 2
h
d1 d mod h and a1 , b1 , c1 , d1 .
2
For obtaining the value of a1 we find the remainder r when a is divided by h. We put a1 = r or
h h
a1 = r – h according as r or r respectively.
2 2
Then, a1 b1 c1 d1 a b c d 0 mod h a12 b12 c12 d12 nh for some
2 2 2 2 2 2 2 2
148
h2 np hp nh a 2 b2 c2 d 2 . a12 b12 c12 d12 r 2 s 2 t 2 u 2
where
r aa1 bb1 cc1 dd1 , s ab1 ba1 cd1 dc1
t ac1 a1c bd1 db1 u ad1 a1d bc1 cb1.
Now, r aa1 bb1 cc1 dd1 a12 b12 c12 d12 0 mod h .
2 2 2 2
r s t u r s t u
Similarly, s t u 0 mod h . So, np where , , , are
h h h h h h h h
all integers. Since 0 < n < h, we have a contradiction. Hence, h = 1.
Theorem 13: (Lagrange): Any positive integer n can be expressed as a sum of four squares.
Proof: If n = 1 then n = 12 +02+02+02 which is a sum of four squares.
For n > 1 we take n = p1 p2…pr as prime factorization. Since each prime can be expressed as the
sum of four squares, their product which is equal to n will also be expressed as sum of four
squares.
Example 9: Express 459 as sum of four squares.
Solution : We have
459 = 33 17
32 3 17
32 12 12 12 02 42 12 02 02
32 4 1 0 02 1 4 0 0 0 0 4 0 0 0 1 0
2 2 2
Example 9: Find the relation a2+b2+1 = hp for p = 19 and hence show that 319=42+42+42+32.
p 1 19 1
Solution: We have 9
2 2
Therefore, S1 = {02, 12, 22,…,92} and S2= { –1 – 02, –1 – 12, –1 – 22,…, –1 –92}
Now we will find the integers of S1 which are congruent (mod 19) to the integers of S1. We have
12 –1 – 62(mod 19) 32 –1 – 32(mod 19) 82 –1 – 72(mod 19)
Therefore, 62 +12 +1 = 219 , 32 +32 +1 = 119 82 +72 +1 = 6 19
These are the required relations.
Since 6 19 = 82 + 72 +12 + 02 we have
8 0 8 0 7 1 7 1
2 2 2 2
3 19 4 4 4 3
2 2 2 2
2 2 2 2
149
Waring’s problem
Waring, E in 1770 stated that every positive integer can be written as the sum four squares, nine
cubes, nineteen fourth powers and so on. When we say that every number is expressible as the
sum of four squares we mean that four is such a least number. It may also be more than four. For
example, 36 = 32 +42 +52 +62 . Similarly, Waring’s assertion regarding cubes we mean that 9 is
the least number of positive integers whose sum of cubes is the given positive integer. Waring’s
assertion can be stated as follow:
For any given positive integer k there exists a smallest integer N(k) depending only on k
such that every positive integer can be represented as the sum of N(k) kth powers. Thus, Waring
conjectured that N(2) = 4, N(3) = 9 and N(4) = 19.
13.4. Summary
In this chapter we studied integers which can be expressible as sum of squares of two or more
integers and showed any integer of the form 4k + 1 can be expressed as sum of two squares.
13.5. Keywords
Sum of squares, odd, even.
13.6. Exercise:
1. Express each of the integers as sum of two squares:
(a) 41 (b) 97 (c) 541 (d) 7250
2. Determine whether each integer can be written as sum of squares:
(a) 101 (b) 315 (c) 315 (d) 454
3. Show that one more than twice the product of two consecutive integers can be written as
the sum of two square.
4. If n ≡ 3 or 6(mod 9), then show that n cannot be represented as sum of two squares.
5. A number is said to be triangular if it can be written in the form n(n + 1) / 2. If n is the
sum of two triangular numbers, then prove that 4n + 1 is the sum of two squares.
6. Show that no positive integer n ≡ 7(mod 8) can be written as the sum of three squares.
7. Show that no integer N of the form 4e(8n + 7) can be represented as the sum of three
squares.
8. Express each prime as the sum of four squares:
(a) 43 (b) 89 (c) 197 (d) 349
13.7. Reference:
1. Elementary Number Theory, David M. Burton, McGraw Hill Publication
2. An Introduction to the Theory of Numbers, G. H. Hardy and E. M. Wright, Oxford
150
UNIT – 14
THE FIBONACCI SEQUENCE, IDENTITIES INVOLVING FIBONACCI NUMBERS
Structure:
14.0. Objective
14.1. Introduction
14.2. The Fibonacci numbers
14.3. Certain Identities Involving Fibonacci Numbers
14.4. Summary
14.5. Keywords
14.6. Exercises
14.7. References
14.0. Objective
Another important problem that is usually discussed not only in Mathematics but also in
Computer Science, because of its recursive nature is “Rabbit Problem” that leads to Fibonacci
numbers. Fibonacci numbers have so much properties that a lot of literature can be found on this
subject. In this chapter we discuss some of the important properties of Fibonacci numbers.
14.1. Introduction
The Italian mathematician Leonardo de Pisa was born in Pisa around 1175 AD. He is commonly
known as Fibonacci which is a shortened form of Filius Bonaccio (son of Bonaccio). His father,
Bonaccio, was a customs inspector in the city of Bugia on the north coast of Africa (presently
Bougie in Algeria) and as a result, Fibonacci was educated by the Mohammedans of Barbary. He
was taught the Arabic system of numbers and in the early thirteenth century returned to Italy to
publish the book Liber Abaci (Book offhe Abacus) in 1202 (Leonardo di Pisa 1857). This book
introduced the Arabic system of numbers to Europe and is responsible for Fibonacci's reputation
as the most accomplished mathematician of the middle ages. The book also posed a problem
involving the progeny of a single pair of rabbits which is the basis of the Fibonacci sequence (or
Fibonacci series). It was, however, Edouard Lucas, whose contribution to this area of
mathematics will be discussed in detail in the next chapter, who rediscovered the Fibonacci
sequence in the late nineteenth century, and properly attributed it to its original founder.
151
The rabbit problem is as follows:
A pair of adult rabbits produces a pair of baby rabbits once each month. Each pair of
baby rabbits requires one month to grow to be adults and subsequently produces one
pair of baby rabbits each month thereafter. Determine the number of pairs of adult
and baby rabbits after some number of months. It is also assumed that rabbits are
immortal.
This problem may be expressed mathematically in this way: The number of adult rabbit pairs in a
particular month (say month n+2), Fn+2, is given by the number of adult rabbit pairs in the
previous month, An+1, plus the number of baby rabbit pairs from the previous month which grow
to be adults, bn+1;
bn1 Fn (16)
Combining (1) and (2) gives the recursion relation for the number of adult rabbit pairs as
Hence the recursive relation (3) gives a sequence of numbers 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89,
144, … with F1 = 1, F2 = 1 and Fn2 Fn1 Fn . This sequence is called Fibonacci sequence.
The Fibonacci sequence grows rapidly.
152
Theorem 1: We have
F5n2 10n for n 1.
Proof: Proof is by induction. For n = 1, we have A7 = 13 > 10. Let us assume that the
inequality holds for arbitrary integer n = k, that is F5k 2 10k . Now we show that it also holds
for n = k + 1. Using the recursive formula (3) several times, we can write
Which is precisely (4) with n replaced by k + 1. Hence, by induction (4) holds for all m ≥ 2 and
n ≥ 1.
153
Theorem 4: For m ≥ 1 and n ≥ 1, Fmn is divisible by Fm.
Proof: Proof is by induction on n. The result is obviously true when n = 1. Let us assume that
Fmn is divisible by Fm for n = 1, 2, …, k. From (4), we have Fm( k 1) Fmk 1Fm Fmk Fm1
Because Fm divides Fmk by supposition, the right hand side of this expression (and hence, the left
hand side) must be divisible by Fm. Accordingly, Fm / Fm(k+1), which was to be proved.
Lemma 1: If m = qn + r, then gcd(Fm, Fn) = gcd(Fr, Fn).
Proof: From (4), we have gcd( Fm , Fn ) gcd( Fqnr , Fn ) gcd( Fqn1Fr Fqn Fr 1, Fn ) .
Now from Theorem 4 and the fact that gcd(a+c, b) = gcd(a, b), whenever b / c, gives
gcd( Fqn1Fr Fqn Fr 1, Fn ) gcd( Fqn 1Fr , Fn ).
We claim that, gcd( Fqn1Fr , Fn ) 1 . Suppose d gcd( Fqn1Fr , Fn ). Then d / Fn and Fn / Fqn
implies d / Fqn and therefore d is a common divisor of the successive Fibonacci number Fqn-1 and
Fqn. Because successive Fibonacci numbers are relatively prime, d = 1.
We know that if gcd(a, c) = 1, then gcd(a, bc) = gcd(a, b). Hence, we have
gcd( Fm , Fn ) gcd( Fqn1Fr , Fn ) gcd( Fr , Fn ).
rn 2 qn rn 1 rn 0 rn rn 1
rn 1 qn 1rn 0.
Now, from above Lemma 1, we have
gcd( Fm , Fn ) gcd( Fr1 , Fn ) gcd( Fr1 , Fr2 ) gcd( Frn1 , Frn ).
Since rn / rn-1, by Theorem 4, we have Frn | Frn 1 and hence gcd ( Frn , Frn 1 ) Frn . But rn , being the
last nonzero remainder in the Euclidean Algorithm for m and n, is equal to gcd(m, n). Hence
gcd ( Fn , Fm ) Fgcd( m,n ) . This completes the proof.
154
Corollary 1: In the Fibonacci sequence, Fm / Fn if and only if m / n for n ≥ m ≥ 3.
Proof: One way we have already proved in Theorem 4. So, assume that Fm / Fn. Then
gcd(Fm, Fn) = Fm. But, by Theorem 5, the value of gcd(Fm, Fn) = Fgcd(m, n). Hence, gcd(m, n) = m
and therefore m / n.
Example 1: We show that gcd(F16, F12) = gcd(987, 144). From Euclidean algorithm, we have
gcd(987, 144) = 3 and gcd(16, 12) = 4. Now, F4 = 3. Hence gcd(F16, F12) = Fgcd(16, 12).
F1 F2 F3 Fn Fn2 1 (19)
155
The important point is that except for the initial sign the right-hand side of this equation is the
same as the left-hand side, but with all the subscripts decreased by 1. By repeating the argument
( Fn21 Fn Fn2 ) can be shown to be equal to the expression (1)( Fn22 Fn1Fn3 ) , and hence
1 1 5 1 5
n n
Fn .
5 2 2
This formula can be obtained by considering the two roots
1 5 1 5
and (21)
2 2
of the equation x2 – x – 1 = 0. Since they are roots of this equation, they must satisfy
2 1 and 2 1.
Multiply first relation by τn and second by φn. Then, we obtain
n2 n1 n and n2 n1 n .
Subtracting the second equation from the first, and dividing by τ – φ , leads to
n 2 n 2 n 1 n 1 n n
(22)
H n2 H n1 H n n 1.
From (7), we have
1 5 1
Hence,
2 2
H1 1 H2 1.
156
All this shows that the sequence H1, H2, H3, … is precisely the Fibonacci sequence, which gives
n n
Fn n 1. (23)
1 5
Note 2: The number is usually called Golden Ratio.
2
Note 3: (9) is called Binet’s formula.
Using (9), we can prove certain identities involving Fibonacci numbers.
Theorem 7: We have
Fn22 Fn2 F2n2 .
Proof: As we start, recall that 1 which has the immediate consequence ( )2 k 1 for k ≥ 1,
Then,
2 2
n 2 n 2 n n
F 2
n2 F 2
n
2( n 2) 2 2( n 2) 2 n 2 2 n
( )2 ( ) 2
2( n2) 2( n 2) 2 n 2 n
( )2
Now the expression in the numerator may be written as
2( n2) ( )2 2n ( )2 2n 2( n2) ( 2 2 )( 2n2) 2n2) )
On doing so, we get
( 2 2 )( 2 n 2 2 n 2 )
F 2
n2 F 2
( )2
n
2 n2 2 n2
( )
1.F2 n 2 F2 n 2 .
For a second illustration of the usefulness of the Binet formula, let us once again derive the
relation F2 n1F2 n1 1 F22n , (see Note 1). First, we calculate
2 n 1 2 n 1 2 n 1 2 n 1
F2 n 1F2 n 1 1 1
5 5
1
( 4 n 4 n ( ) 2 n 1 2 ( ) 2 n 1 2 5)
5
1
( 4 n 4 n ( 2 2 ) 5).
5
157
Because 2 2 3, this last expression becomes
1 4n 1
( 4 n 2) ( 4 n 4 n 2( ) 2 n )
5 5
2
2n 2n
F2 n
2
5
which is the required identity.
14.4. Summary
In this chapter we have seen that how rabbit problem leads to Fibonacci sequence and studied
some of its properties. Also we have seen that how nicely the Fibonacci numbers are connected
1 5
with golden ratio .
2
14.5. Keywords
Fibonacci, sequence, identity, golden ratio.
14.6. Exercise
1. For n = 1, 2, …, 10, show that 5Fn2 4( 1)n is a perfect square.
2. Prove that if 2 | Fn , then 4 | Fn21 Fn21 .
3. Show that F12 F22 F32 Fn2 Fn Fn1 .
4. For n ≥ 3, prove that Fn21 Fn2 3Fn21 2 F12 F22 F32 Fn21 .
5. Evaluate gcd(F9, F12), and gcd(F15, F20).
6. Using induction on the positive integer n, establish the following formulae:
a) F1 2F2 3F3 nFn (n 1) Fn2 Fn4 2
b) F2 2F4 3F6 nF2n nF2n1 F2n .
7. Show that F2 F4 F6 F2n F2 n1 1 .
8. Deduce F2 n1 Fn2 Fn21 .
9. Use problem viii to obtain the following identities:
a) Fn21 Fn22 2F2 n1 for n ≥ 3
b) Fn22 Fn21 2( Fn2 Fn21 ) for n ≥ 2.
10. Prove that Fn Fn1 Fn2 Fn21 (1)n .
14.7. Reference
1. Elementary Number Theory, David M. Burton, McGraw Hill Publication
2. The Golden Ratio and Fibonacci Numbers, Richard A. Dunlap, World Scientific.
158
UNIT – 15
FINITE CONTINUED FRACTIONS, CONVERGENTS OF A CONTINUED
FRACTION, SIMPLE CONTINUED FRACTIONS
Structure:
15.0. Objective
15.1. Finite continued fractions
15.2. Convergent fractions
15.3. Solution of linear Diophantine equation using continued fraction
15.4. Summary
15.5. Keywords
15.6. Exercises
15.7. References
15.0. Objective
A very important application of the Euclidean algorithm lies in the continued fractions, which
also gives an alternative way of representing real numbers. In this chapter we shall show that
every rational number has finite continued fraction representation and shall see its link with the
solution of linear Diophantine equations.
214 4
6 (28)
35 35
So we have obtained a first piece of information: the rational number 214 / 35 lies between 6 and
7, as 0 < 4 / 35 < 1. By writing 4 / 35 as the inverse of a number greater than 1, formula (5)
becomes
159
214 1
6 (29)
35 35
4
35 3 35 1
8 that is 8 (30)
4 4 4 4
3
4 1
1 (31)
3 3
is called a finite continued fraction and is denoted by [a0; a1,…,an]. The numbers ak are called
the terms or the partial quotients of the continued fraction. The reason for assuming ak > 0 for k
≥ 1 in the above definition is that this guarantees that no division by zero will occur. A
continued fraction is said to be simple if all of the ai are integers.
Theorem 1: Every finite simple continued fraction is equal to a rational number, and every
rational number can be written as a finite simple continued fraction.
Proof. The first part is trivial. For the second one, let a / b be the rational number, b > 0. Apply
the Euclidean algorithm to find the gcd of a and b:
a = ba0 + r1, 0 < r1 < b,
b = r1a1 + r2, 0 < r2 < r1,
r1 = r2a2 + r3, 0 < r3 < r2,
⋮
ri = ri+1ai+1 + ri+2, 0 < ri+2 < ri+1,
⋮
rn−2 = rn−1an−1 + rn, 0 < rn < rn−1,
rn−1 = rn an + 0.
160
As all the remainders are positive, so are all the quotients ai, with the possible exception of the
first one. Rewrite the equations given by the Euclidean algorithm dividing the first one by b, the
second one by r1, the third one by r2 and so on, till the last one, to be divided by rn. So we obtain
The left-hand sides of these equations are rational numbers, which are rewritten as the sum of an
integer and a fraction with numerator equal to 1. By successive eliminations, we get
161
Notice that may be obtained from by substituting for ak. Clearly, for k = n we
get the complete original continued fraction. Every = [a0; a1, . . . , ak] is a rational number
which will be denoted by pk / qk, where gcd(pk, qk) = 1.
Suppose now that we have computed the value of [a0; a1, a2,…,an] and want to compute
the value of [a0; a1, a2,…,an+1] without having to repeat the whole computation from scratch. The
following recursion formula describes how to find (n + 1)th convergent knowing nth convergent.
Theorem 2: If a0, a1, a2, . . . , an be real numbers with a1, a2, . . . positive. Let the sequences p0,
p1, p2, . . . , pn and q0, q1, q2, . . . , qn be defined recursively by
&
[ ]
For k = 1
[ ]
[ ]
Now, consider
[ ]
[ ]
[ ]
[ ]
( )
( )
( )
( )
162
Example 1: We have 173 / 55 = [3;6, 1, 7]. Let us compute the sequences pj and qj for j = 0, 1,
2, 3. We have
p0 = 3, q0 = 1
p1 = 3.6+1 = 19 q1 = 6
p2 = 1.19+3 = 22 q2 = 1.6+1 = 7
p3 = 7.22+19 = 173 q3 = 7.7+6 = 55
Theorem 3: If a0, a1, a2, . . . , an be real numbers with a1, a2, . . . positive, with corresponding
convergent Then
(i) ( ) ≥
(ii) ( ) ≥
( )
(iii) ≥
( )
(iv) ≥
163
To find a solution of equation ax by 1 , expand the rational number a / b as a simple continued
fraction; say,
a
[a0 ; a1 , a2 , an ] .
b
Now the last two convergents of this continued fraction are
pn 1 pn
Cn 1 and Cn .
qn 1 qn
Since gcd(pn, qn) = 1 = gcd(a, b), it may be concluded that pn = a and qn = b.
By (i) of Theorem 3, we have pn qn1 qn pn1 (1)n1
Theorem 4: Let a0, a1, a2, . . . be real numbers with a1, a2, . . . positive, with corresponding
convergents Then the convergents C 2i with even indices form a strictly increasing
sequence and the convergents C2j+1 with odd indices form a strictly decreasing sequence, and C2i
< C2j+1, that is
C0 < C2 < … < C2i < … < C2j+i < … < C3 < C1.
( )
Proof: We have, . Hence if n ≥ 2 is even, then and if n ≥ 3
j, then C2j < C2i < C2i+1 and C2i < C2i+1 < C2j+1.
In the above example, 3 < (22 / 7) < (173 / 55) < (19 / 6) in accordance with C0 < C2 < C3 < C1.
164
Theorem 5: If qk is the denominator of the kth convergent Ck of the simple continued fraction
[a0; a1, a2,…,an], then qk – 1 ≤ qk for 1 ≤ k ≤ n, with strict inequality when k > 1.
Proof: We prove the theorem by induction. Since q0 = 1 ≤ a1 = q1, the theorem is true for k = 1.
Assume that it is true for k = m where 1 ≤ m < n. Then
≥
So that the inequality is also true for k = m+1.
15.4. Summary
In this chapter we have studied finite continued fractions, their nth convergents and some of its
properties. We showed that every rational number can be expressed as finite continued fraction
and vice versa. We showed how continued fraction can be used to solve diophantus equation.
15.5. Keywords
Finite continued fraction, simple continued fraction, convergents, rational.
15.6. Exercise:
1. Write each as a finite simple continued fraction:
(a) 57 / 23 (b) 89 / 55 (c) 79 / 91 (d) -43 / 17
2. Compute the convergents of each continued fraction:
(a) [1;1, 1, 1, 1, 1, 1] (b) [0;2, 7, 7, 6]
(c) [3; 1, 4, 2, 7] (d) [-2; 5, 4, 7, 1]
3. Represent each continued fraction as a rational number:
(a) [1;2, 3, 4, 5] (b) [-3;5, 4, 3, 2]
4. Using finite continued fraction [1;1, 1, …, 1] prove that Fn2 Fn Fn21 (1)n1 where n ≥ 1.
5. Solve each Linear Diophantine equation using continued fraction:
(a) 12x + 13y = 14 (b) 28x + 91y = 119
6. Using the continued fraction for the given rational number r, find the continued fraction for 1 / r:
(a) 25 / 18 (b) 464 / 675
15.7. Reference:
1. Elementary Number Theory, David M. Burton, McGraw Hill Publication
2. An Introduction to the Theory of Numbers, G. H. Hardy and E. M. Wright, Oxford
3. Encyclopedia of Mathematics and its Applications, Volume 11, Continued Fractions,
Analytic Theory and Applications, William B. Jones and W. J. Thron, Addison-Wesley
4. An Introduction to the Theory of Numbers, Ivan Niven, Herbert S. Zuckerman and Hugh
L. Montgomery, John Wiley & Sons, Inc.
165
UNIT – 16
INFINITE CONTINUED FRACTION, PERIODIC CONTINUED FRACTION
AND PELL’S EQUATION
Structure:
16.0. Objective
16.1. Infinite continued fractions
16.2. Rational approximation to irrational numbers
16.3. Periodic continued fractions
16.4. Pell’s equation
16.5. Summary
16.6. Keywords
16.7. Exercises
16.8. References
16.0. Objective
We have seen that all rational numbers, can be represented as finite simple continued fractions.
The main reason of interest of continued fractions, however, is in their application to the
representation of irrational numbers. In this chapter, we shall show that every irrational number
can be expressed as an infinite continued fraction. Also, in this chapter we shall investigate
another important equation called Pell’s equation and find complete solution to this problem.
√ (√ )
√
√
166
Definition 1: Let ( ) be a sequence of real numbers, all positive except possibly a0. Infinite
continued fraction is denoted by [a0; a1, a2, … ]. The infinite continued fraction is said to
converge if the limit [ ] exists, and in that case the limit is also denoted
by [a0; a1, a2, … ].
We know that, [a0; a1, a2,…,an] = , the above limit can be written as
[ ] .
Let us now existence of the above limit. By Theorem 3, we have C 0 < C 2 < … < C 2i < … < C
2j+i < … < C 3 < C 1. Because the even-numbered convergents C2n form monotonically increasing
sequence and bounded above by C1, they will converge to a limit α that is greater than each C2n.
Similarly, odd numbered convergents C2n+1 are monotonically decreasing and bounded below by
C0 and hence converges to α’ that is less than each C2n+1. Let us prove α = α’. We have
( )
Consider,
and hence
| |
[ ]
Because x lies strictly between the successive convergents Cn and Cn+1 , we have
| | | | | |
With the view to obtaining a contradiction, assume that x is a rational number, say, x = a / b,
where a and b > 0 are integers. Then
| |
and so,
| |
As qi increase without bounds as i increases, we can chose n so large that b < qn+1 and hence
| |
167
This shows that there is a positive integer between 0 and 1, which is a contradiction.
The converse of the above theorem is also true.
Theorem 2: Every irrational number has a unique representation as an infinite continued
fraction.
Proof: Let x0 be an arbitrary irrational number. Let us find the sequence of integers a0, a1, a2,
… as follows: Let
1
ak [ xk ] and xk 1 k 0 (1)
xk ak
It is evident that xk+1 is irrational whenever xk is irrational. Since x0 is irrational all xk are
irrational by induction. Thus,
0 xk ak xk [ xk ] 1 (2)
and hence
1
xk 1 1 (3)
xk ak
so that the integers ak+1=[xk+1] ≥ 1 for all k ≥ 0. Thus, we have a sequence of integers a0, a1, a2,
…, all positive except perhaps for a0.
Now, (3) can be written as
1
xk ak , k 0.
xk 1
Through successive substitutions, we obtain
1
xk a0
x1
1
a0
1
a1
x2
1
a0
1
a1
1
a2
x3
[a0 ; a1 , a2 , , xn 1 ]
for every positive integer n. Now, we have to prove that the infinite simple continued fraction
[a0, a1, a2, …] indeed converges to x0.
Let n be a fixed positive integer. Then,
xn 1 pn pn 1
x0 [a0 ; a1 , a2 , , xn1 ]
xn 1qn qn 1
168
pn
where Cn is the nth convergent of x0 [a0 ; a1, a2 , ] . Hence,
qn
xn 1 pn pn 1 pn
x0 Cn
xn 1qn qn 1 qn
( pn qn 1 pn 1qn )
( xn 1qn qn 1 )qn
( 1)n 1
[by (i) of Theorem 3 of Unit 3
( xn 1qn qn 1 )qn
From (2), we have xn+1 > an+1 and therefore
1 1 1
x0 Cn
( xn 1qn qn 1 )qn (an 1qn qn 1 )qn qn 1qn
1
Because qk increases without bounds as k increases, 0 as n . Hence
qn 1qn
x0 n lim
Cn [a0 ; a1 , a2 , ].
x0 23 4 23 4 [ 23 4 a0 4
1 1 23 4 23 3
x1 1 a1 1
x0 x0 23 4 7 7
1 7 23 3 23 3
x2 3 a2 3
x1 x1 23 3 2 2
1 2 23 3 23 4
x3 1 a3 1
x2 x2 23 3 7 7
1 7
x4 23 4 8 ( 23 4) a4 8
x3 x3 23 4
Because x5 = x1, also x6 = x2, x7 = x3, x8 = x4; then we get x9 = x5 = x1, and so on, which means
that the block of integers 1, 3, 1, 8 repeats indefinitely. We find that the continued fraction
23 [4;1, 3, 1, 8, 1, 3, 1, 8, ]
[4;1, 3, 1, 8]
169
Now, we prove that the representation of an irrational number as an infinite continued fraction is
unique in the following theorem.
Theorem 3: If the two infinite simple continued fractions [a0 ; a1, a2 , ] and [b0 ; b1, b2 , ]
1 1
a0 b0
[a1; a2 , a3 , ] [b1; b2 , b3 , ]
so that
[a1; a2 , a3 , ] = [b1; b2 , b3 , ]
Now assume that ak = bk and that [ak 1; ak 2 , ak 3 , ] [bk 1; bk 2 , bk 3 , ] . Using the same
argument, we see that ak+1 = bk+1, and
1 1
ak 1 bk 1
[ak 2 ; ak 3 , ] [bk 2 ; bk 3 , ]
which implies
[ak 2 ; ak 3 , ] [bk 2 ; bk 3 , ]
Hence by induction, we see that ak = bk for k = 0, 1, 2, …
Theorem 4: If x is an irrational number, then there are infinitely many rational numbers p / q
such that
p 1
x 2 (4)
q q
Proof: Let pk / qk be the kth convergent of the continued fraction of x. Then, by Theorem 2 of
Unit 4, we know that
pk 1 1
x 2 [ qk qk 1
qk qk qk 1 qk
Hence
pk 1
x 2
qk qk
.
Consequently, the convergents of x, pk / qk , k = 1, 2, … are infinitely many rational numbers
which satisfy (4).
170
16.2. Rational approximation to irrational numbers
The following theorem and corollary shows that the convergents of the simple infinite
continued fraction of an irrational numbers x are the best rational approximation to x.
Theorem 5: Let pn / qn be the nth convergent of the continued fraction representing the irrational
number x. If a and b are integers, with 1 ≤ b < qn+1, then
qn x pn bx a
If 0, then the equation qn b qn1 implies that qn 0 and therefore 0. If
0, then b qn1 which implies b qn1 and therefore qn b qn1 0; this makes 0.
Hence, and must have opposite signs. By Theorem 4 of Chapter 15, since x lies between
pn p
and n 1 , qn x pn and qn1 x pn1 will have opposite signs. This implies qn x pn
qn qn 1
and qn1 x pn1 must have the same sign and therefore
171
Corollary 1: If 1 ≤ b ≤ qn, the rational number a / b satisfies
p a
x n x
qn b
Proof: Suppose
p a
x n x
qn b
then
p a
qn x pn qn x n b x bx a
qn b
which is a contradiction to Theorem 5.
Theorem 6: Let x be an arbitrary irrational number. If the rational number a / b where b ≥ 1
and gcd(a, b) = 1, satisfies
a 1
x 2
b 2b
then a / b is one of the convergents pn / qn in the continued fraction representation of x.
Proof: Assume that a / b is not a convergent of x. Since the sequence qn is an increasing
sequence, there exists a unique integer n for which qn ≤ b < qn+1. For this n, the last lemma
gives the first inequality in the chain
a 1
qn x pn bx a b x
b 2b
which may be written as
pn 1
x
qn 2bqn
Since, a / b ≠ pn / qn, bpn – aqn is a nonzero integer, and hence 1 ≤ |bpn – aqn|.
Now, consider
1 bp aqn p a p a 1 1
n n n x x 2
bqn bqn qn b qn b 2bqn 2b
Since, qn b ,
1 1 1 1 1
2 2 2 2.
2bqn 2b 2b 2b b
Therefore
1 1 1 1
2 qn b.
bqn b qn b
But this is a contradiction to the fact that qn ≤ b. This completes the proof.
172
16.3. Periodic Continued Fractions
Definition 2: If an infinite continued fraction contains a block of partial denominators b1, b2, …,
bn that repeats indefinitely, the fraction is called periodic. We write a periodic fraction as
a0 , a1, , am , b1, b2 , bn , b1, b2 , bn ,
More compactly as
a0 , a1, , am , b1, b2 , bn
where the over bar indicates that this block of integers repeats over and over. If b1, b2 , bn is the
smallest block of integers that constantly repeats, we say that b1, b2 , bn is the period of the
expansion and that the length of the period is n.
For example
23 [4;1, 3, 1, 8, 1, 3, 1, 8, ]
[4;1, 3, 1, 8]
is periodic, whereas
[3; 7, 15, 1, 292, ]
is not a periodic continued fraction.
If a periodic simple continued fraction is given then the value of the continued fraction can be
found easily.
Example 2: Let x [3;6,1, 4,1, 4, ] [3;6,1, 4] [3;6, y] , where y [1, 4] [1; 4, y]
Then,
1 y 5y 1
y 1 1
4
1 4y 1 4y 1
y
which leads to the quadratic equation 4 y 2 4 y 1 0
1 2
Since y > 0, and since this equation has only one positive root, y .
2
From x = [3;6, y], we find that
1 25 19 2 14 2
x 3 .
6
1 86 2 4
1 2
2
Example 3: Consider x [4;1, 3, 1, 8, 1, 3, 1, 8, ] [4;1, 3, 1, 8]
Using nth convergents pn / qn, let us find the value of periodic continued fraction [4;1, 3, 1, 8] .
173
Let y [1;3,1,8,1,3,1,8 ] [1;3,1,8, y] . Then,
n -2 -1 0 1 2 3 4
an 1 3 1 8 y
pn 0 1 1 4 5 44 44y+5
qn 1 0 1 3 4 35 35y+4
44 y 5
Hence, y 7 y2 8 y 1 0
35 y 4
4 23 1 7 23 4 23
Since y is positive, y , therefore, x [4; y] 4 4
7 y 4 23 4 23
Hence x 23.
This shows that the values of the periodic simple continued fractions are the roots of quadratic
equations with integer coefficients. Later we prove it in a theorem.
Definition 3: An irrational number ξ is called a quadratic irrational (or algebraic of degree two)
if it is the root of a quadratic polynomial with integer coefficients, that is if a 2 b c 0 for
suitable integer coefficients a, b, and c with a ≠ 0.
Proposition 1: A real number ξ is a quadratic irrational if and only if it has the form
r s d , where d is a positive integer that is not a perfect square, r and s are rational
numbers and s ≠ 0.
Proof: Any real irrational solution of a quadratic equation ax2 + bx + c = 0 obviously has this
form. Conversely, a real number of this form is irrational and satisfies the quadratic equation
(x – r)2 = s2d, which can be turned into a quadratic equation with integer coefficients upon
multiplication by squares of the denominators of r and s.
the set of all real numbers ξ of the form r s d , with r and s rational. The number
' r s d is called the conjugate of ξ.
and ( / ) / .
174
Proposition 2: If the number x has a periodic simple continued fraction expansion, then x is a
quadratic irrational.
Let (pk, qk) be the convergents of the continued fraction [b0 ; b1, , br 1, y ]. Then
ypr 1 pr 2
y [b0 ; b1, , br 1, y ] ,
yqr 1 qr 2
and solving for y we see that y satisfies a quadratic equation with integer co-efficients. Hence, y
is a quadratic irrational.
yPm1 Pm2
Let (Pk, Qk) be the convergents of [a0 ; a1, a2 , , am1 ] . Then, x [a0 ; a1 , , am1 , y]
yQm1 Qm2
The converse of Proposition 2 is also true, that is every quadratic irrational has a periodic simple
continued fraction expansion. The proof of this needs some preparatory work.
u d
Lemma 1: If x is a quadratic irrational, then x can be written in the form x , where d is
v
an integer that is not a perfect square, u and v are integer, and v | (d – u2).
u0 d
Theorem 7: Suppose x0 , where d is a positive integer that is not a perfect square, u0
v0
and v0 are integers and v0 | (d u02 ) . Define recursively the sequences un 0 , vn 0 , an 0 , and
xn 0
as follows:
un d d un21
xn , an xn and un1 an vn un , vn 1 , for n 0.
vn vn
Then un and vn are integers, vn | (d un2 ) , and x0 [a0 ; a1, a2 , , an , xn1 ] for all n, and
x0 [a0 ; a1, a2 , ] .
175
Proof: We recall the recursive algorithm in Theorem 2 of Unit 4 for obtaining the continued
fraction expansion of x0 [a0 ; a1, a2 , ] . The terms an are given by
1
a0 [ x0 ], xn1 , and an1 [ xn1 ] for n 0, 1, 2,
xn an
un d
Now suppose inductively that xn , with integers un and vn that satisfy vn | (d un2 ) .
vn
Then
1 1 d (an vn un ) un 1 d
xn 1 ,
xn an d (an vn un ) d (an vn un ) 2 vn 1
vn vn
where un1 anvn un , vn1 d un21 / vn .
Clearly, un+1 is an integer and un+1 ≡ –un(mod vn). Hence by the induction assumption,
d un21 d un2 0(mod vn ), that is vn divides d un21 . Therefore, vn+1 is also an integer, and
Example 4: Let us compute the continued fraction expansion of the number (1 5) / 3 using
u d
the above algorithm. Since 3 | (5 12 ), we first have to put the number in the form of .
v
Multiplying numerator and denominator by -3, we obtain
3 45
x0 , that is u0 3, v0 9, and d 45.
9
Now v0 / d u02 , so we can start the algorithm. The result of the computations is shown in the
following table:
n 0 1 2 3 4 5 6 7 8 9
un -3 12 -1 5 5 3 6 6 3 5
vn -9 11 4 5 4 9 1 9 4 5
an -1 1 1 2 2 1 12 1 2 2
1 5
[1;1,1,2,2,1,12,1,2].
3
176
Lemma 2: Let x be a quadratic irrational and define xn as in Theorem 7. If the conjugate xk 0
Proof: By induction, it suffices to prove that xn 0 implies 1 xn 1 0. So assume xn 0 .
1
Consider, xn 1 . Then, by Note 2, we have
xn an
1
xn 1
xn an
Since an ≥ 1, the denominator xn an is strictly less than –1, so it follows that 1 xn 1 0 .
Proof: We have, xn 1 1/ ( xn an ) , and hence ( 1/ xn 1 ) an xn . Since 0 xn 1 , it
Lemma 4: If x is a quadratic irrational, then there exists an index k such that xk 0 .
Proof: Let (pk, qk) denote the kth convergent of x. Since x [a0 ; a1 , a2 , , an1 , xn ], we have
pn 1 xn pn 2
x ,
qn 1 xn qn 2
and solving for xn we obtain
qn 2 x pn 2 qn 2 x ( pn 2 / qn 2 )
xn .
pn 1 qn 1 x qn 1 x ( pn 1 qn 1 )
qn 2 x ( pn 2 / qn 2 )
By taking conjugates, we get xn .
qn1 x ( pn1 qn1 )
We now use the fact that the convergents pn / qn converges to x as n tends to infinity and that x’
≠ x. It follows that the expression within parenthesis converges to (x’ – x) / (x’ – x), that is to 1,
as n tends to infinity. Consequently, the expression within parenthesis is certainly greater than 0
when n is big enough, that is xn has the same sign as qn2 / qn1, which is negative since qn is
177
By Lemma 4, there is an index k such that xn 0, and by Lemma 2, 1 xn 0 for all n k.
Since xn > 1 for all n ≥ 1, we conclude that
2 d 2u
1 xn xn and 0 xn xn n
vn vn
for all n > k. Hence 0 vn 2 d and un > 0 if n > k. Moreover, using the relation
(d un21 ) vnvn1 0 , we obtain un21 d , that is un1 d for n > k. Thus, if n > k+1, then
0 un d and 0 vn 2 d . Hence, the ordered pairs (un, vn) can assume only a fixed
number of possible pair values and so there are distinct integers i and j with j > i such that uj = ui
and vj = vi. This implies that xi = xj = xi+(j – i), and hence x has a periodic continued fraction.
Note 1: All the continued fraction expansions of d takes the form d [a0 ; a1 , a2 , , an ] that
is, the periodic part starts after one term, this initial term being [ d ] .
Note 2: If d is a positive integer that is not a perfect square, then the continued fraction
Theorem 9: Let (pn ,qn) denote the nth convergent of d , let the integers un and vn be defined
for the number x = d as in Theorem , that is xn = (un+ d )/ vn with vn/(d –un2), and let r be the
Proof. Write d = [a0, a1, a2, . . .] = [a0, a1, a2, . . . ,an, xn+1].
178
(ii) The convergents pn/qn are > d if n is odd and < d if n is even. Therefore, pn2 dqn2 has the
same sign as (–1)n-1 , so it follows from (i) that vn 1 is positive for every n ≥ –1.
(iii) Since x = d has period length r, xkr 1 x1 for all positive integers k. It follows that
1 1
xkr akr x0 a0 a0 d ,
xkr 1 x1
That is xkr akr a0 d . Hence, vkr= 1 (and ukr= akr – a0).
Conversely, assume vn = 1; then xn = un + d , so an = [xn] = un+ [ d ] = un + a0
Then vn ≥ 2 by the above Theorem, and using Lemma 2 we conclude that xn (un d ) / vn 0 ,
xn 2 d / vn d . Finally, an [ xn ] [ d ] a0 .
square, there will of course be two additional trivial solutions ( N ,0), and if –N /d happens to
be an integer that is a perfect square, (0, N / d ) are two trivial solutions of Pell’s equation.
179
If (x1, y1) and (x2, y2) are two positive solutions of x2 – dy2 = N, then
x12 x22 d ( y12 y22 ), and hence x1 < x2 if and only if y1 < y2. Thus, if we order the positive
solutions according to increasing x-value or according to increasing y-value we will get the same
result.
If there is a positive solution in integers of Pell’s equation, then there is obviously a
positive solution (x1, y1) with a least positive x-value. This solution has also the least y-value
among all positive solutions. Since it plays a special role we introduce the following definition.
Definition 5: Suppose Pell’s equation x2 – dy2 = N has positive integral solutions. The
fundamental solution, or least positive solution, is the positive solution (x1, y1) such that x1 < u
and y1 < v for every other positive solution (u, v).
The following theorem gives a connection between Pell’s equation and continued fractions.
Theorem 10: Let d be a positive integer that is not a perfect square, and suppose | N | < d.
If (u, v) is a positive solution in integers of x2 – dy2 = N, then there is a convergent (pn, qn) of the
necessarily integers, such that d . is irrational and N < d . , and assume that u and v are positive
integers, such that d . is irrational and N < d . , and assume that u and v are positive integers
satisfying u2 – dv2 = N.
Since
u u u dv
2 2
N
d d 2
v v
2
v v
and the second factor of the left hand side is positive, we first conclude that (u / v) d 0, and
consequently (u / v) d 2 d . Hence
u N d 1
0 d 2 2 2.
v v ( u / v d ) 2v d v
By Theorem 6, u / v is a convergent of d .
Let now d and N be as in the statement of the Theorem 10. The case N > 0 is a special
case of what we have just proved.
180
If N < 0, we rewrite the equation y 2 (1/ d ) x 2 ( N / d ). Since 0 N / d d / d 1 / d ,
we can apply the general case above, and we conclude that v / u is a convergent of 1 / d .
Suppose d has the continued fraction [a0, a1, a2, . . .]. Then 1/ d [0, d ]
[0, a0 , a1, a2 , ] . Hence, there is an n such that
u 1
[0, a0 , a1, a2 , ]
v [a0 , a1, a2 , ] ,
length of the simple continued fraction expansion of d , and let pn , qn n 0 be the corresponding
sequence of convergents.
(i) Suppose r is even. Then
a. x2 – dy2 = –1 has no solutions in integers;
b. all positive integral solutions of x2 – dy2 = 1 are given by x = pkr-1, y = qkr-1 for k =
1, 2, 3, … , with x = pr-1 and y = qr-1 as the fundamental solution.
(ii) Suppose r is even. Then
a. all positive integral solutions of x2 – dy2 = –1 are given by x = pkr-1, y = qkr-1 for k
= 1, 3, 5, … , with x = pr-1 and y = qr-1 as the fundamental solution.
b. all positive integral solutions of x2 – dy2 = 1 are given by x = pkr-1, y = qkr-1 for k =
2, 4, 6, … , with x = p2r-1 and y = q2r-1 as the fundamental solution.
Proof: By Theorem 10, the positive integral solutions of x2 – dy2 = ±1 are to be found among
pn , qn n0
increasing. Therefore, the first solution that appears in the sequence will be the
fundamental solution.
According to Theorem 9, pn2 dqn2 (1)n1 vn1 , where vn ≥ 1 for all n and vn = 1 if and
only if r / n. Thus, pn2 dqn2 2 except when n = kr – 1 for some nonnegative integer k, in
which case
pn2 dqn2 (1)kr .
181
If r is even, then (–1)kr = 1 for all k, and hence (pkr-1, qkr-1) is a solution of x 2 dy 2 1 has no
positive solution, and of course no solution at all in integers. This proves part (i). If the period
length r is odd, then (–1)kr = 1 for k even, and = –1 for k odd, and this proves part (ii).
Example 5: We shall use Theorem 11 to find the fundamental solution of the equation
x 2 19 y 2 1
The continued fraction expansion of 19 [4,2,1,3,1,2,8] . Since the period length is 6, the
fundamental solution is (x, y) = (p5, q5). The convergents are computed in the following table:
n -2 -1 0 1 2 3 4 5
an 4 2 1 3 1 2
pn 0 1 4 9 13 48 61 170
qn 1 0 1 2 3 11 14 39
( x1 y1 d )( x2 y2 d ) (u v d ),
u 2 dv 2 (u v d )(u v d )
( x1 y1 d )( x2 y2 d )( x1 y1 d )( x2 y2 d )
( x12 dy12 )( x22 dy22 ) MN .
The solution (u, v) will obviously be positive if the original ones are positive.
Theorem 12: Let (x1, y1) be the fundamental solution of x 2 dy 2 1. Then all positive integral
solutions are given by (xn, yn), n ≥ 1, where the integers xn and yn are recursively defined by
xn1 ( x1xn y1 ynd ), yn1 ( x1 yn y1xn ).
182
Proof: Clearly xn1 yn1 d ( x1 y1 d )( xn yn d ) ( x1 y1 d )n1. Hence by Lemma 5
with M = N = 1, if (xn, yn) is a positive solution of Pell’s equation x 2 dy 2 1 , then (xn+1, yn+1)
will also be a positive solution. It therefore follows by induction, the (xn, yn) is a solution for all
n.
It remains to show that every positive integral solution is obtained in this way. Suppose
there is a positive solution (u, v) that is not of the form (xn, yn). Since xn forms an increasing
sequence, there must be some integer m such that xm u < xm+1. It follows that ym v < ym+1,
because we get the same result if positive solutions are ordered according to their x value or y
value. We cannot have equality, because u = xm would imply v = ym. Now (xm, –ym) is of course
also a (non-positive) solution of x 2 dy 2 1 , so by Lemma 5 we will obtain another solution (s,
t) by defining
(u v d )
s t d (u v d )( xm ym d ) .
( xm ym d )
Since ( xm ym d ) (u v d ) ( xm1 ym1 d ), we have
( xm1 ym1 d )
1 s t d ( x1 y1 d ).
( xm ym d )
But s t d 1/ ( s t d ) and hence 0 s t d 1. It now follows that
s 12 ( s t d ) 12 ( s t d ) 12 0 0
t d 12 ( s t d ) 12 ( s t d ) 12 12 0,
So (s, t) is a positive solution. Therefore, s > x1 and t > y1, but this contradicts s t d
x1 y1 d . This, contradiction shows that every integral solution (u, v) must be of the form (xn,
yn).
Example 2: In Example 1, we showed that the fundamental solution of x2 – 19y2 = 1
is (x1, y1) = (170, 39). Using the recursion formulas
xn+1 = x1xn + 19y1yn, yn+1 = x1yn + y1xn,
we can compute the next positive solutions. They are
(x2, y2) = (57 799, 13 260)
(x3, y3) = (19 651 490, 4 508 361)
(x4, y4) = (6 681 448 801, 1 532 829 480)
Just as in the case of x2 – dy2 = 1, further solutions of the equation x2 – dy2 = –1 can be found its
fundamental solution. We leave the proof of the following result to the reader.
183
Theorem 13: Suppose that x2 – dy2 = –1 has an integral solution, and let (x1, y1) denote the
fundamental solution. For n ≥ 1, define positive integers xn and yn recursively as in Theorem i,e.
(xn + yn d ) = (x1 +y1 d )n. Then all positive integral solutions of x2 – dy2 = –1 are given by (xn,
yn) with n odd, and all positive integral solutions of x2 – dy2 = 1 are given by (xn, yn) with n even.
In particular, (x2, y2) is the fundamental solution of x2 – dy2 = 1.
16.5. Summary
In this chapter we studied infinite continued fractions and showed that every irrational number
can be expressed as an infinite continued fraction and vice versa. We also showed how infinite
continued fractions can be used to completely determine the solutions of Pell’s equation.
16.6. Keywords
Infinite continued fraction, periodic continued fraction, rational and irrational numbers,
approximation, recursion formula.
16.7. Exercise:
1. Write down each irrational number as an infinite simple continued fraction:
(a) 5 (b) 7 (c) 15 (d) e
2. Using the continued fraction of π = [3; 7, 15, 1, 292, …] compute the value of π correct to
eight decimal places.
3. Using the continued fraction of e = [2; 1, 2, 1, 1, 4, 1, 1, 6, 1, 1, 8, …] compute the value
of e correct to six decimal places.
F
4. Prove that lim n 1 , the golden ratio.
n F
n
5. Find all positive solutions of the following equations for which y < 250:
(a) x2 – 2y2 = 1 (b) x2 – 3y2 = 1 (c) x2 – 5y2 = 1.
6. Show that there are an infinitude of even integers n with the property that both n + 1 and
(n / 2) + 1 are perfect squares.
7. Find two positive solutions of each of the following equations:
(a) x2 – 23y2 = 1 (b) x2 – 26y2 = 1 (c) x2 – 33y2 = 1.
16.8. References
1. Elementary Number Theory, David M. Burton, McGraw Hill Publication
2. An Introduction to the Theory of Numbers, G. H. Hardy and E. M. Wright, Oxford
3. Encyclopedia of Mathematics and its Applications, Volume 11, Continued Fractions,
Analytic Theory and Applications, William B. Jones and W. J. Thron, Addison-Wesley
4. An Introduction to the Theory of Numbers, Ivan Niven, Herbert S. Zuckerman and Hugh
L. Montgomery, John Wiley & Sons, Inc.
184