Lecture 6-Division Algorithm
Lecture 6-Division Algorithm
Learning Objectives
To apply division algorithm
To apply the Euclidean algorithm
Algorithms
An algorithm is a systematic procedures (instructions)
for calculation.
𝑎 = 𝑏𝑞 + 𝑟
where 0 ≤ 𝑟 < 𝑏.
a – integer
b – integer > 0
q – quotient
r – remainder
Algorithms
𝑎 = 𝑏𝑞 + 𝑟
31 3
q = = 4 = 4.428571 = 4
7 7
◦ So a = bq + r gives 31 = 7 ∙ 4 + 3
Given a, b:
Example: (3)(5) = 15
◦ 15 is the multiple of 3 and of 5.
◦ 3 and 5 are divisors (factors) of 15.
Common Factor
Let m, n be positive integers.
Examples:
1. What is the common factor for 16 and 24
2. What is the common factor for 15 and 30
Common Multiple
A positive integer p is a common multiple of m and n if it is a
multiple of both of them
Examples:
1. Which of the following is the common multiple of 3 and 6?
1. 15
2. 18
3. 24
4. 27
?
gcd (18, 24) = 6
Examples:
1. What is the LCM of 8 and 6?
2. What is the LCM of 3 and 4?
22 = 2 ∙ 8 + 6 96 22 96 22
lcm(96,22) = = = 1056
gcd(96,22) 2
8=1∙6+2
6=3∙2 No remainder
Example 2
22 = 2 ∙ 8 + 6 96 22 96 22
lcm(96,22) = = = 1056
gcd(96,22) 2
8=1∙6+2
6=3∙2 No remainder
Example 3
63 = 15 ∙ 4 + 3 63 256
lcm(63,256) =
gcd(63,256)
4=1∙3+1
63 256
= = 16,128
1
3=3∙1 No remainder
Example 3
63 = 15 ∙ 4 + 3 63 256
lcm(63,256) =
gcd(63,256)
4=1∙3+1
63 256
= = 16,128
1
3=3∙1 No remainder
Extension to the Euclidean Algorithm
If d = gcd(m, n) then d can be expressed
as a linear combination
d = xm + yn
of m and n, where x and y are integers
x=3, y=-13
Example 5
It can be shown that the gcd of 256 and 63 equals 1:
256 = 4 ∙ 63 + 4
63 = 15 ∙ 4 + 3
4=1∙3+1
3=3∙1
Then we work upwards from the second-last line, as follows:
1=4-1∙3
1 = 4 – 1 ∙ (63 – 15 ∙ 4)
1= 4 - 1 ∙ 63 + 1 ∙ 15 ∙ 4
1 = 16 ∙ 4 – 1 ∙ 63
1 = 16 ∙ (256 – 4 ∙ 63) – 1 ∙ 63
1 = 16 ∙ 256 – 64 ∙ 63 - 1 ∙ 63
1 = 16 ∙ 256 – 65 ∙ 63
So 1 = 16 ∙ 256 – 65 ∙ 63.
The End