Modular Arithmetic
Modular Arithmetic
- If it is 11 o'clock and you have to finish your math homework in 18 hours, what hour will it be at that time?
Answer: 11 + 18 = 5.
Hence the time that the homework could it be finished is 5 o’clock.
- If it is 12:00 now, what time is it in 12 hours? What is the remainder when you divide 12 by 12?
Answer: Using the 12-hour clock based on the given figure above, if it is now 12:00, the time after another
12 hour is also 12 o’clock and it has an equivalent number as zero (0).
If we are going to divide 12 by 12, it is very obvious that the remainder is 0.
- If it is 12:00 now, what time is it in 18 hours? What is the remainder when you divide 18 by 12?
Answer: Similar on what we do to example 3, if it is now 12:00, adding 18 hours starting from 12 (0) would
give us 6 o’clock. Dividing 18 by 12, the remainder would be 6. Hence, the time after 18 hours starting to 12
o’clock is 6 o’clock.
4 + 6 = 3 (Thursday)
and
0 + 16 = 2 (Wednesday)
Monday = 0
Tuesday = 1
Wednesday = 2
Thursday = 3
Friday = 4
Saturday = 5
Sunday = 6
Let us say today is Wednesday. What would be the day 11 days after Wednesday? What
would be the remainder if we are going to divide 11 by 7?
Answer: Based on our given days in a week above, the equivalent number for Wednesday is 2. Adding
11 days after Wednesday, we got Sunday where this day has an equivalent number as 6. Adding 2
by 11, the result is 13 and if we are going to divide 13 by 7, the result is 6. Hence, 2 + 11 = 6.
Activity:
Modular Arithmetic
Two integers a and b are said to be congruent modulo n, where n is an element of N, if is an integer. In
this case, we write a ≡ b (mod n). The number n is called the modulus. The statement a ≡ b (mod n) is called
a congruence.
This could be stated in this form.
If a, b ∈ Z and n ∈ Z+ , then a ≡ b (mod n) if and only if n | a – b.
Based on the given table above, each expression follows the modular arithmetic under modulo 12.
a) 12 ≡ 0 (mod 12)
b) 21 ≡ 9 (mod 12)
c) 37 ≡ 1 (mod 12)
d ) 17≡ 5 (mod 12)
Another way to be able to write in a congruence modulo n is by dividing by n and take the remainder. Let
us say n = 3. Then;
14(mod 3) ≡ 2; that is 14 = (3)(4) + 2. The remainder is 2.
9 (mod 3) ≡ 0; that is 9 = (3)(3) + 0. The remainder is 0.
2 (mod 3) ≡ 2; since 2 = (3)(0) + 2.
-1 (mod 3) ≡ 2; since -1 = (3)(-1) + 2
-5 (mod 3) ≡ 1; since -5 = (3)(-2) + 1. The remainder is 1.
An alternative method to determine a true congruence in a ≡ b(mod n), where a and b are whole numbers,
then when a and b is divided by n, they must have the same remainder.
Let us say the given modulo is 53 ≡ 17 (mod 3). Now, if we divide 53 to 3, then;
53 = (3)(17) + 2. The remainder is 2
and if we divide 17 to 3, we get;
17 = (3)(5) + 2. The remainder is also 2.
Theorem
For arbitrary integers a and b, a ≡ b(mod n) if and only if a and b have the same remainder when divided by n.
Properties On Congruence
Let n > 0 be fixed and a, b, c and d are arbitrary integers. Then,
a) a ≡ a(mod n)
b) if a ≡ b(mod n) then b ≡ a(mod n)
c) if a ≡ b(mod n) and b ≡ c(mod n), then a ≡ c(mod n)
d) if a ≡ b(mod n) and c ≡ d(mod n), then a + c = b + d (mod n) and ac ≡ bd (mod n)
e) if a ≡ b(mod n), then a + c ≡ b + c (mod n) and ac ≡ bc (mod n)
f) If a ≡ b (mod n), then ak ≡ bk (mod n)
Activity:
Determine whether the following is congruence or not congruence. Write your answer on the right side of
each item.
a) 5 ≡ 8 (mod 3) f) 11 ≡ 15 (mod 4)
b) 5 ≡ 20 (mod 4) g) 7 ≡ 21 (mod 3)
c) 21 ≡ 45 (mod 6) h) 18 ≡ 60 (mod 7)
d) 88 ≡ 5 (mod 9) i) 72 ≡ 30 (mod 5)
e) 100 ≡ 20 (mod 8) j) 25 ≡ 85 (mod 12)
Direction: Answer the following questions. Write your answer after each item.
a) What is 13mod1?
b) What is -4mod9?
c) What is -13mod1?
d) What is -14mod2?
e) What is 14mod2?
Which of the following integers are valid for solutions for x?
1. Given x ≡ 17 mod 4
a) -43 b) -17 c) 15 d) 25
2. Given x ≡ 11 mod 8
a) -77 b) 77 c) 27 d) 25
Fill out the table of a modulo 4 addition table and transform each item in a form of a ≡ b mod n.
+ 0 1 2 3 a) 3 + 3 =
0 b) 2 + 3 =
1 c) 1 + 2 =
2 d) 0 + 0 =
3 e) 2 + 2 =
Operations of Modular Arithmetic
Operations of modulo n
1) addition modulo n
2) subtraction modulo n
3) multiplication modulo n
4) additive and multiplicative inverses.
29 ≡ 8 (mod 3)
2 ≡ 8 mod 3
8 mod 3 = 2
Addition Modulo n
Evaluate (23 + 38) mod 12.
61 mod 12.
(23 + 38) mod 12 ≡ 1
Subtraction Modulo n
Evaluate (14 – 27) mod 5.
(-13) mod 5
-13 ≡ x mod 5.
Multiplication Modulo n
Evaluate (15•23)mod 11.
345 = 11•31 + 4
Hence, (15•23)mod 11 = 4
Example
In mod 7 arithmetic, find the multiplicative inverse of 2.
2x ≡ 1 mod 7
2(1) ≡ 1 mod 7 (this is not a true congruence)
2(2) ≡ 1 mod 7 (this is not a true congruence)
2(3) ≡ 1 mod 7 (this is not a true congruence)
2(4) ≡ 1 mod 7 (this is a true congruence)
2(5) ≡ 1 mod 7 (this is not a true congruence)
2(6) ≡ 1 mod 7 (this is not a true congruence)
Hence, in mod 7 arithmetic, the multiplicative of 2 is 4.
Self-Learning Activity
B. Find the additive and multiplicative inverse of the following if any. If there is no additive
nor multiplicative inverse, explain why there is no such as inverses.
1) (x + 15) = 0 mod 29 x= 6) 5x = 1mod 9 x=
2) (23 + x) = 0 mod 27 x= 7) 14x = 1mod 41 x=
3) (x – 45) = 0 mod 89 x= 8) 6x = 1mod 41 x=
4) (46 – x) = 0 mod 16 x= 9) 7x = 1 mod 13 x=
5) (2x – 16) = 0 mod 18 x= 10) 11x = 1 mod 7 x=
Applications of Modular Arithmetic
The staple wire has a bar code of 9-02870-766290. Is the UPC number of this product a valid number?
d12 = 10 – [3(9) + 0 + 3(2) + 8 + 3(7) + 0 + 3(7) + 6 + 3(6) + 2 + 3(9)]mod 10
d12 = 10 – (27 + 0 + 6 + 8 + 21 + 0 + 21 + 6 + 18 + 2 + 27)mod 10
d12 = 10 – 136mod 10
136 = (10)(13) + 6
d12 = 10 – 6 = 4
Since the computed check digit is not the last digit in a given code, then the bar code is not valid.
Luhn Algorithm
uses mod 10 arithmetic
Credit card is usually or normally have 13 to 16 digits long. The first one to six digits are used to identify
the card issuer.
The table below shows some of the identification prefixes used by four popular card issuers.
Card Issuer Prefix Number of digits
Master Card 51 to 55 16
Visa 4 13 or 16
American Express 34 or 37 15
Discover 6011 16
1. Beginning with the next-to-last digit (the last digit is the check digit) and reading from right to left.
2. Double every other digit. If a digit becomes a two digit number after being doubled, treat the number
as two individual digits.
3. Find the sum of the new list of digits. The final sum must be congruent to 0 mod 10.
Example
Determine whether 5234-8213-3410-1298 is a valid card number.
Solution:
5 2 3 4 8 2 1 3 3 4 1 0 1 2 9 8
x2 x2 x2 x2 x2 x2 x2 x2
10 2 6 4 16 2 2 3 6 4 2 0 2 2 18 8
Then;
(1+0) + 2 + 6 + 4 + (1 + 6) + 2 + 2 + 3 + 6 + 4 + 2 + 0 + 2 + 2 + (1 + 8) + 8 = 60
Since 60 ≡ 0 mod 10, this is a valid card number.
A group is a set of elements, with one operation and it must satisfy the following four properties:
P1: The set is close with respect to the operation. For all a, b ∈ G, then a * b ∈ G. Note that the operation
would be + or •or in general *.
P2: The operation satisfies the associative law. For all a, b, c ∈ G, then (a * b) *c = a * (b * c)
P3: There must be an identity element. For every e ∈ G, such that e * a = a *e = a for all a ∈G
P4: Each element has an inverse. For each a ∈ G then for every a-1 ∈ G, such that a * a-1 = a-1 * a = e.
The binary operator addition mod 5, denoted by * is defined on the set Z = {0,1,2,3,4}. Show that (Z, *) is a
group.
* 0 1 2 3 4
0 0 1 2 3 4
1 1 2 3 4 0
2 2 3 4 0 1
3 3 4 0 1 2
4 4 0 1 2 3
P1: (Z, +) is closed since all members of the Cayley Table are in Z.
P2: In number theory, (a + b) + c mod n = a + (b + c) mod n. Hence, it is associative
P3: The identity element is 0, e = 0.
P4: Each element has an inverse. 0-1 = 0; 1-1 = 4; 2-1 = 3;
3-1 = 2; 4-1 = 1
Since all the properties satisfied, hence it is a group.
Show that the integers with addition as the operation form a group.
Solution:
P1. Let a, b ∈ Z. Now, a + b ∈ Z and (–a) + (– b) ∈ Z. Hence it is closed under addition.
P2. Let a, b, and c are element of an integer. The associative property of addition holds true for the integers,
i.e. (a + b) + c = a + (b + c).
P3. Let Z = {…-3,-2,-1,0,1,2,3,…}. The identity element of Z is 0 and 0 is an integer. Hence, there is an identity
for addition.
P4. Let Z = {…-3,-2,-1,0,1,2,3,…}. Each element of Z has an inverse, i.e. if a ∈ Z, then –a is the inverse of a.
Because each of the four conditions of a group is satisfied, the integers with addition as the operation
form a group or (Z, +) is a group.
Abelian Group
groups in which the operation satisfies the commutative property are called commutative group or
abelian group. If the group is a non-commutative property, it is called a non-abelian group.