Upload
hahanh
View
281
Download
9
Embed Size (px)
Citation preview
THE ISLAMIC UNIVERSITY OF GAZA
ENGINEERING FACULTY
DEPARTMENT OF COMPUTER ENGINEERING
DISCRETE MATHMATICS DISCUSSION – ECOM 2011
Eng. Huda M. Dawoud
November, 2015
DISCRETE MATHMATICS ECOM 2012 ENG. HUDA M. DAWOUD
Section 1: Divisibility and Modular Arithmetic
q= ⌊𝑎/𝑑⌋
9. What are the quotient and remainder when
a) 19 is divided by 7?
b) −111 is divided by 11?
c) 789 is divided by 23?
d) 1001 is divided by 13?
e) 0 is divided by 19?
f ) 3 is divided by 5?
g) −1 is divided by 3?
h) 4 is divided by 1?
Answer:
DISCRETE MATHMATICS ECOM 2012 ENG. HUDA M. DAWOUD
a) q = ⌊19/7⌋ = 2 r= 19 – (2 . 7) = 5
b) q = ⌊−111/11⌋ = -11 r= -111 – (-11 . 11) = 10
c) q = ⌊789/23⌋ = 34 r= 789 – (34 . 23) = 7
d) q = ⌊1001/13⌋ = 77 r= 1001 – (77 . 13) = 0
e) q = ⌊0/19⌋ = 0 r= 0 – (0 . 0) = 0
f) q = ⌊3/5⌋ = 0 r= 3 – (0 . 5) = 3
g) q = ⌊−1/3⌋ = -1 r= -1 – (-1 . 3) = 2
h) q = ⌊4/1⌋ = 4 r= 4 – (4 . 1) = 0
11. What time does a 12-hour clock read
a) 80 hours after it reads 11:00?
Answer:
(80 + 11) mod 12 = 7, the clock reads 07:00
12. What time does a 24-hour clock read
a) 100 hours after it reads 2:00?
Answer:
(100 + 2) mod 24 = 6, the clock reads 06:00
DISCRETE MATHMATICS ECOM 2012 ENG. HUDA M. DAWOUD
13. Suppose that a and b are integers, a ≡ 4 (mod 13), and b ≡ 9 (mod 13).
Find the integer c with 0 ≤ c ≤ 12 such that
a) c ≡ 9a (mod 13).
b) c ≡ 11b (mod 13).
c) c ≡ a + b (mod 13).
d) c ≡ 2a + 3b (mod 13).
e) c ≡ a2 + b2 (mod 13).
f ) c ≡ a3 − b3 (mod 13).
Answer:
a) (9 mod 13) · (a mod 13) mod 13 = (9.4) mod 13 = 36 mod 13 = 10
b) (11 mod 13) · (b mod 13) mod 13 = 99 mod 13 = 8
c) (a mod 13) + (b mod 13) mod 13 = (4 + 9) mod 13 = 0
d) 2 · 4 + 3 · 9 mod 13 = 35 mod 13 = 9
e) (a mod 13)2 + (b mod 13)2 mod 13 = (42 + 92) mod 13 = 97 mod 13= 6
f) (a mod 13)3 - (b mod 13)3 mod 13 = -665 mod 13 = -665 – (-52*13) =
11
:مالحظة مهمة جدا
ى أن التعبيريجب أن ننتبه جيدا إل
a ≡ 4(mod 13)
يختلف عن التعبير
a = 4(mod 13)
aفقط، أما في الحالة األولى 4قيمتها aففي الحالة الثانية
.. إلخ 30أو 17أو 4تحتمل أكثر من قيمة حيث قد تساوي
a mod 13 = 4 mod 13بحيث
9و4على أنها bو aوفي السؤال التالي نحن ال نعوض بقيمة
، راجع الخواص من الكتابmodتخدم خواص الولكن نس
والحظ الحل
DISCRETE MATHMATICS ECOM 2012 ENG. HUDA M. DAWOUD
21. Evaluate these quantities.
a) 13 mod 3 b) −97 mod 11
c) 155 mod 19 d) −221 mod 23
Answer:
a) 13 = 4∙3 + 1, r= 1
b) -97 = -9∙11 + 3, r = -2
c) 155 = 8∙19 + 3, r = 3
d) -221 = -10∙23 + 9, r = 9
28. Decide whether each of these integers is congruent to 3 modulo 7.
a) 37 b) 66
c) −17 d) −67
Answer:
3 mod 7 = 3
a) 37 mod 7 = 2, thus 37 is not congruent to 3 mod 7 37 ≢ 3 mod 7
b) 66 ≡ 3 mod 7
c) -17 mod 7 = 4 -17 ≢ 3 mod 7
𝑎 𝑚𝑜𝑑 𝑏 = 𝑎 − ⌊𝑎/𝑏⌋ ∗ 𝑏
𝑎 = ⌊𝑎/𝑏⌋ ∗ 𝑏 + 𝑎 𝑚𝑜𝑑 𝑏
:تذكير
DISCRETE MATHMATICS ECOM 2012 ENG. HUDA M. DAWOUD
d) -67 ≡ 3 mod 7
33. Find each of these values.
a) (992 mod 32)3 mod 15
Answer:
a) (9801 mod 32)3 mod 15 = (9)3 mod 15 = (729)3 mod 15 = 9
DISCRETE MATHMATICS ECOM 2012 ENG. HUDA M. DAWOUD
Section 3: Primes and Greatest Common Divisors
1. Determine whether each of these integers is prime.
a) 21 b) 29
c) 71
Answer:
a) √21 = 4.58
2 ∤ 21
∴ 21 is prime
b) √29 = 5.28
2 ∤ 29, 3 ∤ 29, 5 ∤ 29
∴ 29 is prime
c) √71 = 8.42
2 ∤ 71, 3 ∤ 71, 5 ∤ 71, 7 ∤ 71
∴ 71 is prime
:توضيح
composite، مذكور أن الرقم ال2في النظرية رقم
يقبل القسمة عليه في primeدائما يوجد رقم
إلى جذر هذا الرقم. 2المدى من
compositeوليس primeرقم فحتى نثبت أن ال
إلى جذر 2من primeنقوم بايجاد كل األرقام ال
الرقم
فان كان الرقم ال يقبل القسمة على أي منها، إذن هو
.primeويكون في هذه الحالة compositeليس
تعني ال تقبل القسمة ∤
DISCRETE MATHMATICS ECOM 2012 ENG. HUDA M. DAWOUD
3. Find the prime factorization of each of these integers.
a) 88 b) 126 c) 729 d) 1001
Answer:
a) 88 = 2 ∙44 = 2 ∙2∙22 = 2∙2∙2∙11
b) 126 = 2∙63 = 2∙3∙21 = 2∙3∙3∙ 7
c) 729 = 3∙243 = 3∙3∙81 = 3∙3∙3∙27 = 3∙3∙3 ∙3∙9 = 3∙3∙3∙3∙3∙3
d) 1001 = 7∙143 = 7∙11∙13
25. What are the greatest common divisor and the least common multiple of
these pairs of integers?
a) 37 · 53 · 73, 211 · 35 · 59
b) 11 · 13 · 17, 29 · 37 · 55 · 73
Answer:
a) GCD = 2min(0,11) ∙3min(7,5) ∙5min(3,9) ∙7min(3,0) = 20∙35∙53 ∙70 = 35∙53
LCM = 2max(0,11) ∙3max(7,5) ∙5max(3,9) ∙7max(3,0) = 211 ∙37 ∙ 59∙73
b) GCD = 2min(0,9) ∙3min(0,7) ∙5min(0,5) ∙7min(0,3) ∙11min(1,0) ∙13min(1,0) ∙17min(1,0)
= 20∙30∙ 50∙ 70∙110∙130∙170 = 1
DISCRETE MATHMATICS ECOM 2012 ENG. HUDA M. DAWOUD
LCM = 2max(0,9) . 3 max (0,7) . 5 max (0,5) . 7 max (0,3) . 11 max (1,0) . 13 max (1,0) . 17 max(1,0)
= 29. 37. 55. 73. 111. 131. 171
33. Use the Euclidean algorithm to find
a) gcd(12, 18). b) gcd(111, 201).
Answer:
a) gcd(12, 18) = gcd(12, 18 mod 12) = gcd(12, 6) = gcd(6, 12 mod 6) =
gcd(6, 0) = 6.
b) gcd(111,201) = gcd(111,90) = gcd(90,21) = gcd(21,6) = gcd(6,3) =
gcd(3,0) = 3
DISCRETE MATHMATICS ECOM 2012 ENG. HUDA M. DAWOUD
39. Using the method followed in Example 17, express the greatest common
divisor of each of these pairs of integers as a linear combination of these
integers.
a) 10, 11 b) 21, 44
Answer:
a) gcd(10, 11) = 1, and 1 = 11 - 10 = ( -1) · 10 + 1 · 11.
b) gcd(21, 44)= 1, and
44 = 2∙21 + 2
21= 10∙2 + 1
1 = 21 – 10∙2
= 21 –10∙ (44 – 2∙21)
= 21 – 10∙44 + 10 ∙2∙21
= 21 – ( 10 ∙44) + ( 20∙21)
= ( 21∙21 ) – ( 10 ∙44)
DISCRETE MATHMATICS ECOM 2012 ENG. HUDA M. DAWOUD
Section 4: Solving Congruences
1. Show that 15 is an inverse of 7 modulo 26.
Answer:
We want to find if 15.7 ≡ 1 mod 26 or not
105 mod 26 = 1 and 1 mod 26 = 1, which means that 15.7 ≡ 1 mod 26 is
true and 15 is an inverse of 7 mod 27
:توضيح
ا يطلب حل معادلة على هذا الشكل وعندم ax ≡ b mod mهو معادلة على الشكل linear congruencesال
التي تحقق المعادلة. xيعني أننا يجب أن نجد قيم
حيث أن inverseنحتاج أن نجد ما يسمى بال xحتى نجد
a’a ≡ 1 mod m
تابع األسئلة لتتضح الفكرة
DISCRETE MATHMATICS ECOM 2012 ENG. HUDA M. DAWOUD
5. Find an inverse of a modulo m for each of these pairs of relatively prime
integers using the method followed in Example 2.
a) a = 4, m = 9 b) a = 19, m = 141
Answer:
a) 9=2·4 + 1
4 = 4 · 1
Now, 1 = 9-2·4
-2 is an inverse of 4 mod 9
b) 141=7∙19 + 8
19 = 2∙8 + 3
8=2·3+2
3=1·2+1
2=2·1
Now, 1=3-1·2
Note:
To find an inverse of a mod m:
1. a and m first must be relatively prime that gcd(a,m) = 1
2. From Bezout’s Theorm, we can write sa + tm = 1
3. s here is the inverse of a mod mas
Now see the answer
DISCRETE MATHMATICS ECOM 2012 ENG. HUDA M. DAWOUD
= 3 - 1∙ (8 - 2∙3) = 3∙3 - 1∙ 8
= 3∙ (19 - 2 ∙8) - 1∙8 = 3 ∙19 - 7∙8
= 3∙19 - 7∙ (141 - 7. 19) = (-7) ∙141+52∙19
52 is an inverse of 19 mod 141
11. Solve each of these congruences using the modular inverses found in
parts (b) of Exercise 5.
a) 19x ≡ 4 (mod 141)
Answer:
a) In Exercise 5b we found that an inverse of 19 modulo 141 is 52.
That 19*52 ≡ 1 (mod 141).
Therefore we multiply both sides of this equation by 52.
19*52 * x ≡ 4*52 (mod 141)
(19*52 mod 141)1(x mod 141) = 208 mod 141
x ≡ 67 (mod 141)
مالحظة:
linear congruenceإلكمال حل ال inverseبعد إيجاد ال
inverseنقوم بضرب طرفي المعادلة بال
19*52*x ≡ (4*52) mod 141
ابقة وحسب الخاصية الس
ab mod c = (a mod c)(b mod c) mod c
((19*52) mod 141)1 (x mod 141) ≡ (4*52) mod 141
x ≡ (4*52) mod 141
وهو المطلوب..
a’a ≡ 1 mod m
DISCRETE MATHMATICS ECOM 2012 ENG. HUDA M. DAWOUD
Section 5: Application of Congruences
5. What sequence of pseudorandom numbers is generated using the linear
congruential generator xn+1 = (3xn + 2) mod 13 with seed x0 = 1?
Answer:
x1 = (3 · x0 + 2) mod 13 = (3 · 1 + 2) mod 13 = 5.
x2 = (3 · x1 + 2) mod 13 = (3 · 5 + 2) mod 13 = 17 mod 13 = 4.
x3 = (3 · 4 + 2) mod 13 = 1. Because this is the same as x0, the sequence
repeats from here on out. So the sequence is 1, 5, 4, 1, 5, 4, 1, 5, 4, ....
مالحظة:
، نالحظه في البرامج التي تصمم إلختيار رقم رقام عشوائية يلزم في استخدامات متعددةإيجاد أ
رقام، واأللعاب الورقية وغيرها..فائز ضمن مجموعة من األ
linearإحداها التتفاوت في ما بينها، لذلك هناك أكثر من من طريقة إليجاد هذه األرقام برمجيا
congruential method
DISCRETE MATHMATICS ECOM 2012 ENG. HUDA M. DAWOUD
Section 6: Cryptography
1. Encrypt the message DO NOT PASS GO by translating the letters into
numbers, applying the given encryption function, and then translating the
numbers back into letters.
b) f(p) = (p + 13) mod 26
Answer:
Letter D O N O T P A S S G O Before Encryption 4 15 14 15 20 16 1 19 19 7 15 After Encryption 17 2 1 2 7 3 14 6 6 20 2 Letter Q B A B G C N F F T B
f(4) = (4+13 mod 26) = 17
f(15) = (15+13 mod 26) = 28 mod 26 = 2 and so on…
To translate it back into letter (decrypt it) we use
f-1(p) = (p – 13) mod 26.Try it yourself
DISCRETE MATHMATICS ECOM 2012 ENG. HUDA M. DAWOUD
A B C D E F G H I J 00 01 02 03 04 05 06 07 08 09 K L M N O P Q R S T 10 11 12 13 14 15 16 17 18 19 U V W X Y Z 20 21 22 23 24 25
25. Encrypt the message UPLOAD using the RSA system with n = 53 · 61 and
e = 17, translating each letter into integers and grouping together pairs of
integers, as done in Example 8.
Answer:
UPLOAD = 20 15 11 14 00 03 2015 1114 0003
C = Me mod n = M17 mod 3233
Note that n = 53 · 61 = 3233 and that gcd(e, (p - 1) ( q - 1)) = gcd(l 7, 52 ·
60) = 1, as it should be.
C1 = (2015)17 mod 3233 = 2545
C2 = (1114)17 mod 3233 = 2757
DISCRETE MATHMATICS ECOM 2012 ENG. HUDA M. DAWOUD
C3 = (0003)17 mod 3233 = 1211
The message would be sent as 2545 2757 1211
We need to get d which is the inverse of e mod (p-1)(q-1) Note that we have chosen e, p, q such that the gcd(e, (p-1)(q-1)) =1, so the inverse of
e mod n exists.
مالحظة:
التي تم nو eال يمكن فك تشفيرها إال إزا علمنا قيمة RSAالرسالة المشفرة باستخدام ال
تكون بمثابة كلمة السر التي تمكن من n=(p-1)(q-1)وال eيث المن خاللها التشفير، ح
يعرفها من قراءة الرسالة الصحيحة.
section 4كما تعلمنا في e mod n ل inverseالذي هو dحيث نقوم بإيجاد
فيما يلي سنقوم بفك التشفير للمثال السابق..
DISCRETE MATHMATICS ECOM 2012 ENG. HUDA M. DAWOUD
3233 = 190∙17+ 3
17 = 5∙3 + 2
3 = 2∙1 + 1
Now,
1 = 3 - 2∙1
= 3 – 2(17 - 5∙3)
=3 – 2∙17 + 2∙5∙3
= – 2∙17 + 11∙3
= -2.17 + 11 (3233 - 190∙17)
= -2.17 + 11∙3233 - 2090∙17
= 11∙3233 - 2092∙17
d(2092) is the inverse of e(17) mod n(3233)
2545 2757 1211
M = Cd mod n
M1 = C12092 mod 3233
= (2545) 2092 mod 3233 ،ويكفي الوصول في الحل حالياً لهناحسابها ليس سهل
= 2015
M2 = (2757) 2092 mod 3233
= 1114
M3 = (1211) 2092 mod 3233
= 0003