Download presentation
Presentation is loading. Please wait.
Published byPrudence Austin Modified over 9 years ago
1
CSE 20 DISCRETE MATH Prof. Shachar Lovett http://cseweb.ucsd.edu/classes/wi15/cse20-a/ Clicker frequency: CA
2
Todays topics More modular arithmetic Section 6.2 in Jenkyns, Stephenson
3
Modular arithmetic
4
Modular negation
6
Modular subtraction We know how to do: Addition modulo m Negation modulo m How to do subtraction? To compute (a-b) mod m, we can… A. Compute (-b) mod m, then add to a mod m B. Compute (-a) mod m, then add to b mod m C. Add a and b mod m, then negate D. Negate a, negate b, then add E. Other
7
Modular inverse
10
Modular inverse: existence So… when is there an inverse to a modulo m? What do you think? A. Only if a=1 B. Only if m is prime C. Only if a,m don’t have a common factor D. It is impossible to tell without trying all options E. Other
11
Modular inverse: existence
12
Modular inverse: existence proof
13
Modular inverse: existence proof (contd)
14
Modular arithmetic: summary so far Modulo m Always defined: addition, negation, subtraction, multiplication Sometimes defined: inverse (and also division) a/b mod m is defined whenever gcd(b,m)=1 Compute as a*(1/b mod m) mod m.
15
Modular power
17
Recall: fast (non-modular) power
18
Loop invariant: Res * a b
19
Recall: fast (non-modular) power How to convert this to a fast modular power algorithm?
20
Fast modular power
21
RSA*
22
Next class Order relations Section 6.3 in Jenkyns, Stephenson
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.