Professional Documents
Culture Documents
9/30/2017 1
Module #9 – Number Theory
9/30/2017
Arab Open University – Faculty of Computer Studies 2
MT131 - Discrete Mathematics
Module #9 – Number Theory
Examples:
3 12 and 3 9 3 (12 + 9) 3 21 (21 ÷ 3 = 7)
2 6 2 (6 × 3) 2 18 (18 ÷ 2 = 9)
4 8 and 8 64 4 64 (64 ÷ 4 = 16)
9/30/2017
Arab Open University – Faculty of Computer Studies 3
MT131 - Discrete Mathematics
Module #9 – Number Theory
9/30/2017
Arab Open University – Faculty of Computer Studies 4
MT131 - Discrete Mathematics
Module #9 – Number Theory
Example
101
q 101 div 11 9.18 9
11
r 101 (9) 11 2
9/30/2017
Arab Open University – Faculty of Computer Studies 5
MT131 - Discrete Mathematics
Module #9 – Number Theory
Examples
• What are the quotient and the remainder when −11
is divided by 3?
−11 = 3 × (−4) + 1
q = −4 , r = 1
11
q 11 div 3 3.6 4
3
r 11 (4) 3 1 11 mod 3
• Note:
− 11 3 × (− 3) − 2 because r can't be negative.
9/30/2017
Arab Open University – Faculty of Computer Studies 6
MT131 - Discrete Mathematics
Module #9 – Number Theory
Examples
• Find a and b if :
2a + b = 46 mod 7 and a + 2b = 47 div 9.
46 = 6 × 7 + 4 and 47 = 5 × 9 + 2
46 mod 7 = 4 and 47 div 9 = 5
2a + b = 4 (1)
a + 2b = 5 (2)
By solving (1) and (2) for a and b,
(1) – 2×(2) → – 3b = – 6 → b = 2 and a = 1.
9/30/2017
Arab Open University – Faculty of Computer Studies 7
MT131 - Discrete Mathematics
Module #9 – Number Theory
Modular Congruence
9/30/2017
Arab Open University – Faculty of Computer Studies 8
MT131 - Discrete Mathematics
Module #9 – Number Theory
Examples
Is 17 congruent to 5 modulo 6?
17 mod 6 = 5 and 5 mod 6 = 5,
also 6 | (17 − 5) 6 | 12 where 12 ÷ 6 = 2,
then 17 ≡ 5 (mod 6)
Is 24 congruent to 14 modulo 6?
Since, 24 mod 6 = 0 and 14 mod 6 = 2,
also 6 ∤ (24 − 14) 6 ∤ 10,
then, 24 ≡ 14 (mod 6).
9/30/2017
Arab Open University – Faculty of Computer Studies MT131 - Discrete Mathematics
Module #9 – Number Theory
9/30/2017
Arab Open University – Faculty of Computer Studies 10
MT131 - Discrete Mathematics
Module #9 – Number Theory
Cryptology
9/30/2017
Arab Open University – Faculty of Computer Studies 11
MT131 - Discrete Mathematics
Module #9 – Number Theory
Cryptology
e.g. What is the secret message produce from the message
“GOOD MORNING ZERO”?
First replace the letters in the message with numbers
p : 6 14 14 3 12 14 17 13 8 13 6 25 4 17 14
Second replace p by f (p) = (p + 3) mod 26
f (p) : 9 17 17 6 15 17 20 16 11 16 9 2 7 20 17
Translate this back to letters produces the encrypted
message
“JRRG PRUQLQJ CHUR ”
• To recover the original message from a secrete message.
The inverse function f -1(p) = (p – 3) mod 26 can be used.
This process is called decryption.
9/30/2017
Arab Open University – Faculty of Computer Studies 12
MT131 - Discrete Mathematics
Module #9 – Number Theory
Cryptology
Example: Encrypt the message “STOP GLOBAL
WARMING” using the encrypting function f (x) = (x + 11)
mod 26, 0 ≤ x ≤ 25.
Solution: Replace each letter with the corresponding element
of Z26.
18 19 14 15 6 11 14 1 0 11 22 0 17 12 8 13 6.
Apply the shift f (x) = (x + 11) mod 26, yielding
3 4 25 0 17 22 25 12 11 22 7 11 2 23 19 24 17.
Translating the numbers back to letters produces the cipher
text
“DEZA RWZMLW HLCXTYR”
9/30/2017
Arab Open University – Faculty of Computer Studies 13
MT131 - Discrete Mathematics
Module #9 – Number Theory
Cryptology
Example: Decrypt the message “LEWLYPLUJL PZ H
NYLHA ALHJOLY” using the encrypting function f (x) =
(x + 7) mod 26, 0 ≤ x ≤ 25.
Solution: Replace each letter with the corresponding element
of Z26.
11 4 22 11 24 15 11 20 9 11 15 25 7 13 24 11 7 0 0 11 7 9 14 11 24.
Shift each of the numbers by −7 modulo 26, yielding
4 23 15 4 17 8 4 13 2 4 8 18 0 6 17 4 0 19 19 4 0 2 7 4 17.
Translating the numbers back to letters produces the
decrypted message
“EXPERIENCE IS A GREAT TEACHER”
9/30/2017
Arab Open University – Faculty of Computer Studies 14
MT131 - Discrete Mathematics
Module #9 – Number Theory
Hashing Functions*
9/30/2017
Arab Open University – Faculty of Computer Studies 15
MT131 - Discrete Mathematics
Module #9 – Number Theory
9/30/2017
Arab Open University – Faculty of Computer Studies 16
MT131 - Discrete Mathematics
Module #9 – Number Theory
9/30/2017
Arab Open University – Faculty of Computer Studies 17
MT131 - Discrete Mathematics
Module #9 – Number Theory
Theorem
9/30/2017
Arab Open University – Faculty of Computer Studies 18
MT131 - Discrete Mathematics
Module #9 – Number Theory
9/30/2017
Arab Open University – Faculty of Computer Studies 19
MT131 - Discrete Mathematics
Module #9 – Number Theory
Examples
9/30/2017
Arab Open University – Faculty of Computer Studies 20
MT131 - Discrete Mathematics
Module #9 – Number Theory
Examples
9/30/2017
Arab Open University – Faculty of Computer Studies MT131 - Discrete Mathematics
Module #9 – Number Theory
Greatest Common Divisors
• The greatest common divisor gcd(a, b) of integers
a, b (not both 0) is the largest (most positive) integer
d that is a divisor both of a and of b.
9/30/2017
Arab Open University – Faculty of Computer Studies 23
MT131 - Discrete Mathematics
Module #9 – Number Theory
Examples
9/30/2017
Arab Open University – Faculty of Computer Studies 24
MT131 - Discrete Mathematics
Module #9 – Number Theory
Introduction:
The term algorithm originally referred to
procedures for performing arithmetic operations
using the decimal representations of integers.
These algorithms, adapted for use with binary
representations, are the basis for computer
arithmetic.
9/30/2017
Arab Open University – Faculty of Computer Studies 26
MT131 - Discrete Mathematics
Module #9 – Number Theory
Representations of Integers
Representations of Integers
9/30/2017
Arab Open University – Faculty of Computer Studies 28
MT131 - Discrete Mathematics
Module #9 – Number Theory
Solution: We have
(l 01011111)2 = 1·28 + 0·27 + 1·26 + 0·25 + 1·24
+ 1·23 + 1· 22 + 1·21 + 1·20
= 256 + 64 + 16 + 8 + 4 + 2 + 1
= 351
9/30/2017
Arab Open University – Faculty of Computer Studies 29
MT131 - Discrete Mathematics
Module #9 – Number Theory
Hexadecimal Expansions
Decimal system
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
0 1 2 3 4 5 6 7 8 9 A B C D E F
Hexadecimal system
Any to Decimal
Example