Discrete Mathematics: Theory of Numbers

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 38

Discrete Mathematics

Theory of Numbers
Theory of Numbers

Part 3
Primes

Definition 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.
• Examples 7 is prime. 9 is composite.
• Note 1 is not prime, nor composite.
• Some primes: 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47…
Primes
A positive integer p>1 is called a prime if its only
divisors are 1 or -1 and p or –p

i.e., if p has only trivial divisors

If p is not prime, then it is called composite

If n > 1 is composite then n = ab


where 1<(a, b)<n
Primes.
• Theorem If n is a composite integer, then n has a prime
divisor less than or equal to n.

• An integer n is prime if it is not divisible by any prime less


than or equal to n. (if there is no root, then truncated to the next lower
integer)
– 101 is prime, since 101 is not divisible by 2, 3, 5, or 7 (the only
primes less or equal than 101.)

• Prime factorization of 7007:


– Divide 7007 by primes, it divides by 7: 7007/7 = 1001.
– Divide 1001 by primes, starting with 7… 1001/7 = 143.
– Divide 143 by primes, starting with 7… 143/11 = 13.
– Stop, since 13 is prime. 7007 = 72  11  13
The Fundamental Theorem of
Arithmetic
Every positive integer n> 1 can be written uniquely as the
product of primes, in essentially one way.
(Difficult to prove, but we can use induction)

Note: The ‘Product’ can have a single factor.

Examples.
100 = 22  52
641 = 641
999 = 33  37
1024 = 210
17 = 171
Primes.
Inductive proof

Let n = 2 . Since 2 is prime, n is a product of primes. (with


single factor)
Suppose,
• n is greater than 2and
• The theorem holds good for positive integers less than n

Question : What is the next step ?


Supposing that the theorem holds good for positive integers
less than n
We have to prove that the theorem holds for n
Primes
Case I : n is prime (straightforward case)

It is a product of prime having only one factor


example: 37 = 37

Case II : n is composite

Then n = a * b , where a , b < n (a and b can be prime or


composite)

We have assumed that the theorem is true for integers < n


It is true for a and b, i.e., a and b are products of primes.
Therefore, n is a product of products of primes
Primes
There is no largest prime
That means, there exists an infinite number of primes

Suppose there is a finite number of primes


p1, p2, p3, p4….pm

Let pk is in the set {p1, p2, p3, p4… pk. ….pm}

Say, n = ( p1 * p2 * p3 * p4… * pk. … * pm ) + 1;

Therefore, according to the assumption, n is composite


So it is divisible by some pk <n

So, (n - p1 * p2 * p3 * p4… * pk. … * pm ) is divisible by pk


It is impossible. So, our assumption was wrong.
Primes
Prime Factorization
Every integer n> 1 can be expressed uniquely as a
product of primes

Any prime can appear more than once

n = p1m1 p2m2 p3 m3 p4 m4 …. pr mr

Where p1 < p2 < p3 …..,pr

This is called canonical factorization of n


Greatest Common Divisors
Greatest Common Divisors

Definition
In mathematics, the Greatest Common
Divisor (GCD) of two or more integers, when
at least one of them is not zero, is the
largest positive integer that divides the
numbers without a remainder.

For example, the GCD of 8 and 12 is 4.


Greatest Common Divisors

Let a and b be integers, not both zero. The


largest integer d such that d | a and d | b ,
denoted by gcd(a, b), is called the greatest
common divisor of a and b.
– Examples gcd(24, 36) = 12.
gcd(17, 22) = 1.
gcd (-12, -18) = 6
Greatest Common Divisors

GCD divides the difference


Let d to be a common divisor (gcd or
otherwise) of a and b

Then there exist p and q such that


a = d.p and b = d.q
So, a – b = dp-dq = d(p-q)
So, d | (a-b)  divisor divides the difference
So, GCD of two integers divides the difference
of both integers.
Greatest Common Divisors

Euclidean Algorithm
Let a = 540, b = 168
We can write: (in division algorithm style)
540 = 168 * 3 + 36
168 = 36 * 4 + 24
36 = 24 * 1 + 12
24 = 12 * 2 + 0 Stop when remainder is 0,
i.e., when the remainder
divides the difference
Greatest Common Divisors

The Euclidean algorithm is based on the


principle that the greatest common divisor of
two numbers does not change if the larger
number is replaced by its difference with the
smaller number. For example, 21 is the GCD
of 252 and 105 (252 = 21 × 12 and
105 = 21 × 5), and the same number 21 is also
the GCD of 105 and 147 = 252 − 105.
Greatest Common Divisors

It follows from the fact that

gcd (540,168) =
gcd (168,36) =
gcd (36, 24) =
gcd ( 24, 12) = 12
Greatest Common Divisors

Proof of Euclidean Algorithm

To find x = gcd(a,b)…..largest positive that


divides a and b
x=gcd(a,b). So, x|a and x|b
Let a>b and a = qb + r
Now, x|qb  x|(a-qb)  x|r
gcd (a,b)  gcd(b,r)
Greatest Common Divisors

Similarly, say, b = q`r + r`


gcd (a,b) = gcd(b,r) = gcd(r,r`)

Continue till r`=0

That is , as soon as we find a common divisor,


we don’t factorize it any more.
Greatest Common Divisors

• Procedure to find gcd(a, b):


– Find the prime factorization of a and b.
– If a = p1a1 p2a2… pnan, b = p1b1 p2b2… pnbn, then
min(a1,b1) min(a2,b2) min(an,bn)
gcd(a, b) = p1 p2 … pn
– Examples
120 = 23  3  5 and 500 = 22  53
gcd(120, 500) = 22  51 = 20.
Greatest Common Divisors

Theorem
GCD of two integers a and b can be expressed as (ax
+ by) where x and y are some integers.

Example: Find x and y from


540x + 168y=12
Greatest Common Divisors

540 = 168 * 3 + 36
168 = 36 * 4 + 24
36 = 24 * 1 + 12
24 = 12 * 2 + 0
Greatest Common Divisors

540 = 168 * 3 + 36
168 = 36 * 4 + 24
36 = 24 * 1 + 12  12 = 36 – 24 * 1
24 = 12 * 2 + 0
Greatest Common Divisors

540 = 168 * 3 + 36
168 = 36 * 4 + 24  24 = 168 – 36 * 4
36 = 24 * 1 + 12  12 = 36 – 24 * 1
24 = 12 * 2 + 0
Greatest Common Divisors

540 = 168 * 3 + 36  36 = 540 – 168 * 3


168 = 36 * 4 + 24  24 = 168 – 36 * 4
36 = 24 * 1 + 12  12 = 36 – 24 * 1
24 = 12 * 2 + 0
Greatest Common Divisors

Calculating backwards
12 = 36 – 1 * 24
= 36 – 1 * (168 – 4 * 36)
= 36 – 1 * 168 + 4 * 36
= 5 * 36 – 1 * 168
= 5 * (540 – 3 * 168) – 1 * 168
= 5 * 540 – 15 * 168 – 1 * 168
= 5 * 540 – 16 * 168
Greatest Common Divisors

Calculating backwards We can write


12 = 36 – 1 * 24 gcd (a, b) = ax + by
= 36 – 1 * (168 – 4 * 36) Here, a = 540, b = 168
= 36 – 1 * 168 + 4 * 36 x = 5, y= -16
= 5 * 36 – 1 * 168
= 5 * (540 – 3 * 168) – 1 * 168 Extended
= 5 * 540 – 15 * 168 – 1 * 168 Euclidean
Algorithm
= 5 * 540 – 16 * 168
Greatest Common Divisor

Exercise

GCD of 864 and 291 as an integer linear form in 864 and 291.

i.e., 864x + 291y

x , y: integers

Answer:
x = 32, y = -95

27
Greatest Common Divisors

In fact, the GCD is the smallest positive integer of the


form ax+by.

From extended Euclidean theorem we saw


For integers a and b, there exist integers x and y where gcd
(a, b) = ax + by

Now, gcd divides a and b


So, gcd divides all integers of the form ax + by
Greatest Common Divisors

Also, gcd can not divide any positive integer less


than itself.

So, no integer less than gcd is of the form ax + by

So, gcd is the smallest positive integer of the form


ax + by.
Greatest Common Divisors

(a) For any integer a, we have gcd(1,a) = 1


(b) For any prime p, we have
if p|a then gcd (p, a) = p
else gcd (p, a) = 1;

(c) Suppose a is positive.


Then a | b if and only if gcd(a,b)=a
Greatest Common Divisors

• Simple properties

(a) gcd (a,b) = gcd (b,a)


(b)If x>0 then gcd (ax,bx)=x*gcd(a,b)
(c) If d = gcd(a,b) then gcd(a/d, b/d)=1
(d)For any integer x,
gcd (a, b) = gcd (a, b+ax)
Greatest Common Divisors

Proof (might skip)

Say, d=gcd(a,b)
Let a=p.d and b=q.d
Observe that p and q are relatively prime
Therefore, gcd(p, q)=1
Greatest Common Divisors

Now, let c = gcd (a, b+ax)


= gcd (pd , qd + pdx) = d. gcd (p, q+px)

Since p and q are relatively prime,


Whereas p and px are not,
Therefore, p and q + px are relatively prime
gcd(p, q + px) = 1
Therefore, c=d
Greatest Common Divisors

Relatively prime integers


Two integers a and b are said to be relatively
prime or co-prime if gcd (a,b) = 1
Example
gcd(12,35), gcd(49,18),
gcd(21,64), gcd(-28,45)

Accordingly, if a and b are relatively prime, then


there exist integers x and y such that ax + by = 1
Greatest Common Divisors

GCD divides the difference


e.g. 3 divides the difference of 15 and 24

………………………………………….
For any integer a, we have gcd(a, a+1)=1
It follows from the fact that any common
divisor of a and a +1 must divide their
difference, that is (a+1)-a=1
Greatest Common Divisors

If a and b are co-primes

Then there exist integers x and y

Where ax + by = 1

Obviously, either x or y is negative.


Relatively Prime Integers

• Definition The integers a and b are relatively


prime if gcd(a, b) = 1.
– Example 17 and 22 are relatively prime.

• Definition The integers a1, a2, …, an are pairwise


relatively prime if gcd(ai, aj)=1 whenever 1i<jn.
– Examples
10, 17 and 21 are pairwise relatively prime.
10, 17 and 24 are not pairwise relatively prime.
GCD
Let d be the smallest positive integer of the form
ax+by .

Then d=gcd(a,b)

Proof: All the numbers that can be expressed in the


form ax+by are divisible by d.
GCD divides itself. So, d can also be expressed as
ax+by.
Since d can not divide any number less than itself, it
the lowest integer which can be expressed as ax+by

You might also like