5.1 Mathematical Systems
5.1 Mathematical Systems
Mathematical
Systems
Prepared by: Asst. Prof. Marcelo T. Buen
6.1 Modulo Arithmetic
In mathematics,
modular arithmetic
(sometimes called clock
arithmetic) is a system
of arithmetic for
integers, where numbers
wrap around after they
reach a certain value –
the modulus.
2
6.1 Modulo Arithmetic
Leonhard Euler
• pioneered the modern approach to
congruence in 1750, when he
explicitly introduced the idea of
congruence modulo a number N.
3
6.1 Modulo Arithmetic
5⊞6 7 ⊟ 11
1 ⊞ 16
6
6.1 Modulo Arithmetic
{0 , 1 , 2 , 3 , 4}.
7
6.1 Modulo Arithmetic
Zn = {0, 1, 2, …, n -1}
8
6.1 Modulo Arithmetic
9
6.1 Modulo Arithmetic
𝐚
𝐡𝐚𝐬 𝐚 𝐫𝐞𝐦𝐚𝐢𝐧𝐝𝐞𝐫 𝐫 < 𝐧
𝐧
10
6.1 Modulo Arithmetic
In Z8, what is 4 + 9?
Answer: 5
5 is the remainder when 13 is divided by 8.
11
6.1 Modulo Arithmetic
Answer: 4
12
6.1 Modulo Arithmetic
Answer: 0
13
6.1 Modulo Arithmetic
In Z8, what is 22 - 3?
Answer: 3
14
6.1 Modulo Arithmetic
Answer: 7
15
6.1 Modulo Arithmetic
In Z8, what is 11 5? .
Answer: 7
16
6.1 Modulo Arithmetic
Answer: 8
17
6.1 Modulo Arithmetic
Answer: 3
18
6.1 Modulo Arithmetic
In Z15, what is 14 6? .
Answer: 9
19
6.1 Modulo Arithmetic
20
6.1 Modulo Arithmetic
21
6.1 Modulo Arithmetic
𝒂 ≡ 𝒃 mod n
n: modulus
congruence
22
6.1 Modulo Arithmetic
TRUE or FALSE.
29 ≡ 8 mod 3
TRUE
29 −8
because 3 is 7
and 7 is an integer.
23
6.1 Modulo Arithmetic
TRUE or FALSE.
15 ≡ 4 mod 6
FALSE
15 −4 5
because is 16
6
5
and 1 is NOT an integer.
6
24
6.1 Modulo Arithmetic
TRUE or FALSE.
37 ≡9 mod 7
TRUE
25
6.1 Modulo Arithmetic
TRUE or FALSE.
115 ≡ 10 mod 3
TRUE
26
6.1 Modulo Arithmetic
TRUE or FALSE.
84 ≡3 mod 9
TRUE
27
6.1 Modulo Arithmetic
Solve 3x + 5 ≡ 3 mod 4.
If x = 0, is 3(0) + 5 ≡ 3 mod 4? No
If x = 1, is 3(1) + 5 ≡ 3 mod 4? No
2 , 6, 10, … are
If x = 2, is 3(2) + 5 ≡ 3 mod 4? Yes solutions to
If x = 3, is 3(3) + 5 ≡ 3 mod 4? No 3x + 5 ≡ 𝟑 𝐦𝐨𝐝 𝟒
If x = 4, is 3(4) + 5 ≡ 3 mod 4? No
If x = 5, is 3(5) + 5 ≡ 3 mod 4? No
If x = 6, is 3(6) + 5 ≡ 3 mod 4? Yes
28
6.1 Modulo Arithmetic
Solve 2x + 1 ≡ 3 mod 10 .
1 , 6, 11, … are
solutions to
2x + 1 ≡ 𝟑 𝐦𝐨𝐝 𝟏𝟎
29
6.1 Modulo Arithmetic
Additive Inverse
30
6.1 Modulo Arithmetic
Additive Inverse
31
6.1 Modulo Arithmetic
Additive Inverse
32
6.1 Modulo Arithmetic
Additive Inverse
33
6.1 Modulo Arithmetic
Multiplicative Inverse
34
6.1 Modulo Arithmetic
Multiplicative Inverse
35
6.1 Modulo Arithmetic
Multiplicative Inverse
36
6.1 Modulo Arithmetic
37
6.2 Applications of Modulo Arithmetic
Applications of
Modulo Arithmetic
38
6.2 Applications of Modulo Arithmetic
Zeller’s congruence
39
6.2 Applications of Modulo Arithmetic
Zeller’s congruence
Where:
d = date of the month
m = month (3 = March, 4 = April, 5 = May .....13 = Jan, 14 = Feb)
y = year (last two digits of the year)
c = century (first two digits of the year)
x = day (0 = Saturday, 1 = Sunday, 2 = Monday...)
40
6.2 Applications of Modulo Arithmetic
Zeller’s congruence
Cautions:
[x] is the rounded down value of x.
Jan and Feb are the 13th and 14th months of the
previous year.
January 20, 2011 is like the 13th month of 2010
41
6.2 Applications of Modulo Arithmetic
13(4 + 1) 11 16
𝑥 = 28 + + 11 + + + 5(16) mod7
5 4 4
𝑥 = 28 + 13 + 11 + 2 + 4 + 80 mod7
x = 138 mod 7
x=5
42
6.2 Applications of Modulo Arithmetic
On what day is
January 15, 2019
13(13 + 1) 18 20
𝑥 = 15 + + 18 + + + 5(20) mod7
5 4 4
𝑥 = 15 + 36 + 18 + 4 + 5 + 100 mod7
x = 178 mod 7
x=3
43
6.2 Applications of Modulo Arithmetic
46