16
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

Embed Size (px)

Citation preview

Page 1: 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

mod arithmetic

Page 2: 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

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. 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
Page 4: 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

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

b)m|(am)b(a mod

congruences

Page 5: 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

b)m|(am)b(a mod

)5(mod27

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

)}3(mod2205|{

xxNxx

Page 6: 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
Page 7: 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

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. 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

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. 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

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. 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
Page 11: 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

)(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. 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

)(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. 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
Page 14: 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

)(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. 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

)(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. 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

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