Presentation is loading. Please wait.

Presentation is loading. Please wait.

CSE 20 DISCRETE MATH Prof. Shachar Lovett Clicker frequency: CA.

Similar presentations


Presentation on theme: "CSE 20 DISCRETE MATH Prof. Shachar Lovett Clicker frequency: CA."— Presentation transcript:

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

5

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

8

9

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

16

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


Download ppt "CSE 20 DISCRETE MATH Prof. Shachar Lovett Clicker frequency: CA."

Similar presentations


Ads by Google