You are on page 1of 37

# Let us get into«

Number Theory

c  
  
ntroduction to Number Theory

## Number theory is about   and their

properties.

 divisibility,
 greatest common divisors,
 least common multiples, and
 modular arithmetic

## and look at some relevant algorithms.

c  
  
ivision
f a and b are integers with a  |, we say that
a ëë b if there is an integer c so that b = ac.

## When a divides b we say that a is a  

 of b
and that b is a   of a.

## We write  when a does not divide b

(see book for correct symbol).

c  
  
ivisibility Theorems
For integers a, b, and c it is true that

 if a | b and a | c, then a | (b + c)
º    V | 6 and V | 9, so V | 15.

##  if a | b, then a | bc for all integers c

º    5 | 1|, so 5 | 2|, 5 | V|, 5 | 4|, «

 if a | b and b | c, then a | c
º    4 | 8 and 8 | 24, so 4 | 24.

c  
  
[rimes
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    as
the 
ë 
 

ë 
 ,, where the prime factors
are written in order of increasing size.

c  
  
[rimes
Examples:
15 = V5
48 = 2 2 2 2 V = 24 V
17 = 17
1|| = 2 2 5 5 = 22 52
512 = 2 2 2 2 2 2 2 2 2 = 29
515 = 5 1|V
28 = 227
c  
  
[rimes

## f 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.

c  
  
The ivision Algorithm
Let  be an integer and ë a positive integer.
Then there are unique integers  and , with
 ë
 ë,, such that ë
ë..

## n the above equation,

 ë is called the divisor,
  is called the dividend,
  is called the quotient, and
  is called the remainder.

c  
  
The ivision Algorithm
º   

## When we divide 17 by 5, we have

5åV + 2.
17 = 5å

 17 is the dividend,
 5 is the divisor,
 V is called the quotient, and
 2 is called the remainder.

c  
  
The ivision Algorithm
r
   
What happens when we divide -11 by V ?
Note that the remainder cannot be negative.
Vå(-4) + 1.
-11 = Vå

##  -11 is the dividend,

 V is the divisor,
 -4 is called the quotient, and
 1 is called the remainder.

c  
  
Xreatest Common ivisors
Let a and b be integers, not both zero.
The largest integer d such that d | a and d | b is
called the 

ë
 of a and b.
The greatest common divisor of a and b is denoted
by gcd(a, b).
º    What is gcd(48, 72) ?
The positive common divisors of 48 and 72 are
1, 2, V, 4, 6, 8, 12, 16, and 24, so gcd(48, 72) = 24.
º    What is gcd(19, 72) ?
The only positive common divisor of 19 and 72 is
1, so gcd(19, 72) = 1.
c  
  
Xreatest Common ivisors
o   


a = p1a1 p2a2 « pnan , b = p1b1 p2b2 « pnbn ,
where p1 < p2 < « < pn and ai, bi  i for 1  i  n

## gcd(a, b) = p1min(a1, b1 ) p2min(a2, b2 ) « pnmin(an, bn )

º   
a = 6| = 22 V1 51
b = 54 = 21 VV 5|
gcd(a, b) = 21 V1 5| = 6
c  
  
Velatively [rime ntegers
 

Two integers a and b are     if
gcd(a, b) = 1.

º   
Are 15 and 28 relatively prime?
Yes, gcd(15, 28) = 1.
Are 55 and 28 relatively prime?
Yes, gcd(55, 28) = 1.
Are V5 and 28 relatively prime?
No, gcd(V5, 28) = 7.
c  
  
Velatively [rime ntegers
 

The integers a1, a2, «, an are   
  if gcd(ai, aj) = 1 whenever 1  i < j  n.

º   
Are 15, 17, and 27 pairwise relatively prime?
No, because gcd(15, 27) = V.
Are 15, 17, and 28 pairwise relatively prime?
Yes, because gcd(15, 17) = 1, gcd(15, 28) = 1 and
gcd(17, 28) = 1.
c  
  
Least Common Multiples
 

The 

   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).
º   
lcm(V, 7) = 21
lcm(4, 6) = 12
lcm(5, 1|) = 1|
c  
  
Least Common Multiples
o   


a = p1a1 p2a2 « pnan , b = p1b1 p2b2 « pnbn ,
where p1 < p2 < « < pn and ai, bi  i for 1  i  n

## lcm(a, b) = p1max(a1, b1 ) p2max(a2, b2 ) « pnmax(an, bn )

º   
a = 6| = 22 V1 51
b = 54 = 21 VV 5|
4å27
lcm(a, b) = 22 VV 51 = 4å 27åå5 = 54|
c  
  
XC and LCM

a = 6| = 22 V1 51

b = 54 = 21 VV 5|

gcd(a, b) = 21 V1 5| =6

lcm(a, b) = 22 VV 51 = 54|

!
 åå  ë å 
!
 

c  
  
Modular Arithmetic
Let a be an integer and m be a positive integer.
We denote by 
ë the remainder when a is
divided by m.

º   

9 mod 4 = 1
9 mod V = |
9 mod 1| = 9
-1V mod 4 = V

c  
  
Congruences
Let a and b be integers and m be a positive integer.
We say that 
  

ë
 if
m divides a ² b.

## We use the notation 

00 
ë to indicate
that a is congruent to b modulo m.

n other words:
a 0 b (mod m) if and only if 
ë 
ë .

ë 
ë .

c  
  
Congruences
º   
s it true that 46 0 68 (mod 11) ?
Yes, because 11 | (46 ² 68).
s it true that 46 0 68 (mod 22)?
Yes, because 22 | (46 ² 68).
For which integers z is it true that z 0 12 (mod 1|)?
z{«,
t is true for any z {«,--28, -18, -8, 2, 12, 22, V2, «}

!
  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.

c  
  
Congruences
!
  Let m be a positive integer.
f a 0 b (mod m) and c 0 d (mod m), then
a + c 0 b + d (mod m) and ac 0 bd (mod m).
[


We know that a 0 b (mod m) and c 0 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 0 b + d (mod m) and ac 0 bd (mod m).

c  
  
The Euclidean Algorithm
The º ë r 
 finds the 

ë
 of two integers a and b.
For example, if we want to find gcd(287, 91), we
ëë 287 by 91:
91åV + 14
287 = 91å
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 - 9191ååV = 14.
Consequently, gcd(287, 91) = gcd(14, 91).

c  
  
The Euclidean Algorithm
n the next step, we divide 91 by 14:
14å6 + 7
91 = 14å
This means that gcd(14, 91) = gcd(14, 7).

So we divide 14 by 7:
7å 2 + |
14 = 7å
We find that 7 | 14, and thus gcd(14, 7) = 7.

!
 ë!"# "\$
c  
  
The Euclidean Algorithm
n  ë

ë
 ë

ë,, the algorithm can be implemented
as follows:


ë  gcd(a, b: positive integers)
x := a
y := b
  y  |

r := x
ë y
x := y
y := r
 ë {x is gcd(a, b)}

c  
  
Vepresentations of ntegers
Let b be a positive integer greater than 1.
Then if n is a positive integer, it can be expressed
   in the form:

## where k is a nonnegative integer,

a|, a1, «, ak are nonnegative integers less than b,
and ak  |.

º   

8å1|2 + 5å
859 = 8å 5å1|1 + 9å
9å1||
c  
  
Vepresentations of ntegers

º   
   

1å24 + 1å
(1|11|)2 = 1å 1å22 + 1å
1å21 = (22)1|

º   
% ë     

(we use letters A to F to indicate numbers 1| to 15)
Vå16V + 1|å
(VA|F)16 = Vå 1|å162 + 15å
15å16| = (1486V)1|

c  
  
Vepresentations of ntegers
How can we construct the base b expansion of an
integer n?
First, divide n by b to obtain a quotient q| and
remainder a|, that is,
n = bq| + a|, where |  a| < b.
The remainder a| is the rightmost digit in the base
b expansion of n.
Next, divide q| by b to obtain:
q| = bq1 + a1, where |  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.
c  
  
Vepresentations of ntegers
º   
What is the base 8 expansion of (12V45)1| ?

## First, divide 12V45 by 8:

8å154V + 1
12V45 = 8å
8å192 + 7
154V = 8å
8å24 + |
192 = 8å
8å V + |
24 = 8å
8å| + V
V = 8å
The result is: (12V45)1| = (V||71)8.
c  
  
Vepresentations of ntegers

ë base_b_expansion(n, b: positive integers)

ë base_b_expansion(n,
q := n
k := |
  q  |

ak := q mod b
q := q/b
k := k + 1
 ë
{the base b expansion of n is (ak-1 « a1a|)b }

c  
  
Let a = (an-1an-2«a1a|)2, b = (bn-1bn-2«b1b|)2.
How can we add these two binary numbers?
a| + b| = c|å2 + s|,
where s| is the 
 in the binary
expansion of a + b, and c| is the 
..
Then, add the next pair of bits and the carry:
a1 + b1 + c| = c1å2 + s1,
where s1 is the   in the binary expansion of
a + b, and c1 is the carry.
c  
  

## The result is:

a + b = (snsn-1«s1s|)2

c  
  
º   
Add a = (111|)2 and b = (1|11)2.

## |åå2 + 1, so that c| = | and s| = 1.

a| + b| = | + 1 = |
1å2 + |, so c1 = 1 and s1 = |.
a1 + b1 + c| = 1 + 1 + | = 1å
1å2 + |, so c2 = 1 and s2 = |.
a2 + b2 + c1 = 1 + | + 1 = 1å
1å2 + 1, so cV = 1 and sV = 1.
aV + bV + c2 = 1 + 1 + 1 = 1å
s4 = cV = 1.

Therefore, s = a + b = (11||1)2.

c  
  
How do we (humans) add two integers?

1 11 carry
Example: 758V
+ 49V2
1 25 1 5
1 1 carry
Binary expansions: (1|11)2
+ (1|1|)2
(1|1 |1 )2

c  
  
Let a = (an-1an-2«a1a|)2, b = (bn-1bn-2«b1b|)2.
How can we  
   
 
numbers?
a| + b| = c|å2 + s|,
where s| is the 
 in the binary
expansion of a + b, and c| is the 
..
Then, add the next pair of bits and the carry:
a1 + b1 + c| = c1å2 + s1,
where s1 is the   in the binary expansion of
a + b, and c1 is the carry.
c  
  

## The result is:

a + b = (snsn-1«s1s|)2

c  
  
º   
Add a = (111|)2 and b = (1|11)2.

## |åå2 + 1, so that c| = | and s| = 1.

a| + b| = | + 1 = |
1å2 + |, so c1 = 1 and s1 = |.
a1 + b1 + c| = 1 + 1 + | = 1å
1å2 + |, so c2 = 1 and s2 = |.
a2 + b2 + c1 = 1 + | + 1 = 1å
1å2 + 1, so cV = 1 and sV = 1.
aV + bV + c2 = 1 + 1 + 1 = 1å
s4 = cV = 1.

Therefore, s = a + b = (11||1)2.

c  
  


c := |
for j := | to n-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«s1s|)2}

c  
  