Title: CMSC 203, Section 0401
1- CMSC 203, Section 0401
- Discrete Structures
- Fall 2004
- Matt Gaston
- mgasto1_at_cs.umbc.edu
- http//www.csee.umbc.edu/mgasto1/203
2 Integers Ch. 2.4-2.5
3Division
Let a and b be integers with a ? 0. Then a
divides b if there is an integer c such that b
ac. When a divides b, a is called a factor of b
and b is called a multiple of a. The notation a
b denotes a divides b.
4Primes
A positive integer p gt 1 is called prime if the
only positive factors of p are 1 and p. A
positive integer that is greater than 1 and is
not prime is called composite.
5The Fundamental Theorem of Arithmetic
Theorem Every positive integer greater than 1
can be written uniquely as a prime or as the
product of two or more primes where the
prime factors are written in order of
nondecreasing size.
6The Division Algorithm
Theorem Let a be an integer and d a
positive integer. Then there are unique integers
q and r, with 0 ? r ? d, such that a dq r.
In the equality given in the above theorem, a is
called the dividend,d is called the divisor, q
is called the quotient,and r is called the
remainder. This notation is used to express the
quotient and remainder q a div d r a
mod d.
7Greatest Common Divisor
Let a and b be integers, but not both 0. The
largest integer d such that d a and d b is
called the greatest common divisor of a and b.
gcd(a,b)
8Least Common Multiple
Let a and b be positive integers. The
largest integer d such that a d and b d is
called the least common multiple of a and b.
lcm(a,b)
9Modular Arithmetic
If a and b are integers and m is a positive
integer, then a is congruent to b modulo m if m
(a b). a ? b (mod m)
10Congruence Theorems
Theorem Let m be a positive integer. Then a ?
b (mod m) if and only if a mod m b mod m.
Theorem Let m be a positive integer. Then a ?
b (mod m) if and only if there is an integer k
such that a b km.
Theorem Let m be a positive integer. If a ? b
(mod m) and c ? d (mod m), then a c ? b d
(mod m) and ac ? bd (mod m).
11Base b Expansions
Theorem Let b be a positive integer greater
than 1. Then if n is a positive integer, it can
be expressed uniquely in the form n akbk
ak-1bk-1 . . . a1b a0, where k is a
nonnegative integer, a0 , a1 , . . . , ak are
Nonnegative integers less than b.
12Constructing Base b Expansions
procedure base b expansion (npositive integer) q
n k 0 while (q ? 0) begin ak q mod b q
? q / b ? k k 1 end the base b
expansion of n is (ak-1 ak-2 . . . a1 a0 )b
13Addition of Integers
procedure add (a,bpositive integers) c 0 for
j 0 to n - 1 begin d ? (aj bj c) / 2
? sj aj bj c - 2d c d end sj
c the binary expansion of the sum is (sn sn-1 .
. . s0 )2
14Multiplying Integers
procedure multiply (a,bpositive integers) c
0 for j 0 to n - 1 begin if bj then cj a
shifted j places else cj 0 end p 0 for j
0 to n 1 p p cj p is the value of
ab
15Euclidean Algorithm
Lemma Let a bq r, where a, b, q, and r are
integers. Then gcd(a, b) gcd(b, r)
procedure procedure (a,bpositive integers) x
a y b while y ? 0 begin r x mod y x
y y r end gcd(a, b) is x