Modular Arithmetic
1
Basic Idea:
Given an integer
n
!
2
, we want to classify the set of integers according to
the reminder obtained when dividing by
n
.
Special Notation:
!
a
,
b
"
Z
, if
n

a
!
b
( )
, we write
a
!
b
mod
n
( )
,
and say that “
a
is congruent to
b
,
mod
n
.”
In
other words,
a
!
b
mod
n
( )
means that
a
and
b
yield the same reminder
when divided by
n
.
In
other words,
a
!
b
mod
n
( )
means that
a
=
nk
+
b
for some integer
k
.
The Set of Integers mod
n
:
Z
n
=
0,1,2,3,4,.
..
n
!
1
{ }
Important Theorems:
Theorem:
Given
,
a b
!
Z
, with
a
and
b
not both 0. If
(
)
gcd
,
d
a b
=
, then there
exist
,
x y
!
Z
such that
d
ax
by
=
+
.
Theorem:
Given
,
a b
!
Z
, with
a
and
b
not both 0. If
(
)
gcd
,
d
a b
=
, then
is the
smallest positive integer that can be expressed as the linear combination
d
ax
by
=
+
, where
,
x y
!
Z
.
Theorem:
Integers
a
and
b
are relatively prime if and only if there exist
,
x y
!
Z
such that
1
ax
by
+
=
.
Modular Arithmetic
Within the set
Z
n
, we can perform standard arithmetic such as addition, subtraction, and
multiplication. However, we must know how to “reduce
mod
n
.”
Given
a
,
b
!
Z
n
,
1.
a
!
b
"
a
+
b
( )
mod
n
( )
2.
a
!
b
"
a
#
b
( )
mod
n
( )
Theorem:
Given
a
!
Z
n
,
a
!
1
(the multiplicative inverse of