cns 3
cns 3
In general,
gcd(60, 24) = gcd(60, -24) = 12
We stated that two integers a and b are relatively prime if their only
common positive integer factor is 1. This is equivalent to saying that a
and b are relatively prime if gcd(a, b) = 1.
8 and 15 are relatively prime because the positive divisors of 8 are 1, 2, 4, and 8, and the
positive divisors of 15 are 1, 3, 5, and 15. So 1 is the only integer on both lists.
Finding the Greatest Common Divisor
we have integers a, b such that d = gcd(a, b). Because
there is no harm in assuming a b 0. Now dividing a by b and applying the division
algorithm, we can state:
But if r1 0, we can state that d r1.
This is due to the basic properties of divisibility:
The relations d a and d b together imply that d (a - q1b), hence d r1.
Before proceeding with the Euclidian algorithm, we need to answer the question:
What is the gcd(b, r1)?
We know that d b and d r1.
Now take any arbitrary integer c that divides both b and r1.
The result is the following system of equations:
11 mod 7 = 4;
- 11 mod 7 = 3
Two integers a and b are said to be congruent modulo n,
if (a mod n) = (b mod n).
This is written as a b (mod n)
if (a mod n) = (b mod n).
73 mod 23 = 4
4 mod 23 = 4
Hence, 73 is congruently equal to 4 when we applying mod 23 on those numbers.
73 4 (mod 23)
21 mod 10 = 1
-9 mod 10 = 1
Hence, -9 is congruently equal to 21 when we applying mod 10 on those numbers.
-9 21 (mod 10)
-8 mod 3 = ? 8+1 mod 3 = 9 mod 3 = 0
-8 mod 3 = 1
-8 mod 12 = ? Ans: 4
-12 mod 24 = ? Ans: 12
72 24 (mod 8)
72 72 mod 8 0
24 24 mod 8 0
A mod n = b mod n
A b mod n
72 24 mod 8
117 mod 13 = ?
Properties of Congruences
Ex:
-11 mod 8 = 5. How?
Ans: (11 + ?) mod 8 = 0
(11 + 0) mod 8 0
(11 + 1) mod 8 0
(11 + 2) mod 8 0
(11 + 3) mod 8 0
(11 + 4) mod 8 0
(11 + 5) mod 8 = 16 mod 8 = 0
Modular Arithmetic Operations
The (mod n) operator maps all integers into the set of integers {0, 1, …., (n -
1)}.
Modular arithmetic exhibits the following properties:
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) * (b mod n)] mod n = (a * b) mod n
11 mod 8 = 3; 15 mod 8 = 7
[(11 mod 8) + (15 mod 8)] mod 8 = 10 mod 8 = 2
(11 + 15) mod 8 = 26 mod 8 = 2
[(11 mod 8) - (15 mod 8)] mod 8 = -4 mod 8 = 4
(11 - 15) mod 8 = -4 mod 8 = 4
[(11 mod 8) * (15 mod 8)] mod 8 = 21 mod 8 = 5
(11 * 15) mod 8 = 165 mod 8 = 5
Example for the 3 properties:
11 mod 8 = 3; 15
mod 8 = 7
[3] = {…., -13, -9, -5, -1, 3, 7, 11, 15, 19, ……}
Of all the integers in a residue class, the smallest nonnegative integer is the
one used to represent the residue class.
Finding the smallest nonnegative integer to which k is congruent modulo n is
called reducing k modulo n.
Properties of Modular Arithmetic for Integers in Zn
Equation (4.4) is consistent with the existence of an additive inverse. Adding
the additive inverse of a to both sides of Equation (4.4), we have,
((-a) + a + b) ((-a) + a + c) (mod n)
b c (mod n)
if (a x b) (a x c) (mod n) then b c (mod n) if a is relatively prime to n.
Recall that two integers are relatively prime if their only common positive
integer factor is 1.
Applying the multiplicative inverse of a to both sides of Equation (4.5), we
have
((a-1)ab) ((a-1)ac) (mod n)
b c (mod n)
The integers 6 and 8 are not relatively prime, since they have the common
factor 2. We have the following:
6 * 3 = 18 2 (mod 8)
6 * 7 = 42 2 (mod 8)
The reason for this strange result is that for any general modulus n, a
multiplier a that is applied in turn to the integers 0 through (n - 1) will fail to
produce a complete set of residues if a and n have any factors in common.
In general, an integer has a multiplicative inverse in Z n if that integer is relatively
prime to n. Table 4.2c shows that the integers 1, 3, 5, and 7 have a multiplicative
inverse in Z8; but 2, 4, and 6 do not.