Upload
ethan-bradshaw
View
217
Download
0
Embed Size (px)
Citation preview
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
a is congruent to b modulo m if m divides a - b
b)m|(am)b(a mod
congruences
b)m|(am)b(a mod
)5(mod27
)}3(mod2205|{ xxNxx}17,14,11,8,5{
)}3(mod2205|{
xxNxx
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
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
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
)(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
)(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
)(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
)(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
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