CSI3022__MODULE1__1__GCD (1)
CSI3022__MODULE1__1__GCD (1)
Security
1
C OURSE I NFORMATION
2
S YLLABUS
3
Syllabus
4
Text & Reference Books
5
Mode of Evaluation
6
M ODULE - 1
7
Number Theory
8
Number System
Some of the fundamental number system are:
• The natural numbers, N, (also known as non negative
numbers). Ex: 1,2,3,4,…
• The whole numbers, W , are the set of natural numbers along
with the number 0. Ex: 0,1,2,3,4…
• The integers, Z , obtained by adding negative numbers to W.
Ex: …-2,-1,0,1,2,3,4,…
• The rational numbers, Q, obtained by adjoining reciprocals
of nonzero intergers to Z . Form of p/q where ‘q’ is not equal
to zero. Ex: 1/2, 1/5, 3/4
• The real numbers, R, any number that we can think of,
except complex numbers, is a real number.
9
Whole Number
10
Natural Number
• Natural Number is an integer greater than 0
• It is a member of the set {1,2,3,4….}
• Natural Numbers are also known as counting
numbers.
11
Factor
Prime Number
Composite Number
Co-Prime Number
12
Factor
13
Factor
• A factor is a number that divides another
number evenly with no remainder
• Factors are numbers you multiply to get other
numbers
Factors of 24: ?
14
Factor
15
Factor
Factors of 24:
1,2,3,4,6,8,12,24
16
Factor
Factors of 48 : ?
Factors of 32: ?
17
Factor
Factors of 48:
1,2,3,4,6,8,12,16, 24, 48
18
Factor
Factors of 32:
1, 2, 4, 8, 16, 32
19
Prime Number
• They have no other factors except for 1 and the
number itself
• A number that can only be factored as 1 times
itself is called "prime".
• 1 is not a prime number. It doesn’t have two
distinct factors.
• 2, 3, 5, 7, 11, 13, 17, 19, 23 ,29. ...
Composite Number
• Numbers that have more than 2 factors are called
as Composite numbers
• Positive Integers that have more than 2 factors
• Numbers that are divisible by more than two
numbers.
• 4, 6, 8, 9, 10, 12, 14, 15, 16, ...
Co-Prime Number
• Set of numbers that have GCD as 1 are called as Co-
Prime Numbers
• For instance 7 and 8 are co-prime numbers
23
Greatest Common Divisor
• GCD of two or more integers which are not
zero is the greatest positive integer that divides
each of the integers.
• GCD of two numbers is the greatest number
that divides both the numbers.
• Ex: GCD of 12 and 8 is 4
24
GCD using Factorization
25
GCD(12,33)=?
26
GCD using Factorization
EX:1
GCD(12,33)=3
27
GCD(25,150)=?
28
GCD using Factorization
EX:2
GCD(25,150)=25
29
GCD(13,33)=?
30
GCD using Factorization
EX:3 - Prime numbers
GCD(13,33)=?
31
Identify the co-prime numbers
• 24, 36
• 20, 21
• 542, 446
Identify the co-prime numbers
24, 36
24 = 2 × 2 × 2 × 3
36 = 2 × 2 × 3 × 3
Common factors: 2 × 2 × 3 = 12
Identify the co-prime numbers
20, 21
20 = 2 × 2 × 5
21 = 3 × 7
No common factors other than 1
Identify the co-prime numbers
542, 446
542 = 2 × 271
446 = 2 × 223
Common factors: 2
Identify the co-prime numbers
24, 36
24 = 2 × 2 × 2 × 3
36 = 2 × 2 × 3 × 3
Common factors: 2 × 2 × 3 = 12
20, 21
20 = 2 × 2 × 5
21 = 3 × 7
No common factors other than 1
542, 446
542 = 2 × 271
446 = 2 × 223
Common factors: 2
GCD by Division Method
37
GCD by Division Method
1. First take two of the given numbers
2. Divide the greater by the smaller number
3. Then divide the divisor by the remainder
4. The divisor which does not leave a remainder
is the gcd of the two numbers.
38
GCD(1785,546)=?
39
EXAMPLE
40
GCD(48,60)=?
41
EXAMPLE
GCD(48,60)=?
48)60(1
48
12)48(4
48
0
GCD (48,60)=12
42
GCD(48,60,38)=?
43
GCD(48,60,38)=?
gcd(a,b,c)=gcd(gcd(a,b),c)
44
EXAMPLE
GCD(48,60,38)=?
48)60(1
48
12)48(4
48
0
GCD (48,60,38)=2
45
GCD(48,60,54,12)=?
46
GCD(48,60,54,12)=?
Gcd(a,b,c,d)=gcd(gcd(a,b),gcd(c,d))
47
GCD(48,60,54,12)=6
48
GCD by Division Method - Exercise
• Find the GCD of 30 and 45
55
Divisibility
56
Divisibility Property
57
Divisibility Property
EX: a=4, b=4, 4|4=0
Ex: 0|2, 0|4,…
58
Divisibility Property
59
Division algorithm
Non-negative Integer
Positive Integer
Dividing -11 by 7:
We repeatedly add until we get a number from 0 to 7-1=6 .
-11+7=-4
-4+7=3
2 times 7 is added to get number from 0 to 6
3+7=10
So, (-2)*7+3=-11 60
Division algorithm
a=70, n=15
61
Division algorithm
62
Euclidean Algorithm
63
Euclidean Algorithm
64
Euclidean Algorithm
gcd(a,b)=c
65
Euclidean Algorithm
66
Euclidean Algorithm
67
Euclidean Algorithm
68
Euclidean Algorithm
69
Euclidean Algorithm
70
Euclidean Algorithm
EX:1
71
Euclidean Algorithm
72
Euclidean Algorithm
73
Euclidean Algorithm
EX:1
74
Euclidean Algorithm
EX:2
75
Euclidean Algorithm
EX:2
76
Euclidean Algorithm
EX:3
77
Euclidean Algorithm
EX:3
78
Euclidean Algorithm
EX:4
GCD(1005,105)=?
79
Euclidean Algorithm
EX:4
GCD(1005,105)=15
80
Euclidean Algorithm
EX:5
GCD(710,310)=?
81
Euclidean Algorithm
EX:5
GCD(710,310)=10
82
Euclidean Algorithm
83
GCD(710,310)=10
Euclidean Algorithm
Example:
Example:
Proof
86
Euclidean Algorithm
87
Euclidean Algorithm
88
Euclidean Algorithm
89
Euclidean Algorithm
Example:
90
Euclidean Algorithm
91
Euclidean Algorithm
92
Euclidean Algorithm
93
Euclidean Algorithm
EX:6
GCD(25,60)=?
94
Euclidean Algorithm
95
Euclidean Algorithm
96
Euclidean Algorithm
EX:7
GCD(2740,1760)=?
97
Euclidean Algorithm
98
gcd(2740,1760)=?
gcd(2740,1760)=20 99
Extended Euclidean Algorithm
100
Extended Euclidean Algorithm
101
Extended Euclidean Algorithm
a. Process
102
Extended Euclidean Algorithm
b. Algorithm
a b 1 0 0 1
Extended Euclidean Algorithm
EX:8
GCD(161,28)=?
104
Extended Euclidean Algorithm
(-1) * 161 + 6 * 28 = 7
Or
161 (-1) + 28 (6) = 7
-161+168 = 7
7=7 105
Extended Euclidean Algorithm
EX:9
GCD(17,0)=?
106
Extended Euclidean Algorithm
107
Extended Euclidean Algorithm
EX:11
GCD(0,45)=?
108
Extended Euclidean Algorithm
109
Extended Euclidean Algorithm
GCD(188,46)=?
110
Extended Euclidean Algorithm
GCD(188,46)=?
gcd(188, 46) = 2
s = -11
t = 45
111
Extended Euclidean Algorithm
GCD(258,62)=?
112
Extended Euclidean Algorithm
GCD(258,62)=?
gcd(258, 62) = 2
s = -6
t = 25
113