mod arithmetic

16
mod arithmetic

Upload: selia

Post on 15-Jan-2016

52 views

Category:

Documents


0 download

DESCRIPTION

mod arithmetic. mod arithmetic. a mod m is the remainder of a divided by m a mod m is the integer r such that a = qm + r and 0

TRANSCRIPT

Page 1: mod arithmetic

mod arithmetic

Page 2: mod arithmetic

mod arithmetic

• a mod m is the remainder of a divided by m• a mod m is the integer r such that

• a = qm + r and 0 <= r < m • again, r is positive

•Examples

• 17 mod 3 = 2• 17 mod 12 = 5 (5 o’clock)•-17 mod 3 = 1

Page 3: mod arithmetic
Page 4: mod arithmetic

a is congruent to b modulo m if m divides a - b

b)m|(am)b(a mod

congruences

Page 5: mod arithmetic

b)m|(am)b(a mod

)5(mod27

)}3(mod2205|{ xxNxx}17,14,11,8,5{

)}3(mod2205|{

xxNxx

Page 6: mod arithmetic
Page 7: mod arithmetic

mbmamba modmod)(mod

b)m|(am)b(a mod

a is congruent to b mod m if and only if the remainder of a divided by m is equal to the remainder of b divided by m.

proof

Page 8: mod arithmetic

b)m|(am)b(a mod

)()(

congruence ofDefn

mod ofDefn

mod ofDefn

modmod)(mod

2121

2121

3

22

11

rrmqq

rrmqmqba

mqba

rmqb

rmqa

mbmamba

mbmamba modmod)(mod

Page 9: mod arithmetic

21

21

2121

2121

3

22

11

r

zero bemust

)(|But

)()(

congruence ofDefn

mod ofDefn

mod ofDefn

modmod)(mod

r

rr

bam

rrmqq

rrmqmqba

mqba

rmqb

rmqa

mbmamba

b)m|(am)b(a modmbmamba modmod)(mod

Page 10: mod arithmetic
Page 11: mod arithmetic

)(mod)(mod)(mod mdbcamdcmba

b)m|(am)b(a mod

If a is congruent to b mod m and c is congruent to d mod m then a+c is congruent to b+d mod m

proof

Page 12: mod arithmetic

)(mod)(mod)(mod mdbcamdcmba

)(|)(mod

)(|)(mod

dcmmdc

bammba

tydivisibili From))()((|

)(|)(mod

)(|)(mod

dcbam

dcmmdc

bammba

))()((|

tydivisibili From))()((|

)(|)(mod

)(|)(mod

dbcam

dcbam

dcmmdc

bammba

congruence ofDefn ))(mod(

))()((|

tydivisibili From))()((|

)(|)(mod

)(|)(mod

mdbca

dbcam

dcbam

dcmmdc

bammba

b)m|(am)b(a mod

Page 13: mod arithmetic
Page 14: mod arithmetic

)(mod)(mod)(mod mbdacmdcmba

If a is congruent to b mod m and c is congruent to d mod mthen ac is congruent to bd mod m

b)m|(am)b(a mod

proof

Page 15: mod arithmetic

)(mod)(mod)(mod mbdacmdcmba

congruence ofDefn 2

1

mqdc

mqba

)(

)(

2121

2121

2

1

mqqbqdqmbdac

mqqbqdqmbdac

mqdc

mqba

)(mod

)(|

)(

)(

2121

2121

2

1

mbdac

bdacm

mqqbqdqmbdac

mqqbqdqmbdac

mqdc

mqba

b)m|(am)b(a mod

Page 16: mod arithmetic

Mod arithmetic

• -133 mod 9 = 2 (but in Claire?)• list 5 numbers that are congruent to 4 modulo 12• hash function h(k) = k mod 101

• h(104578690)• h(432222187)• h(372201919)• h(501338753)

examples