SlideShare a Scribd company logo
1
UNIT-2
NUMBER THEORY
Number theory
• 1.Divisors
• 2.Primer Factorization
• 3.Congruence
• 4.Quadratic Residues
2
1.Divisors
Theorem 1.1. Division Algorithm. Let n and d ≥ 1 be integers. There
exist uniquely determined integers q and r such that n = qd + r and
0 ≤ r < d.
Proof. Let X = {n − td|t ∈ , n − td ≥ 0}. Then X is nonempty (if
n≥0,then n X; if n < 0, then n(1 − d) X). Hence let r be the∈ ∈
smallest member of X . Then r = n − qd for some q ∈ , and it
remains to show that r < d. But if r ≥d, then 0 ≤ r − d = n − (q + 1)d,
so r − d is in X contrary to the minimality of r.
As to uniqueness, suppose that n = q’d + r’, where 0≤ r’< d. We
may assume that r ≤ r’(a similar argument works if r’ ≤ r). Then
0 ≤ r’ − r = (q − q’)d, so (q − q’)d is a nonnegative multiple of d that
is less than d (because r’ − r ≤ r ’< d). The only possibility is
(q − q’)d = 0, so q’ = q, and hence r’ = r.
3
1.Divisors
• Given n and d ≥ 1, the integers q and r in Theorem 1.1 are called,
respectively, the quotient and remainder when n is divided by d.
For example, if we divide n = −29 by d = 7, we find that −29 =
(−5) · 7 + 6, so the quotient is −5 and remainder is 6.
The usual process of long division is a procedure for finding the
quotient and remainder for a given n and d ≥ 1. However, they can
easily be found with a calculator. For example, if n = 3196 and d =
271 then n/d = 11,79 approximately, so q = 11. Then r = n − qd =
215, so 3196 = 11 · 271 + 215, as desired.
If d and n are integers, we say that d divides n, or that d is a
divisor of n, if n = qd for some integer q. We write d|n when this
is the case. Thus, a positive integer p >1is prime if and only if p has
no positive divisors except 1 and p. The following properties of the
divisibility relation | are easily verified:
4
1.Divisors
(i) n|n for every n.
(ii) If d|m and m|n, then d|n.
(iii) If d|n and n|d, then d = ±n.
(iv) If d|n and d|m, then d|(xm + yn) for all integers x and y.
Given positive integers m and n, an integer d is called a common
divisor of m and n if d|m and d|n.
If m and n are integers, not both zero, we say that d is the
greatest common divisor of m and n, and write d = gcd(m, n),
if the following three conditions are satisfied:
(i) d ≥ 1. (ii) d|m and d|n.
(iii) If k|m and k|n, then k|d.
5
1.Divisors
• Theorem 1.2. Let m and n be integers, not both zero.
Then d = gcd(m, n) exists,and d = xm + yn for some
integers x and y.
Proof. Let X = {sm + tn | s, t ∈ ; sm + tn ≥1}. Then X is
not empty since m2
+ n2
is in X, so let d be the smallest
member of X. Since d X we have d∈ ≥ 1 and
d = xm + yn for integers x and y, proving conditions (i)
and (iii) in the definition of the gcd.
Hence it remains to show that d|m and d|n.We show
that d|n; the other is similar. By the division algorithm
6
1.Divisors
write n = qd + r, where 0 ≤ r < d. Then
r = n − q(xm + yn) = (−qx)m + (1 − qy)n. Hence, if r ≥ 1, then
r X, contrary to the minimality of d. So r = 0 and we have∈
d|n.
When gcd(m, n) = xm + yn where x and y are integers, we say
that gcd(m, n) is a linear combination of m and n. There is an
efficient way of computing x and y using the division
algorithm.
The following example illustrates the method.
7
1.Divisors
• Example . Find gcd(37, 8) and express it as a linear combination of 37
and 8.
Proof. It is clear that gcd(37, 8) = 1 because 37 is a prime; however, no
linear combination is apparent. Dividing 37 by 8, and then dividing each
successive divisor by the preceding remainder, gives the first set of
equations.
37 = 4 · 8 +5 1= 3 − 1 · 2 = 3 − 1(5 − 1 · 3)
8 = 1 · 5 + 3 = 2 · 3 − 5 = 2(8 − 1 · 5) − 5
5 = 1 · 3 + 2 = 2 · 8 − 3 · 5 = 2 · 8 − 3(37 − 4 · 8)
3 = 1 · 2 + 1 = 14 · 8 − 3 · 37
2 = 2 · 1
The last nonzero remainder is 1, the greatest common divisor, and this
turns out always to be the case. Eliminating remainders from the bottom up
(as in the second set of equations) gives 1 = 14 · 8 − 3 · 37.
8
1.Divisors
• Theorem 1.3. Euclidean Algorithm. Given integers m and
n ≥ 1, use the division algorithm repeatedly:
m = q1n + r1 0 ≤ r1 < n
n = q2r1 + r2 0 ≤ r2 < r1
r1 = q3r2 + r3 0 ≤ r3 < r2
...
...
r k-2= qkrk−1 + rk 0 ≤ rk < rk-1
rk−1= qk+1rk
where in each equation the divisor at the preceding stage is
divided by the remainder. These remainders decrease
r1 > r2 > · · · ≥ 0
9
1.Divisors
so the process eventually stops when the remainder
becomes zero. If r1 = 0, then gcd(m, n) = n. Otherwise,
rk = gcd(m, n), where rk is the last nonzero remainder
and can be expressed as a linear combination of m and
n by eliminating remainders.
Proof. Express rk as a linear combination of m and n by
eliminating remainders in the equations from the
second last equation up. Hence every common
divisor of m and n divides rk. But rk is itself a common
divisor of m and n (it divides every ri—work up through
the equations). Hence rk = gcd(m, n).
10
1.Divisors
Two integers m and n are called relatively prime if gcd(m, n) = 1.
Hence 12 and 35 are relatively prime, but this is not true for 12 and 15
Because gcd(12, 15) = 3. Note that 1 is relatively prime to every
integer m. The following theorem collects three basic properties of
relatively prime integers.
Theorem 1.4. If m and n are integers, not both zero:
(i) m and n are relatively prime if and only if 1 = xm + yn for some
integers x and y.
(ii) If d = gcd(m, n), then m/d and n/d are relatively prime.
(iii) Suppose that m and n are relatively prime.
(a) If m|k and n|k, where k ∈ , then mn|k.
(b) If m|kn for some k ∈ , then m|k
11
1.Divisors
• Proof. (i) If 1 = xm + yn with x, y ∈ , then every
divisor of both m and n divides 1, so must be 1 or −1. It
follows that gcd(m, n) = 1. The converse is by the
euclidean algorithm.
(ii). By Theorem 1.2, write d = xm + yn,
where x, y ∈ . Then
1 = x(m/d)+y(n/d) and (ii) follows from (i).
(iii). Write 1 = xm + yn, where x, y ∈ . If k = am and k
= bn, a, b ∈ then k = kxm + kyn = (xb + ya)mn, and
(a) follows. As to (b), suppose that
kn = qm, q ∈ . Then k = kxm + kyn = (kx + qn)m, so
m|k.
12
2.Prime Factorization
Recall that an integer p is called a prime if:
• (i) p ≥ 2.
• (ii) The only positive divisors of p are 1 and p.
The reason for not regarding 1 as a prime is that
we want the factorization of every integer into
primes to be unique. The following result is needed.
13
2.Prime Factorization
• Theorem 2. 1. Euclid’s Lemma. Let p denote a prime.
(i) If p|mn where m, n ∈ , then either p|m or p|n.
(ii) If p|m1m2 · · ·mr where each mi ∈ , then p|mi for some i.
Proof. (i) Write d = gcd(m, p). Then d|p, so as p is a prime, either
d = p or d = 1.
If d = p, then p|m; if d =1, then since p|mn, we have p|n by
Theorem 1.4 .
(ii) This follows from (i) using induction on r.
14
2.Prime Factorization
• Theorem 2.2. Every integer n >1 is a product
of primes.
• Proof. Let pn denote the statement of the theorem. Then p2
is clearly true.
If p2, p3, . . . , pk are all true, consider the integer k + 1. If
k + 1 is a prime, there is nothing to prove. Otherwise,
k + 1 = ab, where 2 ≤ a, b ≤ k. But then each of a and b are
products of primes because pa and pb are both true by the
(strong) induction assumption. Hence ab = k + 1 is also a
product of primes, as required.
15
2.Prime Factorization
• Theorem 2.3. Prime Factorization Theorem. Every
integer n ≥ 2 can be written as a product of (one or
more) primes. Moreover, this factorization is unique
except for the order of the factors. That is,
if n = p1p2 · · · pr and n = q1q2 · · · qs ,
where the pi and qj are primes, then r = s and the qj
can be relabeled so that pi = qi for each i.
16
2.Prime Factorization
• Proof. The existence of such a factorization was
shown in Theorem 2.2. To prove uniqueness, we
induction the minimum of r and s. If this is 1, then n
is a prime and the uniqueness follows from Euclid’s
lemma. Otherwise, r ≥ 2 and s ≥ 2. Since
p1|n = q1q2 · · · qs Euclid’s lemma shows that p1 divides
some qj , say p1|q1 (after possible relabeling of the qj ).
But then p1 = q1 because q1 is a prime. Hence n/p1 =
p2p3· · · pr = q2q3 · · · qs , so, by induction,
r − 1 = s − 1 and q2, q3, . . . , qs can be relabeled such
that pi = qi for all i = 2, 3, . . . , r. The theorem follows.
17
2.Prime Factorization
• It follows that every integer n ≥ 2 can be written in
the form n = p1
n
1 p2
n
2 · · · pr
n
r ,where p1, p2, . . . , pr are
distinct primes, ni ≥ 1 for each i, and the pi and ni are
determined uniquely by n. If every ni = 1, we say that
n is square-free, while if n has only one prime
divisor, we call n a prime power.If the prime
factorization
n = p1
n
1 p2
n
2 · · · pr
n
r of an integer n is given, and if d
is a positive divisor of n, then these pi are the only
possible prime divisors of d (by Euclid’s lemma). It
follows that
18
Prime Factorization
19
Collorary 2.4
Prime Factorization
20
Theorem 2.5
21
3.Congruences
• Definition 3.1.. If m ≥ 0 is fixed, then integers a and b
are congruent modulo m,denoted by a ≡ b (mod m)
if m | (a – b ). Usually, one assumes that the modulus
m >1 because the cases m = 0 and m = 1 are not very
interesting: if a and b are integers, then a ≡ b (mod 0) if
and only if 0 | (a –b), that is, a = b, and so congruence
mod 0 is ordinary equality.
The congruence a ≡ b (mod 1) is true for every pair of
integers a and b because 1 | (a – b) always. Hence,
every two integers are congruent mod 1.
22
3.Congruences
• If a and b are positive integers, then a ≡ b (mod 10) if
and only if they have the same last digit; more
generally, a ≡ b (mod 10n
)if and only if they have same
last n digits. For example, 526 ≡ 1926 (mod 100).
• London time is 6 hours later than Chicago time. What
time is it in London if it is 10:00 A.M. in Chicago?
Since clocks are set up with 12 hour cycles, this is
really a problem about congruence mod 12. To solve it,
note that 10 + 6 = 16 ≡ 4(mod 12); and so it is 4:00 P.M.
in London.
23
3.Congruences
• Proposition 3.1. If m > 0 is a fixed integer, then for all
integers a, b, c,
(i) a ≡ a (mod m);
(ii) if a ≡ b (mod m), then b ≡ a (mod m);
(iii) if a ≡ b (mod m) and b ≡ c (mod m), then a ≡ c (mod
m).
• Proposition 3.2. Let m > 0 be a fixed integer.
(i) If a = qm + r , then a ≡ r (mod m).
(ii) If 0 ≤ r ’< r < m, then r and r ’are not congruent mod
m; in symbols, r r ’ (mod m).
(iii) a ≡ b (mod m) if and only if a and b leave the same
remainder after dividing by m.
24
3.Congruences
• Proposition 3.3. Let m> 0 be a fixed integer.
(i) If ai ≡ a’i (mod m) for i = 1; 2; … ; n, then
a1 +... + an ≡ a’1 +...+ a’n (mod m):
In particular, if a ≡ a’ (mod m) and b ≡ b’ (mod m),
then
a + b ≡ a’ + b’ (mod m):
(ii) If ai ≡ a’i (mod m) for i = 1; 2; … ; n, then
a1 ... an ≡ a’1 ... a'n (mod m)
In particular, if a ≡ a’ (mod m) and b ≡ b’ (mod m),
then ab ≡ a’b’ (mod m)
(iii) If a ≡ b (mod m), then an
≡ bn
(mod m) for all n >0. 25
3.Congruences
26
Theorem 3.4 (Fermat).
3.Congruences
• Theorem 3.5. If (a;m)= 1, then, for every integer b, the
congruence ax ≡ b (mod m) can be solved for x; in fact,
x = sb, where sa ≡ 1 (mod m). Moreover, any two solutions
are congruent mod m.
Proof. Since (a;m)= 1, there is an integer s with
as ≡ 1( mod m) (because there is a linear combination
1 = sa + tm). It follows that b = sab + tmb and
asb ≡ b (mod m), so that x = sb is a solution. (Note that
Proposition 3.2(i) allows us to take s with 1≤ s < m.)
If y is another solution, then ax ≡ ay mod m, and so
m | a(x - y). Since (a;m)= 1, Theorem 1.4 gives m |(x – y);
that is, x ≡ y (mod m).
27
4.Quadratic Residues
• Definition 4.1. If m is a positive integer ,we say that the
integer a is a quadratic residue of m if (a,m) = 1 and the
congruence x2
≡ a (mod m) has a solution.
If the congruence x2
≡ a (mod m) has a no solution, we say a
is quadratic nonresidue of m.
Example. To detemine which integer are quadratic residues of
11, we compute the squares of the integer 1, 2, 3, …, 10.We
find that 12
≡ 102
≡ 1(mod 11), 22
≡ 92
≡ 4 (mod 11), 32
≡ 82
≡ 9
(mod 11), 42
≡ 72
≡ 5 (mod 11), and 52
≡ 62
≡ 3(mod11).
Hence , the quadratic residues of 11 are 1, 3, 4, 5, 9 ;the integer
2,6,7,8,10 are quadratic nonresidues of 11.
28
4.Quadratic Residues
• Lemma 4.1. Let p be odd prime and a an integer not divisible
by p. Then the congruence x2
≡ a (mod p) has either no
solutions or exactly two incongruent solutions modulo p.
• Proof. If x2
≡ a (mod p ) has a solution, say x = x0, then we can
easily demonstrate that x = - x0 is second incongruent solution.
Since (-x0)2
= x0
2
≡ a (mod p ) we see that – x0 is solution. We
note that x0 –x0 (mod p), for if x0 ≡ - x0 (mod p), then we have
2x0 ≡ 0 (mod p). This is impossible since p is odd and p x0
(since x0
2
≡ a (mod p ) and p a ).
To show that there are no more than two incogruent solutions,
assume that x ≡ x0 and x ≡ x1 are both solutions of x2
≡ a (mod
p). Then we have x0
2
≡ x1
2
≡ a (mod p) , so that
29
≡
|/
|/
4.Quadratic Residues
x0
2
- x1
2
= (x0 + x1)(x0- x1) ≡ 0 (mod p).
Hence , p| (x0 +x1) or p | (x0- x1), so that x1 ≡ - x0 (mod p) or
x0 ≡ x1 (mod p). Therefore if there is a solution of x2
≡ a (mod
p), there are exactly two incongruent solution.
Theorem 4.2. If p is an odd prime , then there are exactly
(p-1 )/2 quadratic residues of p and ( p – 1 )/2 quadratic
nonresidues of p among the integer 1, 2, …, p – 1 .
Proof. To find all the quadratic residues of p among the
integers 1, 2, …, p – 1 we compute the least positive residues
modulo p of the squares of the integers 1, 2, p – 1 .
30
4.Quadratic Residues
• Since there are p – 1 squares to consider and since each
congruence x2
≡ a (mod p) has either zero or two solotions ,
there must be exactly ( p – 1 )/2 quadratic residues of p among
the integer 1, 2, …, p – 1 . The remaining p – 1 – ( p – 1 )/2
= ( p – 1 )/2 positive integers less than p – 1 are quadratic
nonresidues of p .
The special notation associaed with quadratic residues is
described in the following definition.
31
W
4.Quadratic Residues
• Definition 4.2. Let p be an odd prime and a an integer not
divisible by p . The Legendre symbol is defined by
• The symbol iz named after the French mathematician
Andrien – Marie Legendre who introduced the use of this
notation
32
1
1
if a iz quadraticresidueof pa
if aiz aquadratic nonresidueof pp
  
=  ÷
−  
4.Quadratic Residues
• Example . The previous example shows that the Legendre
symbol
have the followings values :
33
, 1,2,...,10
11
a
a
 
= ÷
 
1 3 4 5 9
1
11 11 11 11 11
2 6 7 8 10
1
11 11 11 11 11
         
= = = = = ÷  ÷  ÷  ÷  ÷
         
         
= = = = = − ÷  ÷  ÷  ÷  ÷
         
4.Quadratic Residues
We now present a criterion for deciding whether an integer is
a quadratic residue of prime. This criterion is useful in
demonstraing propeties of the Legendre symbol.
Theorem 4.3. Euler’s Criterion.
Let p be an odd prime and let a be positive integer not
divisible by p. Then
34
( 1)/ 2
(mod ).pa
a p
p
− 
≡ ÷
 
4.Quadratic Residues
Proof.
Firt ,assume that .Then , the congruence x2
≡ a (mod p)
has a solution, say x = x0. Using Fermat’s little theorem , we see
that
Hence,if ,we know that
35
1
a
p
 
= ÷
 
( 1)/2 2 ( 1)/2 1
0 0( ) 1(mod )p p p
a x x p− − −
= = ≡
1
a
p
 
= ÷
 
( 1)/ 2
(mod )pa
a p
p
− 
≡ ÷
 
4.Quadratic Residues
• Now cosider the case where .Then , the congruence
x2
≡ a (mod p) has no solutions. For each integer i such that
1≤i≤p-1, there is a unique integer j with 1≤j≤p-1, such that
ij ≡ a (mod p ). Furthermore , since the congruence x2
≡ a
(mod p) has no solutions, we know that i≠j. Thus, we can
group the integer 1, 2,…, p - 1 into (p – 1 )/2 pairs each with
product a . Multiplying these pairs together, we find that
(p – 1 )! ≡ a (p–1)/2
(mod p).Since Wilson’s theorem tell us that
(p – 1 )!≡ - 1 (mod p), we see that – 1 ≡ a (p-1 )/2
(mod p) .In this
case, we also have
36
1
a
p
 
= − ÷
 
( 1)/ 2
(mod ).pa
a p
p
− 
≡ ÷
 
4.Quadratic Residues
Theorem 4.4. Let p be an odd prime and a and b integers not
divisible by p.Then
37
2
) (mod ), .
) .
) 1.
a b
i if a b p then
p p
a b ab
ii
p p p
a
iii
p
   
≡ = ÷  ÷
   
    
= ÷ ÷  ÷
    
 
= ÷
 
4.Quadratic Residues
Proof.
i) If a ≡ b (mod p ) then x2
≡ a (mod p) has s solution if an
only if x2
≡ b (mod p) has solution.Hence .
ii) By Euler’s criterion we know that
38
a b
p p
   
= ÷  ÷
   
( 1)/ 2 ( 1)/ 2
( 1)/2
(mod ) , (mod )
( ) (mod )
p p
p
a b
a p b p
p p
ab
ab p
p
− −
−
   
≡ ≡ ÷  ÷
   
 
≡ ÷
 
4.Quadratic Residues
Hence ,
Since the only posible values of a Lagendre symbol are ±1, we
conclude that
39
( 1)/ 2 ( 1)/2 ( 1)/2
( ) (mod )p p pa b ab
a b ab p
p p p
− − −    
≡ = ≡ ÷ ÷  ÷
    
a b ab
p p p
    
= ÷ ÷  ÷
    
4.Quadratic Residues
• iii) Since , from part (ii) it folows that
40
1
a
p
 
= ± ÷
 
2
1
a a a
p p p
    
= = ÷  ÷ ÷
   
The Euclidean Algorithm
How the Algorithm Works
Start with two integers for which you want to
find the GCD. Apply the division algorithm,
dividing the smaller number into the larger.
Example: a = 320, b = 296.
320 = 296 · 1 + 24
The first quotient is q0 and the first remainder
is r0.
How the Algorithm Works (cont.)
If you get a remainder of 0, stop. If not, the
divisor from the previous step becomes the
dividend of the next step. The remainder
from the previous step becomes the divisor of
the previous step.
320 = 296 · 1 + 24
296 = 24 · 12 + 8
Continue until you get a remainder of 0.
The Completed Algorithm
• 320 = 296 · 1 + 24
• 296 = 24 · 12 + 8
• 24 = 8 · 3 + 0
• We get a remainder of 0, so we stop. The last
nonzero remainder is the GCD, so (320, 296) is
equal to 8.
Another Example
Compute (346, 592).
592 = 346 · 1 + 246
346 = 246 · 1 + 100
246 = 100 · 2 + 46
100 = 46 · 2 + 8
46 = 8 · 5 + 6
8 = 6 · 1 + 2
6 = 2 · 3 + 0
So (346, 592) = 2.
The Euclidean Algorithm and Bézout’s
Theorem
We can use the Euclidean Algorithm to find
the integers U and V from Bézout’s Theorem.
As an example, let’s use the Euclidean
Algorithm to show that (324, 148) = 4.
324 = 148 · 2 + 28
148 = 28 · 5 + 8
28 = 8 · 3 + 4
8 = 4 · 2 + 0
Finding U and V
• We want to find integers U and V such that
4 = 324U + 148V.
• Take all of the equations (except the last one)
and solve for the remainder.
• 28 = 324 – 148 · 2
• 8 = 148 – 28 · 5
• 4 = 28 – 8 · 3
Back-Substitution
• Notice that the last equation expresses 4 as a
linear combination of 28 and 8.
• 4 = 28 · 1 + 8 · (-3)
• This is not what we want, however. So we use
the previous equation (which has been solved
for 8) to substitute.
Back-Substitution (cont.)
• 4 = 28 · 1 + (148 – 28 · 5) · (-3)
• Now we want to rearrange this so that 4 is
expressed as a linear combination of 28 and
148 (still not quite what we want, but getting
closer)
• We get 4 = 28 · 16 + 148 · (-3)
Back-Substitution (cont.)
Now use the previous equation (which has
been solved for 28) to substitute.
We get 4 = (324 – 148 · 2) · 16 + 148 · (-3)
Once again, multiply out and rearrange until
we get 4 expressed as a linear combination of
324 and 148.
4 = 324 · 16 + 148 · (-35)
Another Example
• Use the Euclidean Algorithm to show that
(15, 36) = 3.
• Use back-substitution to find integers U and V
so that 3 = 15U + 36V.
52
Number Theory
53
Introduction to Number Theory
•Number theory is about integers and their properties.
•We will start with the basic principles of
• divisibility,
• greatest common divisors,
• least common multiples, and
• modular arithmetic
•and look at some relevant algorithms.
54
Division
•If a and b are integers with a ≠ 0, we say that
a divides b if there is an integer c so that b = ac.
•When a divides b we say that a is a factor of b and that b
is a multiple of a.
•The notation a | b means that a divides b.
•We write a X b when a does not divide b
•(see book for correct symbol).
55
Divisibility Theorems
•For integers a, b, and c it is true that
• if a | b and a | c, then a | (b + c)
• Example: 3 | 6 and 3 | 9, so 3 | 15.
• if a | b, then a | bc for all integers c
• Example: 5 | 10, so 5 | 20, 5 | 30, 5 | 40, …
• if a | b and b | c, then a | c
• Example: 4 | 8 and 8 | 24, so 4 | 24.
•
56
Primes
•A positive integer p greater than 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.
•The fundamental theorem of arithmetic:
•Every positive integer can be written uniquely as the
product of primes, where the prime factors are written in
order of increasing size.
57
Primes
•Examples:
3·53·5
48 =48 =
17 =17 =
100 =100 =
512 =512 =
515 =515 =
28 =28 =
15 =15 =
2·2·2·2·3 = 22·2·2·2·3 = 244
·3·3
1717
2·2·5·5 = 22·2·5·5 = 222
·5·522
2·2·2·2·2·2·2·2·2 = 22·2·2·2·2·2·2·2·2 = 299
5·1035·103
2·2·72·2·7
58
Primes
•If n is a composite integer, then n has a prime divisor
less than or equal .
•This is easy to see: if n is a composite integer, it must
have two prime divisors p1 and p2 such that p1⋅p2 = n.
•p1 and p2 cannot both be greater than
• , because then p1⋅p2 > n.
n
n
59
The Division Algorithm
•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 above equation,
• d is called the divisor,
• a is called the dividend,
• q is called the quotient, and
• r is called the remainder.
60
The Division Algorithm
•Example:
•When we divide 17 by 5, we have
•17 = 5⋅3 + 2.
• 17 is the dividend,
• 5 is the divisor,
• 3 is called the quotient, and
• 2 is called the remainder.
61
The Division Algorithm
•Another example:
•What happens when we divide -11 by 3 ?
•Note that the remainder cannot be negative.
•-11 = 3⋅(-4) + 1.
• -11 is the dividend,
• 3 is the divisor,
• -4 is called the quotient, and
• 1 is called the remainder.
62
Greatest Common Divisors
•Let a and b be integers, not both zero.
•The largest integer d such that d | a and d | b is called
the greatest common divisor of a and b.
•The greatest common divisor of a and b is denoted by
gcd(a, b).
•Example 1: What is gcd(48, 72) ?
•The positive common divisors of 48 and 72 are
1, 2, 3, 4, 6, 8, 12, 16, and 24, so gcd(48, 72) = 24.
•Example 2: What is gcd(19, 72) ?
•The only positive common divisor of 19 and 72 is
1, so gcd(19, 72) = 1.
63
Greatest Common Divisors
•Using prime factorizations:
•a = p1
a
1 p2
a
2 … pn
a
n , b = p1
b
1 p2
b
2 … pn
b
n ,
•where p1 < p2 < … < pn and ai, bi ∈ N for 1 ≤ i ≤ n
•gcd(a, b) = p1
min(a
1
,b
1
)
p2
min(a
2
,b
2
)
… pn
min(a
n
,b
n
)
•Example:
a = 60 =a = 60 = 2222
3311
5511
b = 54 =b = 54 = 2211
3333
5500
gcd(a, b) =gcd(a, b) = 2211
3311
5500
= 6= 6
64
Relatively Prime Integers
•Definition:
•Two integers a and b are relatively prime if
gcd(a, b) = 1.
•Examples:
•Are 15 and 28 relatively prime?
•Yes, gcd(15, 28) = 1.
•Are 55 and 28 relatively prime?
•Yes, gcd(55, 28) = 1.
•Are 35 and 28 relatively prime?
•No, gcd(35, 28) = 7.
Fall 2002 CMSC 203 - Discrete Structures 65
Relatively Prime Integers
•Definition:
•The integers a1, a2, …, an are pairwise relatively prime if
gcd(ai, aj) = 1 whenever 1 ≤ i < j ≤ n.
•Examples:
•Are 15, 17, and 27 pairwise relatively prime?
•No, because gcd(15, 27) = 3.
•Are 15, 17, and 28 pairwise relatively prime?
•Yes, because gcd(15, 17) = 1, gcd(15, 28) = 1 and gcd(17,
28) = 1.
Fall 2002 CMSC 203 - Discrete Structures 66
Least Common Multiples
•Definition:
•The least common multiple of the positive integers a and
b is the smallest positive integer that is divisible by both a
and b.
•We denote the least common multiple of a and b by
lcm(a, b).
•Examples:
lcm(3, 7) =lcm(3, 7) = 2121
lcm(4, 6) =lcm(4, 6) = 1212
lcm(5, 10) =lcm(5, 10) = 1010
Fall 2002 CMSC 203 - Discrete Structures 67
Least Common Multiples
•Using prime factorizations:
•a = p1
a
1 p2
a
2 … pn
a
n , b = p1
b
1 p2
b
2 … pn
b
n ,
•where p1 < p2 < … < pn and ai, bi ∈ N for 1 ≤ i ≤ n
•lcm(a, b) = p1
max(a
1
,b
1
)
p2
max(a
2
,b
2
)
… pn
max(a
n
,b
n
)
•Example:
a = 60 =a = 60 = 2222
3311
5511
b = 54 =b = 54 = 2211
3333
5500
lcm(a, b) =lcm(a, b) = 2222
3333
5511
= 4275 = 540= 4275 = 540
Fall 2002 CMSC 203 - Discrete Structures 68
GCD and LCM
a = 60 =a = 60 = 2222
3311
5511
b = 54 =b = 54 = 2211
3333
5500
lcm(a, b) =lcm(a, b) = 2222
3333
5511
= 540= 540
gcd(a, b) =gcd(a, b) = 2211
3311
5500
= 6= 6
Theorem: ab =Theorem: ab = gcd(a,b)lcm(a,b)gcd(a,b)lcm(a,b)
Fall 2002 CMSC 203 - Discrete Structures 69
Modular Arithmetic
•Let a be an integer and m be a positive integer.
We denote by a mod m the remainder when a is divided
by m.
•Examples:
9 mod 4 =9 mod 4 = 11
9 mod 3 =9 mod 3 = 00
9 mod 10 =9 mod 10 = 99
-13 mod 4 =-13 mod 4 = 33
Fall 2002 CMSC 203 - Discrete Structures 70
Congruences
•Let a and b be integers and m be a positive integer. We
say that a is congruent to b modulo m if
m divides a – b.
•We use the notation a ≡ b (mod m) to indicate that a is
congruent to b modulo m.
•In other words:
a ≡ b (mod m) if and only if a mod m = b mod m.
Fall 2002 CMSC 203 - Discrete Structures 71
Congruences
•Examples:
•Is it true that 46 ≡ 68 (mod 11) ?
•Yes, because 11 | (46 – 68).
•Is it true that 46 ≡ 68 (mod 22)?
•Yes, because 22 | (46 – 68).
•For which integers z is it true that z ≡ 12 (mod 10)?
•It is true for any z∈{…,-28, -18, -8, 2, 12, 22, 32, …}
•Theorem: Let m be a positive integer. The integers a and b
are congruent modulo m if and only if there is an integer k
such that a = b + km.
Fall 2002 CMSC 203 - Discrete Structures 72
Congruences
•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).
•Proof:
•We know that a ≡ b (mod m) and c ≡ d (mod m) implies
that there are integers s and t with
b = a + sm and d = c + tm.
•Therefore,
•b + d = (a + sm) + (c + tm) = (a + c) + m(s + t) and
•bd = (a + sm)(c + tm) = ac + m(at + cs + stm).
•Hence, a + c ≡ b + d (mod m) and ac ≡ bd (mod m).
Fall 2002 CMSC 203 - Discrete Structures 73
The Euclidean Algorithm
•The Euclidean Algorithm finds the greatest common
divisor of two integers a and b.
•For example, if we want to find gcd(287, 91), we divide
287 by 91:
•287 = 91⋅3 + 14
•We know that for integers a, b and c,
if a | b and a | c, then a | (b + c).
•Therefore, any divisor of 287 and 91 must also be a
divisor of 287 - 91⋅3 = 14.
•Consequently, gcd(287, 91) = gcd(14, 91).
Fall 2002 CMSC 203 - Discrete Structures 74
The Euclidean Algorithm
•In the next step, we divide 91 by 14:
•91 = 14⋅6 + 7
•This means that gcd(14, 91) = gcd(14, 7).
•So we divide 14 by 7:
•14 = 7⋅2 + 0
•We find that 7 | 14, and thus gcd(14, 7) = 7.
•Therefore, gcd(287, 91) = 7.
75
The Euclidean Algorithm
•In pseudocode, the algorithm can be implemented as
follows:
•procedure gcd(a, b: positive integers)
•x := a
•y := b
•while y ≠ 0
•begin
• r := x mod y
• x := y
• y := r
•end {x is gcd(a, b)}
76
Representations of Integers
•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,
•and ak ≠ 0.
•Example for b=10:
•859 = 8⋅102
+ 5⋅101
+ 9⋅100
77
Representations of Integers
•Example for b=2 (binary expansion):
•(10110)2 = 1⋅24
+ 1⋅22
+ 1⋅21
= (22)10
•Example for b=16 (hexadecimal expansion):
•(we use letters A to F to indicate numbers 10 to 15)
•(3A0F)16 = 3⋅163
+ 10⋅162
+ 15⋅160
= (14863)10
•
78
Representations of Integers
•How can we construct the base b expansion of an integer
n?
•First, divide n by b to obtain a quotient q0 and remainder a0,
that is,
•n = bq0 + a0, where 0 ≤ a0 < b.
•The remainder a0 is the rightmost digit in the base b
expansion of n.
•Next, divide q0 by b to obtain:
•q0 = bq1 + a1, where 0 ≤ a1 < b.
•a1 is the second digit from the right in the base b expansion
of n. Continue this process until you obtain a quotient equal
to zero.
79
Representations of Integers
•Example:
What is the base 8 expansion of (12345)10 ?
•First, divide 12345 by 8:
•12345 = 8⋅1543 + 1
•1543 = 8⋅192 + 7
•192 = 8⋅24 + 0
•24 = 8⋅3 + 0
•3 = 8⋅0 + 3
•The result is: (12345)10 = (30071)8.
80
Representations of Integers
•procedure base_b_expansion(n, b: positive integers)
•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 … a1a0)b}
81
Addition of Integers
•Let a = (an-1an-2…a1a0)2, b = (bn-1bn-2…b1b0)2.
•How can we add these two binary numbers?
•First, add their rightmost bits:
•a0 + b0 = c0⋅2 + s0,
•where s0 is the rightmost bit in the binary expansion of a
+ b, and c0 is the carry.
•Then, add the next pair of bits and the carry:
•a1 + b1+ c0 = c1⋅2 + s1,
•where s1 is the next bit in the binary expansion of a + b,
and c1 is the carry.
82
Addition of Integers
•Continue this process until you obtain cn-1.
•The leading bit of the sum is sn = cn-1.
•The result is:
•a + b = (snsn-1…s1s0)2
83
Addition of Integers
•Example:
•Add a = (1110)2 and b = (1011)2.
•a0 + b0 = 0 + 1 = 0⋅2 + 1, so that c0 = 0 and s0 = 1.
•a1 + b1+ c0 = 1 + 1 + 0 = 1⋅2 + 0, so c1 = 1 and s1 = 0.
•a2 + b2+ c1 = 1 + 0 + 1 = 1⋅2 + 0, so c2 = 1 and s2 = 0.
•a3 + b3+ c2 = 1 + 1 + 1 = 1⋅2 + 1, so c3 = 1 and s3 = 1.
•s4 = c3 = 1.
•Therefore, s = a + b = (11001)2.
84
Addition of Integers
•How do we (humans) add two integers?
•Example: 7583
+ 4932
5511552211
111111 carrycarry
Binary expansions:Binary expansions: (1011)(1011)22
++ (1010)(1010)22
1100
carrycarry11
1100
11
11(( ))22
85
Addition of Integers
•Let a = (an-1an-2…a1a0)2, b = (bn-1bn-2…b1b0)2.
•How can we algorithmically add these two binary
numbers?
•First, add their rightmost bits:
•a0 + b0 = c0⋅2 + s0,
•where s0 is the rightmost bit in the binary expansion of a
+ b, and c0 is the carry.
•Then, add the next pair of bits and the carry:
•a1 + b1+ c0 = c1⋅2 + s1,
•where s1 is the next bit in the binary expansion of a + b,
and c1 is the carry.
86
Addition of Integers
•Continue this process until you obtain cn-1.
•The leading bit of the sum is sn = cn-1.
•The result is:
•a + b = (snsn-1…s1s0)2
87
Addition of Integers
•Example:
•Add a = (1110)2 and b = (1011)2.
•a0 + b0 = 0 + 1 = 0⋅2 + 1, so that c0 = 0 and s0 = 1.
•a1 + b1+ c0 = 1 + 1 + 0 = 1⋅2 + 0, so c1 = 1 and s1 = 0.
•a2 + b2+ c1 = 1 + 0 + 1 = 1⋅2 + 0, so c2 = 1 and s2 = 0.
•a3 + b3+ c2 = 1 + 1 + 1 = 1⋅2 + 1, so c3 = 1 and s3 = 1.
•s4 = c3 = 1.
•Therefore, s = a + b = (11001)2.
88
Addition of Integers
•procedure add(a, b: positive integers)
•c := 0
•for j := 0 to n-1
•begin
• d := (aj + bj + c)/2
• sj := aj + bj + c – 2d
• c := d
•end
•sn := c
•{the binary expansion of the sum is (snsn-1…s1s0)2}
89
Mathematical InductionMathematical Induction
90
Mathematical Induction: ExampleMathematical Induction: Example
Show that any postage of ≥ 8¢ can be
obtained using 3¢ and 5¢ stamps.
First check for a few particular values:
8¢ = 3¢ + 5¢
9¢ = 3¢ + 3¢ + 3¢
10¢ = 5¢ + 5¢
11¢ = 5¢ + 3¢ + 3¢
12¢ = 3¢ + 3¢ + 3¢ + 3¢
How to generalize this?
91
Mathematical Induction: ExampleMathematical Induction: Example
• Let P(n) be the sentence “n cents postage can be
obtained using 3¢ and 5¢ stamps”.
• Want to show that
“P(k) is true” implies “P(k+1) is true”
for any k ≥ 8¢.
• 2 cases: 1) P(k) is true and
the k cents contain at least one 5¢.
2) P(k) is true and
the k cents do not contain any 5¢.
92
Mathematical Induction: ExampleMathematical Induction: Example
• Case 1: k cents contain at least one 5¢ coin.
• Case 2: k cents do not contain any 5¢ coin.
Then there are at least three 3¢ coins.
5¢ 3¢ 3¢
Replace 5¢ coin
by two 3¢ coinsk cents k+1 cents
3¢
3¢
3¢ 5¢ 5¢
Replace three
3¢ coins by two
5¢ coins
k cents k+1 cents
93
Domino EffectDomino Effect
• Mathematical induction works like domino
effect:
• Let P(n) be “The nth domino falls backward”.
• If (a) “P(1) is true”;
(b) “P(k) is true” implies “P(k+1) is true”
Then P(n) is true for every n
94
Principle of MathematicalPrinciple of Mathematical
InductionInduction
Let P(n) be a predicate defined for
integers n.
Suppose the following statements are true:
1. Basis step:
P(a) is true for some fixed a∈Z .
2. Inductive step: For all integers k ≥ a,
if P(k) is true then P(k+1) is true.
Then for all integers n ≥ a, P(n) is true.
95
Example: Sum of Odd IntegersExample: Sum of Odd Integers
 Proposition: 1 + 3 + … + (2n-1) = n2
for all integers n≥1.
 Proof (by induction):
1) Basis step:
The statement is true for n=1: 1=12
.
2) Inductive step:
Assume the statement is true for some k≥1
(inductive hypothesis) ,
show that it is true for k+1 .
Example: Sum of Odd IntegersExample: Sum of Odd Integers
 Proof (cont.):
The statement is true for k:
1+3+…+(2k-1) = k2
(1)
We need to show it for k+1:
1+3+…+(2(k+1)-1) = (k+1)2
(2)
Showing (2):
1+3+…+(2(k+1)-1) = 1+3+…+(2k+1) =
1+3+…+(2k-1)+(2k+1) =
k2
+(2k+1) = (k+1)2
.
We proved the basis and inductive steps,
so we conclude that the given statement true. ■
by (1)
97
Important theorems proved byImportant theorems proved by
mathematical inductionmathematical induction
 Theorem 1 (Sum of the first n integers):
For all integers n≥1,
 Theorem 2 (Sum of a geometric sequence):
For any real number r except 1, and any
integer n≥0,
2
)1(
...21
+
=+++
nn
n
1
11
0 −
−
=
+
=
∑ r
r
r
nn
i
i
98
Example
(of sum of the first n integers)
In a round-robin tournament each of the n
teams plays every other team exactly once.
What is the total number of games played?
Solution on the board.
99
Proving a divisibility property byProving a divisibility property by
mathematical inductionmathematical induction
• Proposition: For any integer n≥1,
7n
- 2n
is divisible by 5. (P(n))
• Proof (by induction):
1) Basis step:
The statement is true for n=1: (P(1))
71
– 21
= 7 - 2 = 5 is divisible by 5.
2) Inductive step:
Assume the statement is true for some k≥1 (P(k))
(inductive hypothesis) ;
show that it is true for k+1 . (P(k+1))
100
Proving a divisibility property byProving a divisibility property by
mathematical inductionmathematical induction
Proof (cont.): We are given that
P(k): 7k
- 2k
is divisible by 5. (1)
Then 7k
- 2k
= 5a for some a∈Z . (by definition) (2)
We need to show:
P(k+1): 7k+1
- 2k+1
is divisible by 5. (3)
7k+1
- 2k+1
= 7·7k
- 2·2k
= 5·7k
+ 2·7k
- 2·2k
= 5·7k
+ 2·(7k
- 2k
) = 5·7k
+ 2·5a (by (2))
= 5·(7k
+ 2a) which is divisible by 5. (by def.)
Thus, P(n) is true by induction. ■

More Related Content

What's hot

project
projectproject
Number theory
Number theoryNumber theory
Number theory
Samsil Arefin
 
Logical equivalence, laws of logic
Logical equivalence, laws of logicLogical equivalence, laws of logic
Logical equivalence, laws of logic
Lakshmi R
 
Remainder theorem
Remainder theoremRemainder theorem
Remainder theorem
Department of Education
 
CMSC 56 | Lecture 15: Closures of Relations
CMSC 56 | Lecture 15: Closures of RelationsCMSC 56 | Lecture 15: Closures of Relations
CMSC 56 | Lecture 15: Closures of Relations
allyn joy calcaben
 
number theory.ppt
number theory.pptnumber theory.ppt
number theory.ppt
Shishu
 
CMSC 56 | Lecture 16: Equivalence of Relations & Partial Ordering
CMSC 56 | Lecture 16: Equivalence of Relations & Partial OrderingCMSC 56 | Lecture 16: Equivalence of Relations & Partial Ordering
CMSC 56 | Lecture 16: Equivalence of Relations & Partial Ordering
allyn joy calcaben
 
Factor Theorem and Remainder Theorem
Factor Theorem and Remainder TheoremFactor Theorem and Remainder Theorem
Factor Theorem and Remainder Theorem
Ronalie Mejos
 
Discrete Math Lecture 03: Methods of Proof
Discrete Math Lecture 03: Methods of ProofDiscrete Math Lecture 03: Methods of Proof
Discrete Math Lecture 03: Methods of Proof
IT Engineering Department
 
CMSC 56 | Lecture 11: Mathematical Induction
CMSC 56 | Lecture 11: Mathematical InductionCMSC 56 | Lecture 11: Mathematical Induction
CMSC 56 | Lecture 11: Mathematical Induction
allyn joy calcaben
 
Mathematical Induction
Mathematical InductionMathematical Induction
Mathematical Induction
Edelyn Cagas
 
Sets and relations
Sets and relationsSets and relations
Sets and relations
SURBHI SAROHA
 
Permutation and combination
Permutation and combinationPermutation and combination
Permutation and combination
Shwetha Pejathaya
 
2.2 Set Operations
2.2 Set Operations2.2 Set Operations
2.2 Set Operations
showslidedump
 
Permutation and combination
Permutation and combinationPermutation and combination
Permutation and combination
Kiran Kurian Philip
 
Number theory lecture (part 1)
Number theory lecture (part 1)Number theory lecture (part 1)
Number theory lecture (part 1)
Aleksandr Yampolskiy
 
Predicates and Quantifiers
Predicates and QuantifiersPredicates and Quantifiers
Predicates and Quantifiers
blaircomp2003
 
Linear differential equation with constant coefficient
Linear differential equation with constant coefficientLinear differential equation with constant coefficient
Linear differential equation with constant coefficient
Sanjay Singh
 
Sequences and Series
Sequences and SeriesSequences and Series
Sequences and Series
sujathavvv
 
Chapter 4 Cyclic Groups
Chapter 4 Cyclic GroupsChapter 4 Cyclic Groups
Chapter 4 Cyclic Groups
Tony Cervera Jr.
 

What's hot (20)

project
projectproject
project
 
Number theory
Number theoryNumber theory
Number theory
 
Logical equivalence, laws of logic
Logical equivalence, laws of logicLogical equivalence, laws of logic
Logical equivalence, laws of logic
 
Remainder theorem
Remainder theoremRemainder theorem
Remainder theorem
 
CMSC 56 | Lecture 15: Closures of Relations
CMSC 56 | Lecture 15: Closures of RelationsCMSC 56 | Lecture 15: Closures of Relations
CMSC 56 | Lecture 15: Closures of Relations
 
number theory.ppt
number theory.pptnumber theory.ppt
number theory.ppt
 
CMSC 56 | Lecture 16: Equivalence of Relations & Partial Ordering
CMSC 56 | Lecture 16: Equivalence of Relations & Partial OrderingCMSC 56 | Lecture 16: Equivalence of Relations & Partial Ordering
CMSC 56 | Lecture 16: Equivalence of Relations & Partial Ordering
 
Factor Theorem and Remainder Theorem
Factor Theorem and Remainder TheoremFactor Theorem and Remainder Theorem
Factor Theorem and Remainder Theorem
 
Discrete Math Lecture 03: Methods of Proof
Discrete Math Lecture 03: Methods of ProofDiscrete Math Lecture 03: Methods of Proof
Discrete Math Lecture 03: Methods of Proof
 
CMSC 56 | Lecture 11: Mathematical Induction
CMSC 56 | Lecture 11: Mathematical InductionCMSC 56 | Lecture 11: Mathematical Induction
CMSC 56 | Lecture 11: Mathematical Induction
 
Mathematical Induction
Mathematical InductionMathematical Induction
Mathematical Induction
 
Sets and relations
Sets and relationsSets and relations
Sets and relations
 
Permutation and combination
Permutation and combinationPermutation and combination
Permutation and combination
 
2.2 Set Operations
2.2 Set Operations2.2 Set Operations
2.2 Set Operations
 
Permutation and combination
Permutation and combinationPermutation and combination
Permutation and combination
 
Number theory lecture (part 1)
Number theory lecture (part 1)Number theory lecture (part 1)
Number theory lecture (part 1)
 
Predicates and Quantifiers
Predicates and QuantifiersPredicates and Quantifiers
Predicates and Quantifiers
 
Linear differential equation with constant coefficient
Linear differential equation with constant coefficientLinear differential equation with constant coefficient
Linear differential equation with constant coefficient
 
Sequences and Series
Sequences and SeriesSequences and Series
Sequences and Series
 
Chapter 4 Cyclic Groups
Chapter 4 Cyclic GroupsChapter 4 Cyclic Groups
Chapter 4 Cyclic Groups
 

Similar to Number theory

Números repunits de lehmer
Números repunits de lehmerNúmeros repunits de lehmer
Números repunits de lehmer
lenixez
 
A Proof of Twin primes and Golbach's Conjecture
A Proof of Twin primes and Golbach's ConjectureA Proof of Twin primes and Golbach's Conjecture
A Proof of Twin primes and Golbach's Conjecture
nikos mantzakouras
 
Ch08
Ch08Ch08
UNIT III.pptx
UNIT III.pptxUNIT III.pptx
UNIT III.pptx
UmeshReddy49
 
Number theory
Number theoryNumber theory
Number theory
cherrymer molina
 
DAA - UNIT 4 - Engineering.pptx
DAA - UNIT 4 - Engineering.pptxDAA - UNIT 4 - Engineering.pptx
DAA - UNIT 4 - Engineering.pptx
vaishnavi339314
 
Proof Techniques
Proof TechniquesProof Techniques
Proof Techniques
CHANDANKUMARMANDAL5
 
Solutions Manual for An Introduction To Abstract Algebra With Notes To The Fu...
Solutions Manual for An Introduction To Abstract Algebra With Notes To The Fu...Solutions Manual for An Introduction To Abstract Algebra With Notes To The Fu...
Solutions Manual for An Introduction To Abstract Algebra With Notes To The Fu...
Aladdinew
 
Ch08
Ch08Ch08
Heuristics for counterexamples to the Agrawal Conjecture
Heuristics for counterexamples to the Agrawal ConjectureHeuristics for counterexamples to the Agrawal Conjecture
Heuristics for counterexamples to the Agrawal Conjecture
Amshuman Hegde
 
RSA final notation change2
RSA final notation change2RSA final notation change2
RSA final notation change2
Coleman Gorham
 
ch08 modified.pptmodified.pptmodified.ppt
ch08 modified.pptmodified.pptmodified.pptch08 modified.pptmodified.pptmodified.ppt
ch08 modified.pptmodified.pptmodified.ppt
tahirnaquash2
 
CRYPTO 2.pptx
CRYPTO 2.pptxCRYPTO 2.pptx
CRYPTO 2.pptx
SanjanaMPradeep
 
Imc2017 day1-solutions
Imc2017 day1-solutionsImc2017 day1-solutions
Imc2017 day1-solutions
Christos Loizos
 
MFCS-17.ppt
MFCS-17.pptMFCS-17.ppt
MFCS-17.ppt
SharmaDeep4
 
Trig substitution
Trig substitutionTrig substitution
Trig substitution
dynx24
 
lecture6.ppt
lecture6.pptlecture6.ppt
lecture6.ppt
AbhiYadav655132
 
Chapter 6
Chapter 6Chapter 6
Chapter 6
Kuan-Lun Wang
 
Olimpiade matematika di kanada 2018
Olimpiade matematika di kanada 2018Olimpiade matematika di kanada 2018
Olimpiade matematika di kanada 2018
radar radius
 
3.-SEQUENCES-AND-SERIES-THEORY.hhsssspdf
3.-SEQUENCES-AND-SERIES-THEORY.hhsssspdf3.-SEQUENCES-AND-SERIES-THEORY.hhsssspdf
3.-SEQUENCES-AND-SERIES-THEORY.hhsssspdf
nassorokayanda9412
 

Similar to Number theory (20)

Números repunits de lehmer
Números repunits de lehmerNúmeros repunits de lehmer
Números repunits de lehmer
 
A Proof of Twin primes and Golbach's Conjecture
A Proof of Twin primes and Golbach's ConjectureA Proof of Twin primes and Golbach's Conjecture
A Proof of Twin primes and Golbach's Conjecture
 
Ch08
Ch08Ch08
Ch08
 
UNIT III.pptx
UNIT III.pptxUNIT III.pptx
UNIT III.pptx
 
Number theory
Number theoryNumber theory
Number theory
 
DAA - UNIT 4 - Engineering.pptx
DAA - UNIT 4 - Engineering.pptxDAA - UNIT 4 - Engineering.pptx
DAA - UNIT 4 - Engineering.pptx
 
Proof Techniques
Proof TechniquesProof Techniques
Proof Techniques
 
Solutions Manual for An Introduction To Abstract Algebra With Notes To The Fu...
Solutions Manual for An Introduction To Abstract Algebra With Notes To The Fu...Solutions Manual for An Introduction To Abstract Algebra With Notes To The Fu...
Solutions Manual for An Introduction To Abstract Algebra With Notes To The Fu...
 
Ch08
Ch08Ch08
Ch08
 
Heuristics for counterexamples to the Agrawal Conjecture
Heuristics for counterexamples to the Agrawal ConjectureHeuristics for counterexamples to the Agrawal Conjecture
Heuristics for counterexamples to the Agrawal Conjecture
 
RSA final notation change2
RSA final notation change2RSA final notation change2
RSA final notation change2
 
ch08 modified.pptmodified.pptmodified.ppt
ch08 modified.pptmodified.pptmodified.pptch08 modified.pptmodified.pptmodified.ppt
ch08 modified.pptmodified.pptmodified.ppt
 
CRYPTO 2.pptx
CRYPTO 2.pptxCRYPTO 2.pptx
CRYPTO 2.pptx
 
Imc2017 day1-solutions
Imc2017 day1-solutionsImc2017 day1-solutions
Imc2017 day1-solutions
 
MFCS-17.ppt
MFCS-17.pptMFCS-17.ppt
MFCS-17.ppt
 
Trig substitution
Trig substitutionTrig substitution
Trig substitution
 
lecture6.ppt
lecture6.pptlecture6.ppt
lecture6.ppt
 
Chapter 6
Chapter 6Chapter 6
Chapter 6
 
Olimpiade matematika di kanada 2018
Olimpiade matematika di kanada 2018Olimpiade matematika di kanada 2018
Olimpiade matematika di kanada 2018
 
3.-SEQUENCES-AND-SERIES-THEORY.hhsssspdf
3.-SEQUENCES-AND-SERIES-THEORY.hhsssspdf3.-SEQUENCES-AND-SERIES-THEORY.hhsssspdf
3.-SEQUENCES-AND-SERIES-THEORY.hhsssspdf
 

More from manikanta361

Loops and functions in r
Loops and functions in rLoops and functions in r
Loops and functions in r
manikanta361
 
Inroduction to r
Inroduction to rInroduction to r
Inroduction to r
manikanta361
 
Gui programming
Gui programmingGui programming
Gui programming
manikanta361
 
Graph theory
Graph theoryGraph theory
Graph theory
manikanta361
 
Set theory
Set theorySet theory
Set theory
manikanta361
 
Mathemetics module
Mathemetics moduleMathemetics module
Mathemetics module
manikanta361
 

More from manikanta361 (6)

Loops and functions in r
Loops and functions in rLoops and functions in r
Loops and functions in r
 
Inroduction to r
Inroduction to rInroduction to r
Inroduction to r
 
Gui programming
Gui programmingGui programming
Gui programming
 
Graph theory
Graph theoryGraph theory
Graph theory
 
Set theory
Set theorySet theory
Set theory
 
Mathemetics module
Mathemetics moduleMathemetics module
Mathemetics module
 

Recently uploaded

CSM Cloud Service Management Presentarion
CSM Cloud Service Management PresentarionCSM Cloud Service Management Presentarion
CSM Cloud Service Management Presentarion
rpskprasana
 
Technical Drawings introduction to drawing of prisms
Technical Drawings introduction to drawing of prismsTechnical Drawings introduction to drawing of prisms
Technical Drawings introduction to drawing of prisms
heavyhaig
 
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
thanhdowork
 
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
insn4465
 
2. Operations Strategy in a Global Environment.ppt
2. Operations Strategy in a Global Environment.ppt2. Operations Strategy in a Global Environment.ppt
2. Operations Strategy in a Global Environment.ppt
PuktoonEngr
 
Question paper of renewable energy sources
Question paper of renewable energy sourcesQuestion paper of renewable energy sources
Question paper of renewable energy sources
mahammadsalmanmech
 
ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...
ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...
ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...
Mukeshwaran Balu
 
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdfBPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
MIGUELANGEL966976
 
digital fundamental by Thomas L.floydl.pdf
digital fundamental by Thomas L.floydl.pdfdigital fundamental by Thomas L.floydl.pdf
digital fundamental by Thomas L.floydl.pdf
drwaing
 
Manufacturing Process of molasses based distillery ppt.pptx
Manufacturing Process of molasses based distillery ppt.pptxManufacturing Process of molasses based distillery ppt.pptx
Manufacturing Process of molasses based distillery ppt.pptx
Madan Karki
 
Advanced control scheme of doubly fed induction generator for wind turbine us...
Advanced control scheme of doubly fed induction generator for wind turbine us...Advanced control scheme of doubly fed induction generator for wind turbine us...
Advanced control scheme of doubly fed induction generator for wind turbine us...
IJECEIAES
 
PPT on GRP pipes manufacturing and testing
PPT on GRP pipes manufacturing and testingPPT on GRP pipes manufacturing and testing
PPT on GRP pipes manufacturing and testing
anoopmanoharan2
 
Series of visio cisco devices Cisco_Icons.ppt
Series of visio cisco devices Cisco_Icons.pptSeries of visio cisco devices Cisco_Icons.ppt
Series of visio cisco devices Cisco_Icons.ppt
PauloRodrigues104553
 
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressionsKuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
Victor Morales
 
New techniques for characterising damage in rock slopes.pdf
New techniques for characterising damage in rock slopes.pdfNew techniques for characterising damage in rock slopes.pdf
New techniques for characterising damage in rock slopes.pdf
wisnuprabawa3
 
Swimming pool mechanical components design.pptx
Swimming pool  mechanical components design.pptxSwimming pool  mechanical components design.pptx
Swimming pool mechanical components design.pptx
yokeleetan1
 
sieving analysis and results interpretation
sieving analysis and results interpretationsieving analysis and results interpretation
sieving analysis and results interpretation
ssuser36d3051
 
ML Based Model for NIDS MSc Updated Presentation.v2.pptx
ML Based Model for NIDS MSc Updated Presentation.v2.pptxML Based Model for NIDS MSc Updated Presentation.v2.pptx
ML Based Model for NIDS MSc Updated Presentation.v2.pptx
JamalHussainArman
 
6th International Conference on Machine Learning & Applications (CMLA 2024)
6th International Conference on Machine Learning & Applications (CMLA 2024)6th International Conference on Machine Learning & Applications (CMLA 2024)
6th International Conference on Machine Learning & Applications (CMLA 2024)
ClaraZara1
 
Iron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdf
Iron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdfIron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdf
Iron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdf
RadiNasr
 

Recently uploaded (20)

CSM Cloud Service Management Presentarion
CSM Cloud Service Management PresentarionCSM Cloud Service Management Presentarion
CSM Cloud Service Management Presentarion
 
Technical Drawings introduction to drawing of prisms
Technical Drawings introduction to drawing of prismsTechnical Drawings introduction to drawing of prisms
Technical Drawings introduction to drawing of prisms
 
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
 
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
 
2. Operations Strategy in a Global Environment.ppt
2. Operations Strategy in a Global Environment.ppt2. Operations Strategy in a Global Environment.ppt
2. Operations Strategy in a Global Environment.ppt
 
Question paper of renewable energy sources
Question paper of renewable energy sourcesQuestion paper of renewable energy sources
Question paper of renewable energy sources
 
ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...
ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...
ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...
 
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdfBPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
 
digital fundamental by Thomas L.floydl.pdf
digital fundamental by Thomas L.floydl.pdfdigital fundamental by Thomas L.floydl.pdf
digital fundamental by Thomas L.floydl.pdf
 
Manufacturing Process of molasses based distillery ppt.pptx
Manufacturing Process of molasses based distillery ppt.pptxManufacturing Process of molasses based distillery ppt.pptx
Manufacturing Process of molasses based distillery ppt.pptx
 
Advanced control scheme of doubly fed induction generator for wind turbine us...
Advanced control scheme of doubly fed induction generator for wind turbine us...Advanced control scheme of doubly fed induction generator for wind turbine us...
Advanced control scheme of doubly fed induction generator for wind turbine us...
 
PPT on GRP pipes manufacturing and testing
PPT on GRP pipes manufacturing and testingPPT on GRP pipes manufacturing and testing
PPT on GRP pipes manufacturing and testing
 
Series of visio cisco devices Cisco_Icons.ppt
Series of visio cisco devices Cisco_Icons.pptSeries of visio cisco devices Cisco_Icons.ppt
Series of visio cisco devices Cisco_Icons.ppt
 
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressionsKuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
 
New techniques for characterising damage in rock slopes.pdf
New techniques for characterising damage in rock slopes.pdfNew techniques for characterising damage in rock slopes.pdf
New techniques for characterising damage in rock slopes.pdf
 
Swimming pool mechanical components design.pptx
Swimming pool  mechanical components design.pptxSwimming pool  mechanical components design.pptx
Swimming pool mechanical components design.pptx
 
sieving analysis and results interpretation
sieving analysis and results interpretationsieving analysis and results interpretation
sieving analysis and results interpretation
 
ML Based Model for NIDS MSc Updated Presentation.v2.pptx
ML Based Model for NIDS MSc Updated Presentation.v2.pptxML Based Model for NIDS MSc Updated Presentation.v2.pptx
ML Based Model for NIDS MSc Updated Presentation.v2.pptx
 
6th International Conference on Machine Learning & Applications (CMLA 2024)
6th International Conference on Machine Learning & Applications (CMLA 2024)6th International Conference on Machine Learning & Applications (CMLA 2024)
6th International Conference on Machine Learning & Applications (CMLA 2024)
 
Iron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdf
Iron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdfIron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdf
Iron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdf
 

Number theory

  • 2. Number theory • 1.Divisors • 2.Primer Factorization • 3.Congruence • 4.Quadratic Residues 2
  • 3. 1.Divisors Theorem 1.1. Division Algorithm. Let n and d ≥ 1 be integers. There exist uniquely determined integers q and r such that n = qd + r and 0 ≤ r < d. Proof. Let X = {n − td|t ∈ , n − td ≥ 0}. Then X is nonempty (if n≥0,then n X; if n < 0, then n(1 − d) X). Hence let r be the∈ ∈ smallest member of X . Then r = n − qd for some q ∈ , and it remains to show that r < d. But if r ≥d, then 0 ≤ r − d = n − (q + 1)d, so r − d is in X contrary to the minimality of r. As to uniqueness, suppose that n = q’d + r’, where 0≤ r’< d. We may assume that r ≤ r’(a similar argument works if r’ ≤ r). Then 0 ≤ r’ − r = (q − q’)d, so (q − q’)d is a nonnegative multiple of d that is less than d (because r’ − r ≤ r ’< d). The only possibility is (q − q’)d = 0, so q’ = q, and hence r’ = r. 3
  • 4. 1.Divisors • Given n and d ≥ 1, the integers q and r in Theorem 1.1 are called, respectively, the quotient and remainder when n is divided by d. For example, if we divide n = −29 by d = 7, we find that −29 = (−5) · 7 + 6, so the quotient is −5 and remainder is 6. The usual process of long division is a procedure for finding the quotient and remainder for a given n and d ≥ 1. However, they can easily be found with a calculator. For example, if n = 3196 and d = 271 then n/d = 11,79 approximately, so q = 11. Then r = n − qd = 215, so 3196 = 11 · 271 + 215, as desired. If d and n are integers, we say that d divides n, or that d is a divisor of n, if n = qd for some integer q. We write d|n when this is the case. Thus, a positive integer p >1is prime if and only if p has no positive divisors except 1 and p. The following properties of the divisibility relation | are easily verified: 4
  • 5. 1.Divisors (i) n|n for every n. (ii) If d|m and m|n, then d|n. (iii) If d|n and n|d, then d = ±n. (iv) If d|n and d|m, then d|(xm + yn) for all integers x and y. Given positive integers m and n, an integer d is called a common divisor of m and n if d|m and d|n. If m and n are integers, not both zero, we say that d is the greatest common divisor of m and n, and write d = gcd(m, n), if the following three conditions are satisfied: (i) d ≥ 1. (ii) d|m and d|n. (iii) If k|m and k|n, then k|d. 5
  • 6. 1.Divisors • Theorem 1.2. Let m and n be integers, not both zero. Then d = gcd(m, n) exists,and d = xm + yn for some integers x and y. Proof. Let X = {sm + tn | s, t ∈ ; sm + tn ≥1}. Then X is not empty since m2 + n2 is in X, so let d be the smallest member of X. Since d X we have d∈ ≥ 1 and d = xm + yn for integers x and y, proving conditions (i) and (iii) in the definition of the gcd. Hence it remains to show that d|m and d|n.We show that d|n; the other is similar. By the division algorithm 6
  • 7. 1.Divisors write n = qd + r, where 0 ≤ r < d. Then r = n − q(xm + yn) = (−qx)m + (1 − qy)n. Hence, if r ≥ 1, then r X, contrary to the minimality of d. So r = 0 and we have∈ d|n. When gcd(m, n) = xm + yn where x and y are integers, we say that gcd(m, n) is a linear combination of m and n. There is an efficient way of computing x and y using the division algorithm. The following example illustrates the method. 7
  • 8. 1.Divisors • Example . Find gcd(37, 8) and express it as a linear combination of 37 and 8. Proof. It is clear that gcd(37, 8) = 1 because 37 is a prime; however, no linear combination is apparent. Dividing 37 by 8, and then dividing each successive divisor by the preceding remainder, gives the first set of equations. 37 = 4 · 8 +5 1= 3 − 1 · 2 = 3 − 1(5 − 1 · 3) 8 = 1 · 5 + 3 = 2 · 3 − 5 = 2(8 − 1 · 5) − 5 5 = 1 · 3 + 2 = 2 · 8 − 3 · 5 = 2 · 8 − 3(37 − 4 · 8) 3 = 1 · 2 + 1 = 14 · 8 − 3 · 37 2 = 2 · 1 The last nonzero remainder is 1, the greatest common divisor, and this turns out always to be the case. Eliminating remainders from the bottom up (as in the second set of equations) gives 1 = 14 · 8 − 3 · 37. 8
  • 9. 1.Divisors • Theorem 1.3. Euclidean Algorithm. Given integers m and n ≥ 1, use the division algorithm repeatedly: m = q1n + r1 0 ≤ r1 < n n = q2r1 + r2 0 ≤ r2 < r1 r1 = q3r2 + r3 0 ≤ r3 < r2 ... ... r k-2= qkrk−1 + rk 0 ≤ rk < rk-1 rk−1= qk+1rk where in each equation the divisor at the preceding stage is divided by the remainder. These remainders decrease r1 > r2 > · · · ≥ 0 9
  • 10. 1.Divisors so the process eventually stops when the remainder becomes zero. If r1 = 0, then gcd(m, n) = n. Otherwise, rk = gcd(m, n), where rk is the last nonzero remainder and can be expressed as a linear combination of m and n by eliminating remainders. Proof. Express rk as a linear combination of m and n by eliminating remainders in the equations from the second last equation up. Hence every common divisor of m and n divides rk. But rk is itself a common divisor of m and n (it divides every ri—work up through the equations). Hence rk = gcd(m, n). 10
  • 11. 1.Divisors Two integers m and n are called relatively prime if gcd(m, n) = 1. Hence 12 and 35 are relatively prime, but this is not true for 12 and 15 Because gcd(12, 15) = 3. Note that 1 is relatively prime to every integer m. The following theorem collects three basic properties of relatively prime integers. Theorem 1.4. If m and n are integers, not both zero: (i) m and n are relatively prime if and only if 1 = xm + yn for some integers x and y. (ii) If d = gcd(m, n), then m/d and n/d are relatively prime. (iii) Suppose that m and n are relatively prime. (a) If m|k and n|k, where k ∈ , then mn|k. (b) If m|kn for some k ∈ , then m|k 11
  • 12. 1.Divisors • Proof. (i) If 1 = xm + yn with x, y ∈ , then every divisor of both m and n divides 1, so must be 1 or −1. It follows that gcd(m, n) = 1. The converse is by the euclidean algorithm. (ii). By Theorem 1.2, write d = xm + yn, where x, y ∈ . Then 1 = x(m/d)+y(n/d) and (ii) follows from (i). (iii). Write 1 = xm + yn, where x, y ∈ . If k = am and k = bn, a, b ∈ then k = kxm + kyn = (xb + ya)mn, and (a) follows. As to (b), suppose that kn = qm, q ∈ . Then k = kxm + kyn = (kx + qn)m, so m|k. 12
  • 13. 2.Prime Factorization Recall that an integer p is called a prime if: • (i) p ≥ 2. • (ii) The only positive divisors of p are 1 and p. The reason for not regarding 1 as a prime is that we want the factorization of every integer into primes to be unique. The following result is needed. 13
  • 14. 2.Prime Factorization • Theorem 2. 1. Euclid’s Lemma. Let p denote a prime. (i) If p|mn where m, n ∈ , then either p|m or p|n. (ii) If p|m1m2 · · ·mr where each mi ∈ , then p|mi for some i. Proof. (i) Write d = gcd(m, p). Then d|p, so as p is a prime, either d = p or d = 1. If d = p, then p|m; if d =1, then since p|mn, we have p|n by Theorem 1.4 . (ii) This follows from (i) using induction on r. 14
  • 15. 2.Prime Factorization • Theorem 2.2. Every integer n >1 is a product of primes. • Proof. Let pn denote the statement of the theorem. Then p2 is clearly true. If p2, p3, . . . , pk are all true, consider the integer k + 1. If k + 1 is a prime, there is nothing to prove. Otherwise, k + 1 = ab, where 2 ≤ a, b ≤ k. But then each of a and b are products of primes because pa and pb are both true by the (strong) induction assumption. Hence ab = k + 1 is also a product of primes, as required. 15
  • 16. 2.Prime Factorization • Theorem 2.3. Prime Factorization Theorem. Every integer n ≥ 2 can be written as a product of (one or more) primes. Moreover, this factorization is unique except for the order of the factors. That is, if n = p1p2 · · · pr and n = q1q2 · · · qs , where the pi and qj are primes, then r = s and the qj can be relabeled so that pi = qi for each i. 16
  • 17. 2.Prime Factorization • Proof. The existence of such a factorization was shown in Theorem 2.2. To prove uniqueness, we induction the minimum of r and s. If this is 1, then n is a prime and the uniqueness follows from Euclid’s lemma. Otherwise, r ≥ 2 and s ≥ 2. Since p1|n = q1q2 · · · qs Euclid’s lemma shows that p1 divides some qj , say p1|q1 (after possible relabeling of the qj ). But then p1 = q1 because q1 is a prime. Hence n/p1 = p2p3· · · pr = q2q3 · · · qs , so, by induction, r − 1 = s − 1 and q2, q3, . . . , qs can be relabeled such that pi = qi for all i = 2, 3, . . . , r. The theorem follows. 17
  • 18. 2.Prime Factorization • It follows that every integer n ≥ 2 can be written in the form n = p1 n 1 p2 n 2 · · · pr n r ,where p1, p2, . . . , pr are distinct primes, ni ≥ 1 for each i, and the pi and ni are determined uniquely by n. If every ni = 1, we say that n is square-free, while if n has only one prime divisor, we call n a prime power.If the prime factorization n = p1 n 1 p2 n 2 · · · pr n r of an integer n is given, and if d is a positive divisor of n, then these pi are the only possible prime divisors of d (by Euclid’s lemma). It follows that 18
  • 21. 21
  • 22. 3.Congruences • Definition 3.1.. If m ≥ 0 is fixed, then integers a and b are congruent modulo m,denoted by a ≡ b (mod m) if m | (a – b ). Usually, one assumes that the modulus m >1 because the cases m = 0 and m = 1 are not very interesting: if a and b are integers, then a ≡ b (mod 0) if and only if 0 | (a –b), that is, a = b, and so congruence mod 0 is ordinary equality. The congruence a ≡ b (mod 1) is true for every pair of integers a and b because 1 | (a – b) always. Hence, every two integers are congruent mod 1. 22
  • 23. 3.Congruences • If a and b are positive integers, then a ≡ b (mod 10) if and only if they have the same last digit; more generally, a ≡ b (mod 10n )if and only if they have same last n digits. For example, 526 ≡ 1926 (mod 100). • London time is 6 hours later than Chicago time. What time is it in London if it is 10:00 A.M. in Chicago? Since clocks are set up with 12 hour cycles, this is really a problem about congruence mod 12. To solve it, note that 10 + 6 = 16 ≡ 4(mod 12); and so it is 4:00 P.M. in London. 23
  • 24. 3.Congruences • Proposition 3.1. If m > 0 is a fixed integer, then for all integers a, b, c, (i) a ≡ a (mod m); (ii) if a ≡ b (mod m), then b ≡ a (mod m); (iii) if a ≡ b (mod m) and b ≡ c (mod m), then a ≡ c (mod m). • Proposition 3.2. Let m > 0 be a fixed integer. (i) If a = qm + r , then a ≡ r (mod m). (ii) If 0 ≤ r ’< r < m, then r and r ’are not congruent mod m; in symbols, r r ’ (mod m). (iii) a ≡ b (mod m) if and only if a and b leave the same remainder after dividing by m. 24
  • 25. 3.Congruences • Proposition 3.3. Let m> 0 be a fixed integer. (i) If ai ≡ a’i (mod m) for i = 1; 2; … ; n, then a1 +... + an ≡ a’1 +...+ a’n (mod m): In particular, if a ≡ a’ (mod m) and b ≡ b’ (mod m), then a + b ≡ a’ + b’ (mod m): (ii) If ai ≡ a’i (mod m) for i = 1; 2; … ; n, then a1 ... an ≡ a’1 ... a'n (mod m) In particular, if a ≡ a’ (mod m) and b ≡ b’ (mod m), then ab ≡ a’b’ (mod m) (iii) If a ≡ b (mod m), then an ≡ bn (mod m) for all n >0. 25
  • 27. 3.Congruences • Theorem 3.5. If (a;m)= 1, then, for every integer b, the congruence ax ≡ b (mod m) can be solved for x; in fact, x = sb, where sa ≡ 1 (mod m). Moreover, any two solutions are congruent mod m. Proof. Since (a;m)= 1, there is an integer s with as ≡ 1( mod m) (because there is a linear combination 1 = sa + tm). It follows that b = sab + tmb and asb ≡ b (mod m), so that x = sb is a solution. (Note that Proposition 3.2(i) allows us to take s with 1≤ s < m.) If y is another solution, then ax ≡ ay mod m, and so m | a(x - y). Since (a;m)= 1, Theorem 1.4 gives m |(x – y); that is, x ≡ y (mod m). 27
  • 28. 4.Quadratic Residues • Definition 4.1. If m is a positive integer ,we say that the integer a is a quadratic residue of m if (a,m) = 1 and the congruence x2 ≡ a (mod m) has a solution. If the congruence x2 ≡ a (mod m) has a no solution, we say a is quadratic nonresidue of m. Example. To detemine which integer are quadratic residues of 11, we compute the squares of the integer 1, 2, 3, …, 10.We find that 12 ≡ 102 ≡ 1(mod 11), 22 ≡ 92 ≡ 4 (mod 11), 32 ≡ 82 ≡ 9 (mod 11), 42 ≡ 72 ≡ 5 (mod 11), and 52 ≡ 62 ≡ 3(mod11). Hence , the quadratic residues of 11 are 1, 3, 4, 5, 9 ;the integer 2,6,7,8,10 are quadratic nonresidues of 11. 28
  • 29. 4.Quadratic Residues • Lemma 4.1. Let p be odd prime and a an integer not divisible by p. Then the congruence x2 ≡ a (mod p) has either no solutions or exactly two incongruent solutions modulo p. • Proof. If x2 ≡ a (mod p ) has a solution, say x = x0, then we can easily demonstrate that x = - x0 is second incongruent solution. Since (-x0)2 = x0 2 ≡ a (mod p ) we see that – x0 is solution. We note that x0 –x0 (mod p), for if x0 ≡ - x0 (mod p), then we have 2x0 ≡ 0 (mod p). This is impossible since p is odd and p x0 (since x0 2 ≡ a (mod p ) and p a ). To show that there are no more than two incogruent solutions, assume that x ≡ x0 and x ≡ x1 are both solutions of x2 ≡ a (mod p). Then we have x0 2 ≡ x1 2 ≡ a (mod p) , so that 29 ≡ |/ |/
  • 30. 4.Quadratic Residues x0 2 - x1 2 = (x0 + x1)(x0- x1) ≡ 0 (mod p). Hence , p| (x0 +x1) or p | (x0- x1), so that x1 ≡ - x0 (mod p) or x0 ≡ x1 (mod p). Therefore if there is a solution of x2 ≡ a (mod p), there are exactly two incongruent solution. Theorem 4.2. If p is an odd prime , then there are exactly (p-1 )/2 quadratic residues of p and ( p – 1 )/2 quadratic nonresidues of p among the integer 1, 2, …, p – 1 . Proof. To find all the quadratic residues of p among the integers 1, 2, …, p – 1 we compute the least positive residues modulo p of the squares of the integers 1, 2, p – 1 . 30
  • 31. 4.Quadratic Residues • Since there are p – 1 squares to consider and since each congruence x2 ≡ a (mod p) has either zero or two solotions , there must be exactly ( p – 1 )/2 quadratic residues of p among the integer 1, 2, …, p – 1 . The remaining p – 1 – ( p – 1 )/2 = ( p – 1 )/2 positive integers less than p – 1 are quadratic nonresidues of p . The special notation associaed with quadratic residues is described in the following definition. 31 W
  • 32. 4.Quadratic Residues • Definition 4.2. Let p be an odd prime and a an integer not divisible by p . The Legendre symbol is defined by • The symbol iz named after the French mathematician Andrien – Marie Legendre who introduced the use of this notation 32 1 1 if a iz quadraticresidueof pa if aiz aquadratic nonresidueof pp    =  ÷ −  
  • 33. 4.Quadratic Residues • Example . The previous example shows that the Legendre symbol have the followings values : 33 , 1,2,...,10 11 a a   = ÷   1 3 4 5 9 1 11 11 11 11 11 2 6 7 8 10 1 11 11 11 11 11           = = = = = ÷  ÷  ÷  ÷  ÷                     = = = = = − ÷  ÷  ÷  ÷  ÷          
  • 34. 4.Quadratic Residues We now present a criterion for deciding whether an integer is a quadratic residue of prime. This criterion is useful in demonstraing propeties of the Legendre symbol. Theorem 4.3. Euler’s Criterion. Let p be an odd prime and let a be positive integer not divisible by p. Then 34 ( 1)/ 2 (mod ).pa a p p −  ≡ ÷  
  • 35. 4.Quadratic Residues Proof. Firt ,assume that .Then , the congruence x2 ≡ a (mod p) has a solution, say x = x0. Using Fermat’s little theorem , we see that Hence,if ,we know that 35 1 a p   = ÷   ( 1)/2 2 ( 1)/2 1 0 0( ) 1(mod )p p p a x x p− − − = = ≡ 1 a p   = ÷   ( 1)/ 2 (mod )pa a p p −  ≡ ÷  
  • 36. 4.Quadratic Residues • Now cosider the case where .Then , the congruence x2 ≡ a (mod p) has no solutions. For each integer i such that 1≤i≤p-1, there is a unique integer j with 1≤j≤p-1, such that ij ≡ a (mod p ). Furthermore , since the congruence x2 ≡ a (mod p) has no solutions, we know that i≠j. Thus, we can group the integer 1, 2,…, p - 1 into (p – 1 )/2 pairs each with product a . Multiplying these pairs together, we find that (p – 1 )! ≡ a (p–1)/2 (mod p).Since Wilson’s theorem tell us that (p – 1 )!≡ - 1 (mod p), we see that – 1 ≡ a (p-1 )/2 (mod p) .In this case, we also have 36 1 a p   = − ÷   ( 1)/ 2 (mod ).pa a p p −  ≡ ÷  
  • 37. 4.Quadratic Residues Theorem 4.4. Let p be an odd prime and a and b integers not divisible by p.Then 37 2 ) (mod ), . ) . ) 1. a b i if a b p then p p a b ab ii p p p a iii p     ≡ = ÷  ÷          = ÷ ÷  ÷        = ÷  
  • 38. 4.Quadratic Residues Proof. i) If a ≡ b (mod p ) then x2 ≡ a (mod p) has s solution if an only if x2 ≡ b (mod p) has solution.Hence . ii) By Euler’s criterion we know that 38 a b p p     = ÷  ÷     ( 1)/ 2 ( 1)/ 2 ( 1)/2 (mod ) , (mod ) ( ) (mod ) p p p a b a p b p p p ab ab p p − − −     ≡ ≡ ÷  ÷       ≡ ÷  
  • 39. 4.Quadratic Residues Hence , Since the only posible values of a Lagendre symbol are ±1, we conclude that 39 ( 1)/ 2 ( 1)/2 ( 1)/2 ( ) (mod )p p pa b ab a b ab p p p p − − −     ≡ = ≡ ÷ ÷  ÷      a b ab p p p      = ÷ ÷  ÷     
  • 40. 4.Quadratic Residues • iii) Since , from part (ii) it folows that 40 1 a p   = ± ÷   2 1 a a a p p p      = = ÷  ÷ ÷    
  • 42. How the Algorithm Works Start with two integers for which you want to find the GCD. Apply the division algorithm, dividing the smaller number into the larger. Example: a = 320, b = 296. 320 = 296 · 1 + 24 The first quotient is q0 and the first remainder is r0.
  • 43. How the Algorithm Works (cont.) If you get a remainder of 0, stop. If not, the divisor from the previous step becomes the dividend of the next step. The remainder from the previous step becomes the divisor of the previous step. 320 = 296 · 1 + 24 296 = 24 · 12 + 8 Continue until you get a remainder of 0.
  • 44. The Completed Algorithm • 320 = 296 · 1 + 24 • 296 = 24 · 12 + 8 • 24 = 8 · 3 + 0 • We get a remainder of 0, so we stop. The last nonzero remainder is the GCD, so (320, 296) is equal to 8.
  • 45. Another Example Compute (346, 592). 592 = 346 · 1 + 246 346 = 246 · 1 + 100 246 = 100 · 2 + 46 100 = 46 · 2 + 8 46 = 8 · 5 + 6 8 = 6 · 1 + 2 6 = 2 · 3 + 0 So (346, 592) = 2.
  • 46. The Euclidean Algorithm and Bézout’s Theorem We can use the Euclidean Algorithm to find the integers U and V from Bézout’s Theorem. As an example, let’s use the Euclidean Algorithm to show that (324, 148) = 4. 324 = 148 · 2 + 28 148 = 28 · 5 + 8 28 = 8 · 3 + 4 8 = 4 · 2 + 0
  • 47. Finding U and V • We want to find integers U and V such that 4 = 324U + 148V. • Take all of the equations (except the last one) and solve for the remainder. • 28 = 324 – 148 · 2 • 8 = 148 – 28 · 5 • 4 = 28 – 8 · 3
  • 48. Back-Substitution • Notice that the last equation expresses 4 as a linear combination of 28 and 8. • 4 = 28 · 1 + 8 · (-3) • This is not what we want, however. So we use the previous equation (which has been solved for 8) to substitute.
  • 49. Back-Substitution (cont.) • 4 = 28 · 1 + (148 – 28 · 5) · (-3) • Now we want to rearrange this so that 4 is expressed as a linear combination of 28 and 148 (still not quite what we want, but getting closer) • We get 4 = 28 · 16 + 148 · (-3)
  • 50. Back-Substitution (cont.) Now use the previous equation (which has been solved for 28) to substitute. We get 4 = (324 – 148 · 2) · 16 + 148 · (-3) Once again, multiply out and rearrange until we get 4 expressed as a linear combination of 324 and 148. 4 = 324 · 16 + 148 · (-35)
  • 51. Another Example • Use the Euclidean Algorithm to show that (15, 36) = 3. • Use back-substitution to find integers U and V so that 3 = 15U + 36V.
  • 53. 53 Introduction to Number Theory •Number theory is about integers and their properties. •We will start with the basic principles of • divisibility, • greatest common divisors, • least common multiples, and • modular arithmetic •and look at some relevant algorithms.
  • 54. 54 Division •If a and b are integers with a ≠ 0, we say that a divides b if there is an integer c so that b = ac. •When a divides b we say that a is a factor of b and that b is a multiple of a. •The notation a | b means that a divides b. •We write a X b when a does not divide b •(see book for correct symbol).
  • 55. 55 Divisibility Theorems •For integers a, b, and c it is true that • if a | b and a | c, then a | (b + c) • Example: 3 | 6 and 3 | 9, so 3 | 15. • if a | b, then a | bc for all integers c • Example: 5 | 10, so 5 | 20, 5 | 30, 5 | 40, … • if a | b and b | c, then a | c • Example: 4 | 8 and 8 | 24, so 4 | 24. •
  • 56. 56 Primes •A positive integer p greater than 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. •The fundamental theorem of arithmetic: •Every positive integer can be written uniquely as the product of primes, where the prime factors are written in order of increasing size.
  • 57. 57 Primes •Examples: 3·53·5 48 =48 = 17 =17 = 100 =100 = 512 =512 = 515 =515 = 28 =28 = 15 =15 = 2·2·2·2·3 = 22·2·2·2·3 = 244 ·3·3 1717 2·2·5·5 = 22·2·5·5 = 222 ·5·522 2·2·2·2·2·2·2·2·2 = 22·2·2·2·2·2·2·2·2 = 299 5·1035·103 2·2·72·2·7
  • 58. 58 Primes •If n is a composite integer, then n has a prime divisor less than or equal . •This is easy to see: if n is a composite integer, it must have two prime divisors p1 and p2 such that p1⋅p2 = n. •p1 and p2 cannot both be greater than • , because then p1⋅p2 > n. n n
  • 59. 59 The Division Algorithm •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 above equation, • d is called the divisor, • a is called the dividend, • q is called the quotient, and • r is called the remainder.
  • 60. 60 The Division Algorithm •Example: •When we divide 17 by 5, we have •17 = 5⋅3 + 2. • 17 is the dividend, • 5 is the divisor, • 3 is called the quotient, and • 2 is called the remainder.
  • 61. 61 The Division Algorithm •Another example: •What happens when we divide -11 by 3 ? •Note that the remainder cannot be negative. •-11 = 3⋅(-4) + 1. • -11 is the dividend, • 3 is the divisor, • -4 is called the quotient, and • 1 is called the remainder.
  • 62. 62 Greatest Common Divisors •Let a and b be integers, not both zero. •The largest integer d such that d | a and d | b is called the greatest common divisor of a and b. •The greatest common divisor of a and b is denoted by gcd(a, b). •Example 1: What is gcd(48, 72) ? •The positive common divisors of 48 and 72 are 1, 2, 3, 4, 6, 8, 12, 16, and 24, so gcd(48, 72) = 24. •Example 2: What is gcd(19, 72) ? •The only positive common divisor of 19 and 72 is 1, so gcd(19, 72) = 1.
  • 63. 63 Greatest Common Divisors •Using prime factorizations: •a = p1 a 1 p2 a 2 … pn a n , b = p1 b 1 p2 b 2 … pn b n , •where p1 < p2 < … < pn and ai, bi ∈ N for 1 ≤ i ≤ n •gcd(a, b) = p1 min(a 1 ,b 1 ) p2 min(a 2 ,b 2 ) … pn min(a n ,b n ) •Example: a = 60 =a = 60 = 2222 3311 5511 b = 54 =b = 54 = 2211 3333 5500 gcd(a, b) =gcd(a, b) = 2211 3311 5500 = 6= 6
  • 64. 64 Relatively Prime Integers •Definition: •Two integers a and b are relatively prime if gcd(a, b) = 1. •Examples: •Are 15 and 28 relatively prime? •Yes, gcd(15, 28) = 1. •Are 55 and 28 relatively prime? •Yes, gcd(55, 28) = 1. •Are 35 and 28 relatively prime? •No, gcd(35, 28) = 7.
  • 65. Fall 2002 CMSC 203 - Discrete Structures 65 Relatively Prime Integers •Definition: •The integers a1, a2, …, an are pairwise relatively prime if gcd(ai, aj) = 1 whenever 1 ≤ i < j ≤ n. •Examples: •Are 15, 17, and 27 pairwise relatively prime? •No, because gcd(15, 27) = 3. •Are 15, 17, and 28 pairwise relatively prime? •Yes, because gcd(15, 17) = 1, gcd(15, 28) = 1 and gcd(17, 28) = 1.
  • 66. Fall 2002 CMSC 203 - Discrete Structures 66 Least Common Multiples •Definition: •The least common multiple of the positive integers a and b is the smallest positive integer that is divisible by both a and b. •We denote the least common multiple of a and b by lcm(a, b). •Examples: lcm(3, 7) =lcm(3, 7) = 2121 lcm(4, 6) =lcm(4, 6) = 1212 lcm(5, 10) =lcm(5, 10) = 1010
  • 67. Fall 2002 CMSC 203 - Discrete Structures 67 Least Common Multiples •Using prime factorizations: •a = p1 a 1 p2 a 2 … pn a n , b = p1 b 1 p2 b 2 … pn b n , •where p1 < p2 < … < pn and ai, bi ∈ N for 1 ≤ i ≤ n •lcm(a, b) = p1 max(a 1 ,b 1 ) p2 max(a 2 ,b 2 ) … pn max(a n ,b n ) •Example: a = 60 =a = 60 = 2222 3311 5511 b = 54 =b = 54 = 2211 3333 5500 lcm(a, b) =lcm(a, b) = 2222 3333 5511 = 4275 = 540= 4275 = 540
  • 68. Fall 2002 CMSC 203 - Discrete Structures 68 GCD and LCM a = 60 =a = 60 = 2222 3311 5511 b = 54 =b = 54 = 2211 3333 5500 lcm(a, b) =lcm(a, b) = 2222 3333 5511 = 540= 540 gcd(a, b) =gcd(a, b) = 2211 3311 5500 = 6= 6 Theorem: ab =Theorem: ab = gcd(a,b)lcm(a,b)gcd(a,b)lcm(a,b)
  • 69. Fall 2002 CMSC 203 - Discrete Structures 69 Modular Arithmetic •Let a be an integer and m be a positive integer. We denote by a mod m the remainder when a is divided by m. •Examples: 9 mod 4 =9 mod 4 = 11 9 mod 3 =9 mod 3 = 00 9 mod 10 =9 mod 10 = 99 -13 mod 4 =-13 mod 4 = 33
  • 70. Fall 2002 CMSC 203 - Discrete Structures 70 Congruences •Let a and b be integers and m be a positive integer. We say that a is congruent to b modulo m if m divides a – b. •We use the notation a ≡ b (mod m) to indicate that a is congruent to b modulo m. •In other words: a ≡ b (mod m) if and only if a mod m = b mod m.
  • 71. Fall 2002 CMSC 203 - Discrete Structures 71 Congruences •Examples: •Is it true that 46 ≡ 68 (mod 11) ? •Yes, because 11 | (46 – 68). •Is it true that 46 ≡ 68 (mod 22)? •Yes, because 22 | (46 – 68). •For which integers z is it true that z ≡ 12 (mod 10)? •It is true for any z∈{…,-28, -18, -8, 2, 12, 22, 32, …} •Theorem: Let m be a positive integer. The integers a and b are congruent modulo m if and only if there is an integer k such that a = b + km.
  • 72. Fall 2002 CMSC 203 - Discrete Structures 72 Congruences •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). •Proof: •We know that a ≡ b (mod m) and c ≡ d (mod m) implies that there are integers s and t with b = a + sm and d = c + tm. •Therefore, •b + d = (a + sm) + (c + tm) = (a + c) + m(s + t) and •bd = (a + sm)(c + tm) = ac + m(at + cs + stm). •Hence, a + c ≡ b + d (mod m) and ac ≡ bd (mod m).
  • 73. Fall 2002 CMSC 203 - Discrete Structures 73 The Euclidean Algorithm •The Euclidean Algorithm finds the greatest common divisor of two integers a and b. •For example, if we want to find gcd(287, 91), we divide 287 by 91: •287 = 91⋅3 + 14 •We know that for integers a, b and c, if a | b and a | c, then a | (b + c). •Therefore, any divisor of 287 and 91 must also be a divisor of 287 - 91⋅3 = 14. •Consequently, gcd(287, 91) = gcd(14, 91).
  • 74. Fall 2002 CMSC 203 - Discrete Structures 74 The Euclidean Algorithm •In the next step, we divide 91 by 14: •91 = 14⋅6 + 7 •This means that gcd(14, 91) = gcd(14, 7). •So we divide 14 by 7: •14 = 7⋅2 + 0 •We find that 7 | 14, and thus gcd(14, 7) = 7. •Therefore, gcd(287, 91) = 7.
  • 75. 75 The Euclidean Algorithm •In pseudocode, the algorithm can be implemented as follows: •procedure gcd(a, b: positive integers) •x := a •y := b •while y ≠ 0 •begin • r := x mod y • x := y • y := r •end {x is gcd(a, b)}
  • 76. 76 Representations of Integers •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, •and ak ≠ 0. •Example for b=10: •859 = 8⋅102 + 5⋅101 + 9⋅100
  • 77. 77 Representations of Integers •Example for b=2 (binary expansion): •(10110)2 = 1⋅24 + 1⋅22 + 1⋅21 = (22)10 •Example for b=16 (hexadecimal expansion): •(we use letters A to F to indicate numbers 10 to 15) •(3A0F)16 = 3⋅163 + 10⋅162 + 15⋅160 = (14863)10 •
  • 78. 78 Representations of Integers •How can we construct the base b expansion of an integer n? •First, divide n by b to obtain a quotient q0 and remainder a0, that is, •n = bq0 + a0, where 0 ≤ a0 < b. •The remainder a0 is the rightmost digit in the base b expansion of n. •Next, divide q0 by b to obtain: •q0 = bq1 + a1, where 0 ≤ a1 < b. •a1 is the second digit from the right in the base b expansion of n. Continue this process until you obtain a quotient equal to zero.
  • 79. 79 Representations of Integers •Example: What is the base 8 expansion of (12345)10 ? •First, divide 12345 by 8: •12345 = 8⋅1543 + 1 •1543 = 8⋅192 + 7 •192 = 8⋅24 + 0 •24 = 8⋅3 + 0 •3 = 8⋅0 + 3 •The result is: (12345)10 = (30071)8.
  • 80. 80 Representations of Integers •procedure base_b_expansion(n, b: positive integers) •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 … a1a0)b}
  • 81. 81 Addition of Integers •Let a = (an-1an-2…a1a0)2, b = (bn-1bn-2…b1b0)2. •How can we add these two binary numbers? •First, add their rightmost bits: •a0 + b0 = c0⋅2 + s0, •where s0 is the rightmost bit in the binary expansion of a + b, and c0 is the carry. •Then, add the next pair of bits and the carry: •a1 + b1+ c0 = c1⋅2 + s1, •where s1 is the next bit in the binary expansion of a + b, and c1 is the carry.
  • 82. 82 Addition of Integers •Continue this process until you obtain cn-1. •The leading bit of the sum is sn = cn-1. •The result is: •a + b = (snsn-1…s1s0)2
  • 83. 83 Addition of Integers •Example: •Add a = (1110)2 and b = (1011)2. •a0 + b0 = 0 + 1 = 0⋅2 + 1, so that c0 = 0 and s0 = 1. •a1 + b1+ c0 = 1 + 1 + 0 = 1⋅2 + 0, so c1 = 1 and s1 = 0. •a2 + b2+ c1 = 1 + 0 + 1 = 1⋅2 + 0, so c2 = 1 and s2 = 0. •a3 + b3+ c2 = 1 + 1 + 1 = 1⋅2 + 1, so c3 = 1 and s3 = 1. •s4 = c3 = 1. •Therefore, s = a + b = (11001)2.
  • 84. 84 Addition of Integers •How do we (humans) add two integers? •Example: 7583 + 4932 5511552211 111111 carrycarry Binary expansions:Binary expansions: (1011)(1011)22 ++ (1010)(1010)22 1100 carrycarry11 1100 11 11(( ))22
  • 85. 85 Addition of Integers •Let a = (an-1an-2…a1a0)2, b = (bn-1bn-2…b1b0)2. •How can we algorithmically add these two binary numbers? •First, add their rightmost bits: •a0 + b0 = c0⋅2 + s0, •where s0 is the rightmost bit in the binary expansion of a + b, and c0 is the carry. •Then, add the next pair of bits and the carry: •a1 + b1+ c0 = c1⋅2 + s1, •where s1 is the next bit in the binary expansion of a + b, and c1 is the carry.
  • 86. 86 Addition of Integers •Continue this process until you obtain cn-1. •The leading bit of the sum is sn = cn-1. •The result is: •a + b = (snsn-1…s1s0)2
  • 87. 87 Addition of Integers •Example: •Add a = (1110)2 and b = (1011)2. •a0 + b0 = 0 + 1 = 0⋅2 + 1, so that c0 = 0 and s0 = 1. •a1 + b1+ c0 = 1 + 1 + 0 = 1⋅2 + 0, so c1 = 1 and s1 = 0. •a2 + b2+ c1 = 1 + 0 + 1 = 1⋅2 + 0, so c2 = 1 and s2 = 0. •a3 + b3+ c2 = 1 + 1 + 1 = 1⋅2 + 1, so c3 = 1 and s3 = 1. •s4 = c3 = 1. •Therefore, s = a + b = (11001)2.
  • 88. 88 Addition of Integers •procedure add(a, b: positive integers) •c := 0 •for j := 0 to n-1 •begin • d := (aj + bj + c)/2 • sj := aj + bj + c – 2d • c := d •end •sn := c •{the binary expansion of the sum is (snsn-1…s1s0)2}
  • 90. 90 Mathematical Induction: ExampleMathematical Induction: Example Show that any postage of ≥ 8¢ can be obtained using 3¢ and 5¢ stamps. First check for a few particular values: 8¢ = 3¢ + 5¢ 9¢ = 3¢ + 3¢ + 3¢ 10¢ = 5¢ + 5¢ 11¢ = 5¢ + 3¢ + 3¢ 12¢ = 3¢ + 3¢ + 3¢ + 3¢ How to generalize this?
  • 91. 91 Mathematical Induction: ExampleMathematical Induction: Example • Let P(n) be the sentence “n cents postage can be obtained using 3¢ and 5¢ stamps”. • Want to show that “P(k) is true” implies “P(k+1) is true” for any k ≥ 8¢. • 2 cases: 1) P(k) is true and the k cents contain at least one 5¢. 2) P(k) is true and the k cents do not contain any 5¢.
  • 92. 92 Mathematical Induction: ExampleMathematical Induction: Example • Case 1: k cents contain at least one 5¢ coin. • Case 2: k cents do not contain any 5¢ coin. Then there are at least three 3¢ coins. 5¢ 3¢ 3¢ Replace 5¢ coin by two 3¢ coinsk cents k+1 cents 3¢ 3¢ 3¢ 5¢ 5¢ Replace three 3¢ coins by two 5¢ coins k cents k+1 cents
  • 93. 93 Domino EffectDomino Effect • Mathematical induction works like domino effect: • Let P(n) be “The nth domino falls backward”. • If (a) “P(1) is true”; (b) “P(k) is true” implies “P(k+1) is true” Then P(n) is true for every n
  • 94. 94 Principle of MathematicalPrinciple of Mathematical InductionInduction Let P(n) be a predicate defined for integers n. Suppose the following statements are true: 1. Basis step: P(a) is true for some fixed a∈Z . 2. Inductive step: For all integers k ≥ a, if P(k) is true then P(k+1) is true. Then for all integers n ≥ a, P(n) is true.
  • 95. 95 Example: Sum of Odd IntegersExample: Sum of Odd Integers  Proposition: 1 + 3 + … + (2n-1) = n2 for all integers n≥1.  Proof (by induction): 1) Basis step: The statement is true for n=1: 1=12 . 2) Inductive step: Assume the statement is true for some k≥1 (inductive hypothesis) , show that it is true for k+1 .
  • 96. Example: Sum of Odd IntegersExample: Sum of Odd Integers  Proof (cont.): The statement is true for k: 1+3+…+(2k-1) = k2 (1) We need to show it for k+1: 1+3+…+(2(k+1)-1) = (k+1)2 (2) Showing (2): 1+3+…+(2(k+1)-1) = 1+3+…+(2k+1) = 1+3+…+(2k-1)+(2k+1) = k2 +(2k+1) = (k+1)2 . We proved the basis and inductive steps, so we conclude that the given statement true. ■ by (1)
  • 97. 97 Important theorems proved byImportant theorems proved by mathematical inductionmathematical induction  Theorem 1 (Sum of the first n integers): For all integers n≥1,  Theorem 2 (Sum of a geometric sequence): For any real number r except 1, and any integer n≥0, 2 )1( ...21 + =+++ nn n 1 11 0 − − = + = ∑ r r r nn i i
  • 98. 98 Example (of sum of the first n integers) In a round-robin tournament each of the n teams plays every other team exactly once. What is the total number of games played? Solution on the board.
  • 99. 99 Proving a divisibility property byProving a divisibility property by mathematical inductionmathematical induction • Proposition: For any integer n≥1, 7n - 2n is divisible by 5. (P(n)) • Proof (by induction): 1) Basis step: The statement is true for n=1: (P(1)) 71 – 21 = 7 - 2 = 5 is divisible by 5. 2) Inductive step: Assume the statement is true for some k≥1 (P(k)) (inductive hypothesis) ; show that it is true for k+1 . (P(k+1))
  • 100. 100 Proving a divisibility property byProving a divisibility property by mathematical inductionmathematical induction Proof (cont.): We are given that P(k): 7k - 2k is divisible by 5. (1) Then 7k - 2k = 5a for some a∈Z . (by definition) (2) We need to show: P(k+1): 7k+1 - 2k+1 is divisible by 5. (3) 7k+1 - 2k+1 = 7·7k - 2·2k = 5·7k + 2·7k - 2·2k = 5·7k + 2·(7k - 2k ) = 5·7k + 2·5a (by (2)) = 5·(7k + 2a) which is divisible by 5. (by def.) Thus, P(n) is true by induction. ■