You are on page 1of 52

Let us get into some of …

Elementary Number
Theory

1
Introduction to Number Theory
Number theory is about integers ( )
and their properties.

We will discuss basic principles of


• divisibility,
• greatest common divisors,
• least common multiples, and
• modular arithmetic
• congruence relation
• some problem-solving using these principles

and look at some relevant algorithms.

2
Division
Definition : If a and b are integers with a  0, we
say that a divides b if there is an integer c such
that b = ac.

Alternatively, When a divides b we say that


b is a multiple of a, or
a is a factor of b, or
a is a divisor of b
a divides b (denoted with a | b means)

We write a X b when a does not divide b


(see book/board for correct symbol). 3
Divisibility and Non-
divisibility

4
Lets think!

What can be the possible divisors of


•0
•1
Properties of Divisibility

6
Divisibility of Algebraic Terms

7
Divisibility Theorems
For integers a, b, and c, the following theorems hold:
Thm1 : If a | b and a | c, then a | (b + c)
Example: 3 | 6 and 3 | 9, so 3 | 15.

Thm2 : If a | b, then a | bc for all integers c


Example: 5 | 10, so 5 | 20, 5 | 30, 5 | 40, …

•Thm3 : If a | b and b | c, then a | c


Example: 4 | 8 and 8 | 24, so 4 | 24.

8
Proving Thm3

9
Exercise :

Prove Thm 1 and Thm 2 yourself.

10
Primes
A positive integer p greater than 1 is called prime
if the only positive factors of p are 1 and p.

A positive integer that is greater than 1 and is not


prime is called composite.

The fundamental theorem of arithmetic:


Every positive integer can be written uniquely as
the product of primes, where the prime factors
are written in order of increasing size.

11
Primes
Examples:
15 = 3·5
48 = 2·2·2·2·3 = 24·3
17 = 17
100 = 2·2·5·5 = 22·52
512 = 2·2·2·2·2·2·2·2·2 = 29
515 = 5·103
28 = 2·2·7
12
The Division Algorithm
Let a, b be integers such that b>0 .
Then there are unique integers q and r, such that

a = bq + r

where 0  r < b

In the above equation,


• b is called the divisor,
• a is called the dividend,
• q is called the quotient, and
• r is called the remainder.
13
The Division Algorithm
Example:

When we divide 17 by 5, we have

17 = 53 + 2.

• 17 is the dividend,
• 5 is the divisor,
• 3 is called the quotient, and
• 2 is called the remainder.

14
The Division Algorithm
Another example:
What happens when we divide -11 by 3 ?
Note that the remainder cannot be negative.
-11 = 3(-4) + 1.

• -11 is the dividend,


• 3 is the divisor,
• -4 is called the quotient, and
• 1 is called the remainder.

15
So, what happens when b is a
negative integer?

16
Some examples when b<0

Let b = -7
We choose a = 1, -2, 61 and -59. We get

17
Greatest Common Divisors
Let a and b be integers, not both zero.
The largest integer d such that d | a and d | b is
called the greatest common divisor of a and b.
The greatest common divisor of a and b is denoted
by gcd(a, b) or simply (a,b).

Example 1: What is gcd(48, 72) ?


The positive common divisors of 48 and 72 are
1, 2, 3, 4, 6, 8, 12, 16, and 24, so gcd(48, 72) = 24.

Example 2: What is gcd(19, 72) ?


The only positive common divisor of 19 and 72 is
1, so gcd(19, 72) = 1. 18
Example 3: What is gcd(0, 8) ?
Answer = 8

Example 4: What is gcd(2, 8) ?


Answer = 2

Example 5: What is gcd(-2, 8) ?


Answer = 2

Example 6: What is gcd(2, -8) ?


Answer = 2

Example 7: What is gcd(0, 0) ?


Answer = not defined
19
Greatest Common Divisors
Using prime factorization, let us write WLOG,

a = p1a1 p2a2 … pnan , b = p1b1 p2b2 … pnbn ,


where p1 < p2 < … < pn and for 1  i  n, ai, bi are non –ve
integers. Then,

gcd(a, b) = p1min(a1, b1 ) p2min(a2, b2 ) … pnmin(an, bn )


Example:
a = 60 = 22 31 51
b = 54 = 21 33 50
gcd(a, b) = 21 31 50 = 6
20
For integers a1, a2, …, an

let gcd(ai, aj) = 1

whenever 1  i < j  n.

Fall 2002 CMSC 203 - Discrete Structures 21


A few properties of gcd
Let d = (a,b).

1) If c|a,b then c|d


2)Bezout’s identity : d = xa + yb where x and
y are integers
3)gcd is commutative : (a,b) = (b,c)
4)gcd is associative : (a,(b,c)) = ((a,b),c)
5)gcd is multiplicative : (a,bc) = (a,b) (a,c)

22
Relatively Prime Integers
Definition:
Two integers a and b (not both zeros) are relatively
prime or mutually prime or coprime if gcd(a, b) = 1.

Examples:
Are 15 and 28 relatively prime?
Yes, gcd(15, 28) = 1.
Are 55 and 28 relatively prime?
Yes, gcd(55, 28) = 1.
Are 35 and 28 relatively prime?
No, gcd(35, 28) = 7.
23
Coprime & pairwise coprime
A set of integers can also be called coprime if its
elements share no common positive factor
except 1.
A stronger condition on a set of integers
is pairwise coprime or relatively prime which
means that a and b are coprime for every
pair (a, b) of different integers in the set.
The set {2, 3, 4} is coprime, but it is not pairwise
coprime since 2 and 4 are not relatively prime.

24
Pairwise Relatively Prime Integers
Definition:
The integers a1, a2, …, an are pairwise relatively
prime if gcd(ai, aj) = 1 whenever 1  i < j  n.

Examples:
Are 15, 17, and 27 pairwise relatively prime?
No, because gcd(15, 27) = 3.
Are 15, 17, and 28 pairwise relatively prime?
Yes, because gcd(15, 17) = 1, gcd(15, 28) = 1 and
gcd(17, 28) = 1.
25
Euler’s totient function
The number of integers coprime to a positive
integer n, (between 1 and n), is given by
Euler’s totient function (or Euler's phi
function) φ(n).
φ(n) = number of integers k in the range 1
≤ k ≤ n for which the gcd(n, k) = 1
Euler's product formula
where the product is over the distinct
primes dividing n. Eg, find φ(36)
= 12. 26
Find :

1) φ(1)
2) φ(2)
3) φ(3)
4) φ(4)
5) φ(5)
6) φ(6)
27
Some applications of Euler’s
totient function
• Fermat’s little theorem
• Euler’s generalization of
Fermat’s little theorem
• Primality testing
• Party tricks
• RSA public key encryption
28
Least Common Multiples
Definition:
The least common multiple of the positive integers
a and b is the smallest positive integer that is
divisible by both a and b (a|lcm & b|lcm).
We denote the least common multiple of a and b by
lcm(a, b) or simply [a,b].
Examples:
lcm(3, 7) = 21
lcm(4, 6) = 12
lcm(5, 10) = 10
29
Least Common Multiples
Using prime factorizations and WLOG let

a = p1a1 p2a2 … pnan , b = p1b1 p2b2 … pnbn ,


where p1 < p2 < … < pn and ai, bi  non-ve Z for 1  i
n
lcm(a, b) = p1max(a1, b1 ) p2max(a2, b2 ) … pnmax(an, bn )

Example:
a = 60 = 22 31 51
b = 54 = 21 33 50
lcm(a, b) = 22 33 51 = 4275 = 540
30
GCD and LCM

a = 60 = 22 31 51

b = 54 = 21 33 50

gcd(a, b) = 21 31 50 =6

lcm(a, b) = 22 33 51 = 540

Theorem: ab = gcd(a,b)lcm(a,b)

31
Exercise : Prove the theorem.

You can use


MAX(a,b) + MIN(a,b) = a + b

32
Modular Arithmetic
Motivation
Let us use a clock as an example. Look
carefully at this clock.
Notice, I have replaced the 12 at the top
of the clock with a zero.

Starting at noon, the hour hand points in order to the


following :

This is, in fact, the way in which we count


in modulo 12. When we add 1 to 11, we arrive
back at 0.
Modular Arithmetic
Let a be an integer and n be a positive integer.
We denote by a mod n the remainder when a is divided by n.

So, when a = qn + r we write a mod n = r

Examples:

9 mod 4 = 1
9 mod 3 = 0
9 mod 10 = 9
-13 mod 4 = 3 Reason: -13 = ( -4 )4 + (3)
34
Properties of Modular
Arithmetic

1. [(a mod n) + (b mod n)] mod n = (a + b) mod n


2. [(a mod n) - (b mod n)] mod n = (a - b) mod n
3. [(a mod n) x (b mod n)] mod n = (a x b) mod n
Congruences
Let a and b be integers and m be a positive integer.
We say that a is congruent to b modulo m

•if m divides a – b.
•Notation to indicate that a is congruent to b
modulo m is a  b (mod m) .
•In other words:
a  b (mod m) if and only if a mod m = b mod m.
•Or, if the remainder when a is divided by m is
same when b is divided by m.

36
Congruences
Examples:
Is it true that 46  68 (mod 11) ?
Yes, because 11 | (46 – 68=-22).

Is it true that 46  68 (mod 22)?


Yes, because 22 | (46 – 68).

For which integers z is it true that z  12 (mod 10)?


It is true for any z{…,-28, -18, -8, 2, 12, 22, 32, …}

37
Properties of Congruence relation:
Theorem 1: Let m be a positive integer.
The integers a and b are congruent modulo
m if and only if there is an integer k such
that a = b + km.
Theorem 2: Let m be a positive integer. If
a  b (mod m) and c  d (mod m), then
i) a + c  b + d (mod m) and
ii) ac  bd (mod m).

38
Congruences
Proof for Thm 2:
We know that a  b (mod m) and c  d (mod m)
implies that there are integers s and t with
b = a + sm and d = c + tm.
Therefore,
b + d = (a + sm) + (c + tm) = (a + c) + m(s + t) and
bd = (a + sm)(c + tm) = ac + m(at + cs + stm).
Hence, a + c  b + d (mod m) and ac  bd (mod m).

39
Applications…

Some applications are discussed in


another ppt.

40
The Euclidean Algorithm

The Euclidean Algorithm was known


to Euclid, and appears in ”The
Elements”. This Algorithm is an
important theoretical tool as well
as a practical algorithm.

41
Euclid’s “Element”
• The Elements is a mathematical treatise consisting of 13 books
attributed to the Greek mathematician Euclid, 300 BC.

• These books cover plane and solid Euclidean geometry, elementary number
theory, and incommensurable lines.

• Elements is a collection of definitions, postulates, propositions (theorems


and constructions), and mathematical proofs of the propositions.

• Euclid put together the Elements, collecting many of the work from
earlier Greek mathematicians in a single, logically coherent framework.
• He collected Eudoxus' theorems, perfecting many of Theaetetus', and
also proving things which were only somewhat loosely proved by his
predecessors".
• The source for most of books I and II : Pythagoras (c. 570–495 BC)
• for book III : Hippocrates of Chios (c. 470–410 BC),
• for book V : Eudoxus of Cnidus (c. 408–355 BC),
• For books IV, VI, XI, and XII probably came from other Pythagorean or
Athenian mathematicians
The Euclidean Algorithm

The Euclidean Algorithm finds the greatest


common divisor of two integers a and b.

For example, to find gcd(287, 91):

We divide 287 by 91:


287 = 913 + 14
This means, gcd(287, 91) = gcd(14, 91).

43
In the next step, we divide 91 by 14:
91 = 146 + 7
This means that gcd(14, 91) = gcd(14, 7).
And, 7 | 14, and thus gcd(14, 7) = 7.

Therefore, gcd(287, 91) = 7.

44
Proof:
Lemma 3.3.1 Suppose a and b are integers, not both zero.
a) (a,b) = (b,a),
b) if a > 0 and a|b then (a,b) = a,
c) if a ≡ c(mod b), then (a,b) = (c,b).
Proof.
Part (a) is clear, since a common divisor of a and b is a common divisor of b and a.
For part (b), note that if a|b, then a is a common divisor of a and b. Clearly a is the
largest divisor of a, so we are done.
Finally, for part (c):
If a ≡ c(mod b), then b|(a−c), so there is a y such that a − c = by, i.e., c = a − by.
If d divides both a and b, then it also divides a − by. Therefore, any common
divisor of a and b is also a common divisor of c and b.
Similarly, if d divides both c and b, then it also divides c + by = a, so any common
divisor of c and b is a common divisor of a and b.
This shows that the common divisors of a and b are exactly the common divisors
of c and b.
So, in particular, they have the same greatest common divisor. 45
To compute (a,b) : Divide the larger number (say a) by the
smaller number,

So, a = bq1+ r1 and r1 < b.

By last Lemma, part (c): (a, b) = (b, r1).

Now b = r1q2 + r2, r2 < r1, and (b, r1) = (r1, r2);
then r1= r2q3 + r3, r3< r2, and (r1, r2) = (r2, r3), and so on.

Since r1> r2 > r3 …, eventually some rk= 0 and

(a, b) = (b, r1) = (r1, r2) = (r2, r3) = … = (rk-1, rk) = (rk-1, 0) = rk-1;

Thus, (a,b) is the last non-zero remainder we compute. Note


that (a,0) = a. 46
Example: gcd of 168 and 198
This gives us :
198 = 168(1) + 30 (198,168) = (168,30)
168 = 30(5) + 18 = (30,18)
30 = 18(1) + 12 = (18,12)
18 = 12(1) + 6 = (12,6)
12 = 6(2) + 0 = (6,0)
= 6.

47
Some more examples
1) 252 and 105
2) 1071 and 462
3) 57 and 114

Answers :
21, 21, 57.
With a little extra bookkeeping, we can
use the Euclidean Algorithm to show
that gcd(a,b) is actually a linear
combination of a and b.

49
For example, 198 = 168(1) + 30
168 = 30(5) + 18
30 = 18(1) + 12
Thus, (198,168) = 6 18 = 12(1) + 6
12 = 6(2) + 0

50
Notice that the numbers in the left column are
precisely all the remainders computed by the
Euclidean Algorithm.

With a little care, we can turn this into a nice


theorem, the Extended Euclidean Algorithm…

51
The Extended Euclidean Algorithm

Statement : Suppose a and b are integers,


not both zero. Then there are
integers x and y such that
(a,b) = ax + by.

52

You might also like