You are on page 1of 81

Number Theory

1
Plan
• Integer
• Divisor
• Euclidean theorem
• Greatest common divisor
• Relatively prime
• Modular arithmetic
• Modulo inverse
• Chinese remainder problem
• Prime number

2
Integer

3
Integer
• Integer is a number which haven’t decimal place.
E.g: 12, 7, 5678, -52, 0

• Conversely, Real number is a number which have


decimal place, like 8.0, 34.25, 0.02.

• Usually set of integer denote by Z.


Z+ positive integer
Z- negative integer
4
Divisor

5
Divisors
DEF: Let a, b and c be integers such that
a = b ·c .
Then b and c are said to divide (or are factors) of a,
while a is said to be a multiple of b (as well as of
c). The pipe symbol “|” denotes “divides” so the
situation is summarized by:
b|a c|a.
NOTE: Students find notation confusing, and think
of “|” in the reverse fashion, perhaps confuse
pipe with forward slash “/”

6
Divisors.
Examples
Qst: Which of the following is true?
1. 77 | 7
2. 7 | 77
3. 24 | 24
4. 0 | 24
5. 24 | 0

7
Divisors.
Examples
Ans:
1. 77 | 7: false, bigger number can’t divide
smaller positive number
2. 7 | 77: true, because 77 = 7 · 11
3. 24 | 24: true, because 24 = 24 · 1
4. 0 | 24: false, only 0 is divisible by 0
5. 24 | 0: true, 0 is divisible by every number (0
= 24 · 0)

8
Formula for Number of Multiples up to
given n
Q: How many positive multiples of 15 are less
than 100?

9
Formula for Number of Multiples up to
given n
A: Just list them:
15, 30, 45, 60, 75, 80, 95.
Therefore the answer is 6.

Q: How many positive multiples of 15 are less


than 1,000,000?

10
Formula for Number of Multiples up to
Given n
A: Listing is too much of a hassle. Since 1 out of 15
numbers is a multiple of 15, if 1,000,000 were
were divisible by 15, answer would be exactly
1,000,000/15. However, since 1,000,000 isn’t
divisible by 15, need to round down to the
highest multiple of 15 less than 1,000,000 so
answer is 1,000,000/15.
In general: The number of d-multiples less than N
is given by:
|{m  Z+ | d |m and m  N }| = N/d

11
Divisor Theorem
Let a, b, and c be integers. Then:
1. a|b  a|c  a|(b + c )
2. a|b  a|bc
3. a|b  b|c  a|c
Eg:
1. 17|34  17|170  17|204
2. 17|34  17|340
3. 6|12  12|144  6 | 144

12
Division
Remember long division?
q the quotient

n the divisor 3
31 117
m the dividend
93 r the remainder
24
117 = 31·3 + 24
m = nq + r

13
Euclidean Theorem

14
Euclidean Theorem
Suppose m and n are integer, n > 0. If m
divided by n, there is unique integer q
(quotient) and r (remainder), such that
m = nq + r
where 0  r < n.

15
eg.
(i) 1987/97 = 20, remainder 47:
1987 = 97  20 + 47

(ii) –22/3 = –8, remainder 2:


–22 = 3(–8) + 2

but –22 = 3(–7) – 1 is false, because


r = –1 (remember requirement 0  r < n)
16
Greatest Common Divisor

17
Greatest Common Divisor

• Suppose a and b are non zero integer.


greatest common divisor (gcd) of a and
b are the greatest integer d such that
d | a and d | b.

• In this case gcd(a, b) = d.

18
• eg.
divisors 45: 1, 3, 5, 9, 15, 45;
divisors 36: 1, 2, 3, 4, 9, 12, 18, 36;
common divisors 45 and 36: 1, 3, 9

 gcd(45, 36) = 9.

19
Theorem
• Suppose m and n are integer, where n > 0
such that
m = nq + r , 0  r < n
then gcd(m, n) = gcd(n, r)

• eg: m = 60, n = 18,


60 = 18  3 + 12
gcd(60, 18) = gcd(18, 12) = 6
20
Euclidean Algorithm

• purpose: the algorithm is to


find gcd between two
integers.

• Euclides, who propose the


algorithm, is a mathematician
from Greek. He is write the
algorithm on his book Element.
21
Euclidean Algorithm
1. if n = 0, then m is gcd(m, n);
stop.
but if n  0, go to step 2.
2. Divide m by n , and suppose the remainder
is r .
3. Replace m by n, and replace n by r,
4. Repeat to step 1.

22
procedure Euclidean(input m, n : integer,
output gcd : integer)
{ find gcd(m, n) where m and n are non-negative integer,
and m  n
input: m and n, m  n and m, n  0
output: PBB(m, n)
}

r : integer

while n  0 do
r  m mod n
m  n
n  r
endwhile
{ n = 0, then gcd(m,n) = m }
gcd  m

23
eg. m = 80, n = 12 (Observe m  n)
80  6 12  8

12  1 8  4

8  24  0
The last remainder before 0 is 4, gcd(80, 12) = 4.

24
Linear Combination
• gcd(a,b) can be expressed as linear
combination of a and b as a coefficient.

• eg: gcd(80, 12) = 4 ,


4 = (-1)  80 + 7  12.

• Theorem. suppose a and b are positive


integer, there are exist integer m and n
such that gcd(a, b) = ma + nb.

25
• eg: express gcd(21, 45) as linear combination
of 21 and 45.
• Solution:
45 = 2 (21) + 3
21 = 7 (3) + 0
the last remainder before 0 is 3, then
gcd(45, 21) = 3
so,
3 = 1 (45) – 2 (21)
thus 3 is linear combination of 45 and 21.

26
eg: express gcd(312, 70) as linear combination of 312
and 70.
Solution: apply Euclidean algorithm to get gcd(312, 70):
312 = 4  70 + 32 (i)
70 = 2  32 + 6 (ii)
32 = 5  6 + 2 (iii)
6=32+0 (iv)
The last remainder before 0 is 2, then gcd(312, 70) = 2

Thus, gcd(312, 70) = 2 = 11 (312) – 49 (70)

27
Relatively Prime

28
Relatively Prime
• Two integers a and b are relatively
prime if gcd(a, b) = 1.
• eg.
(i) 20 and 3 are relatively prime, because
gcd(20, 3) = 1.
(ii) 7 and 11 are relatively prime, because
gcd(7, 11) = 1.
(iii) 20 and 5 are not relatively prime, because
gcd(20, 5) = 5  1.

29
• If a and b are relatively prime, there are
exist integer m and n such that
ma + nb = 1

30
• eg. Integer 20 and 3 are relatively prime,
because gcd(20, 3) =1, or it can be
written as
(2). 20 + (–13) . 3 = 1 (m = 2, n = –13)

but, 20 and 5 are not relatively prime, because


gcd(20, 5) = 5  1, hence 20 and 5 can’t
expressed as m . 20 + n . 5 = 1.

31
Modular Arithmetic

32
Modular Arithmetic
• Suppose a and m are integer (m > 0).
Operation
a mod m (read “a modulo m”)
gives remainder if a divided by m.

• Notation: a mod m = r such that


a = mq + r, with 0  r < m.

• m called modulus or modulo, the result of


modular arithmetic m is on the set {0, 1, 2, …,
m – 1}. 33
• eg.
(i) 23 mod 5 = 3 (23 = 5  4 + 3)
(ii) 27 mod 3 = 0 (27 = 3  9 + 0)
(iii) 6 mod 8 = 6 (6 = 8  0 + 6)
(iv) 0 mod 12 = 0 (0 = 12  0 + 0)
(v) – 41 mod 9 = 4 (–41 = 9 (–5) + 4)
(vi) – 39 mod 13 = 0 (–39 = 13(–3) + 0)

• Hint (v): Because a negative, divide |a| by m


gives remainder r’. Thus, a mod m = m – r’ if r’ 
0.
• So, |– 41| mod 9 = 5, then –41 mod 9 = 9 – 5 = 4.

34
Congruence

35
Congruence
• Observe 38 mod 5 = 3 and 13 mod 5 = 3,
then 38  13 (mod 5)
(read: 38 is congruence with 13 in modulo 5).

• Suppose a and b are integer and integer


m > 0, then a  b (mod m) if m is
divisors of a – b.

• If a is not congruence b in modulus m, denote


by a ≢ b (mod m) .
36
• eg.
17  2 (mod 3) ( 3 is divisor 17 – 2 = 15)

–7  15 (mod 11)
(11 is divisors –7 – 15 = –22)

12 ≢ 2 (mod 7)
(7 is not divisor 12 – 2 = 10 )

–7 ≢ 15 (mod 3)
(3 is not divisor –7 – 15 = –22)

37
The other way…
• a  b (mod m) can be written as “equation”
a = b + km (k is integer)

• eg.
17  2 (mod 3)  17 = 2 + (5) (3)
–7  15 (mod 11)  –7 = 15 + (–2) (11)

38
• a mod m = r can be written as
a  r (mod m)

• eg.
(i) 23 mod 5 = 3  23  3 (mod 5)
(ii) 27 mod 3 = 0  27  0 (mod 3)
(iii) 6 mod 8 = 6  6  6 (mod 8)
(iv) 0 mod 12 = 0  0  0 (mod 12)
(v) – 41 mod 9 = 4  –41  4 (mod 9)
(vi) – 39 mod 13 = 0  – 39  0 (mod 13)

39
Theorem
Suppose m is positive integer.
1) if a  b (mod m) and c is integer
(i) (a + c)  (b + c) (mod m)
(ii) ac  bc (mod m)
(iii) ap  bp (mod m) , p is non-negative integer

2) If a  b (mod m) and c  d (mod m), then


(i) (a + c)  (b + d) (mod m)
(ii) ac  bd (mod m)

40
Proof (for 1(ii) and 2(i) ):
1(ii) a  b (mod m) berarti:
 a = b + km
 a – b = km
 (a – b)c = ckm
 ac = bc + Km
 ac  bc (mod m) 

2(i) a  b (mod m)  a = b + k1m


c  d (mod m)  c = d + k2m +
 (a + c) = (b + d) + (k1 + k2)m
 (a + c) = (b + d) + km ( k = k1 + k2)
 (a + c) = (b + d) (mod m) 

41
eg.
Suppose 17  2 (mod 3) and 10  4 (mod 3), then
17 + 5 = 2 + 5 (mod 3)  22 = 7 (mod 3)
17 . 5 = 5  2 (mod 3)  85 = 10 (mod 3)
17 + 10 = 2 + 4 (mod 3)  27 = 6 (mod 3)
17 . 10 = 2  4 (mod 3)  170 = 8 (mod 3)

42
practice
if a  b (mod m) and c  d (mod m) prove that
ac  bd (mod m)

43
Solution
a  b (mod m)  a = b + k1m
c  d (mod m)  c = d + k2m
then
 ac = (b + k1m)(d + k2m)
 ac = bd + bk2m + dk1m + k1k2m2
 ac = bd + Km where K = bk2 + dk1 + k1k2m
 ac  bd (mod m) .

44
Modulo Inverse

45
Modulo Inverse
• On number operation, multiplication inverse is
division

• eg: inverse 4 is 1/4, because 4  1/4 = 1.

• Inverse on modulo arithmetic is more difficult.

46
• If a and m are relatively prime and m > 1,
then inverse of a modulo m is exist.

• Inverse of a modulo m is integer x such that


xa  1 (mod m)
• On the other notation, a–1(mod m) = x

47
proof: a and m relatively prime, thus gcd(a, m) = 1,
there are exist integer x and y such that

xa + ym = 1

xa + ym  1 (mod m)

because ym  0 (mod m), then

xa  1 (mod m)

from the last congruence, it is show that x is inverse


of a modulo m. 
48
• Fro m the above discussion, it is clear that
to find inverse of a modulo m, we must
make linear combination of a and m equal
1. (observe: xa + ym = 1).

• The coefficient of a from those linear


combination is inverse of a modulo m.

49
Example:
Find inverse of 4 (mod 9),
Solution:
Because gcd(4, 9) = 1, inverse 4 (mod 9) is exist.
Using Euclidean algorithm:
9=24+1
or,
–2  4 + 1  9 = 1
From the last relation, this mean that –2 is inverse of
4 modulo 9.

note: observe that –2  4  1 (mod 9)

50
• note: every a number which is congruence to
–2 (mod 9)
is also inverse of 4, instantly 7, –11, 16, etc., because
7  –2 (mod 9) (9 is divisor of 7 – (–2) = 9)
–11  –2 (mod 9) (9 is divisor of –11 – (–2) = –9)
16  –2 (mod 9) (9 is divisor of 16 – (–2) = 18)

51
Practice .
• Find inverse of :
(a)17 (mod 7).
(b)18 (mod 10).

52
Solution
(a) Because gcd(17, 7) = 1, inverse of 17 (mod 7) is exist. Using
Euclidean algorithm:
17 = 2  7 + 3 (i)
7 = 2  3 + 1 (ii)
3 = 3  1 + 0 (iii) (this mean gcd(17, 7) = 1) )
compose (ii) become:
1 = 7 – 2  3 (iv)
compose (i) become:
3 = 17 – 2  7 (v)
substitute (v) to (iv):
1 = 7 – 2  (17 – 2  7) = 1  7 – 2  17 + 4  7 = 5  7 – 2  17
or
–2  17 + 5  7 = 1
from the last equation, it can be concluded that –2 is inverse of
17 (mod 7) 53
(b) because gcd(18, 10) = 2  1, inverse of
18 (mod 10) doesn't exist.

54
The other method to find inverse…
• Find inverse of a (mod m)
• Suppose x is inverse of a (mod m), then
ax  1 (mod m) (definition)
using ‘equation’:
ax = 1 + km
or
x = (1 + km)/a
try to some value of k = 0, 1, 2, … and k = -1, -2, …
the solution are all of integer that satisfies the
condition.
55
• example:
• Inverse of 4 (mod 9) is x such that 4x  1 (mod 9)
4x  1 (mod 9)  4x = 1 + 9k  x = (1 + 9k)/4
For k = 0  x isn’t integer
k = 1  x isn’t integer
k = 2  x isn’t integer
k = 3  x = (1 + 9 . 3)/4 = 7
k = -1  x = (1 + 9. –1)/4 = -2
Inverse of 4 (mod 9) is 7 (mod 9), or -2 (mod 9),
etc.
56
practice
• Find all of inverses of:
(a) 9 (mod 11).
(b) 8 (mod 13).

57
Solution
(a) Suppose 9-1 (mod 11) = x
9x  1 (mod 11) or 9x = 1 + 11k or
x = (1 + 11k)/9
trying some integer value of k (k = 0, -1, -2, ..., 1, 2,
...), then obtained x = 5. Moreover, all of number
which congruence to 5 (mod 11) is also solution,
that are –6, 16, 27, ...

58
Linear Congruence
• Linear congruence have form:
ax  b (mod m)
(m > 0, a and b are integer, and x is a variable on
set of integer).
b  km
Solution: ax = b + km  x  a

(trying for some value of k = 0, 1, 2, … and/or


k = –1, –2, …, such that x is integer)

59
example.
Find a solution of linear congruence: 4x  3 (mod 9)
Solution:
(i) 4x  3 (mod 9)
3 k 9
x
4
k = 0  x = (3 + 0  9)/4 = 3/4 (it isn’t solution)
k = 1  x = (3 + 1  9)/4 = 3
k = 2  x = (3 + 2  9)/4 = 21/4 (it isn’t solution)
k = 3, k = 4 (it isn’t solution)
k = 5  x = (3 + 5  9)/4 = 12

k = –1  x = (3 – 1  9)/4 = –6/4 (it isn’t solution)
k = –2  x = (3 – 2  9)/4 = –15/4 (it isn’t solution)
k = –3  x = (3 – 3  9)/4 = –6

k = –6  x = (3 – 6  9)/4 = –15

The value of x which are satisfies the condition : 3, 12, … and –6, –15,
60
practice
• Solve linear congruence
(a) 3x ≡ 4 (mod 5)
(b) 2x ≡ 3 (mod 4)

61
The other method to find solution
ax  b (mod m)
• Analogy to ordinary equation:
4x = 12
1/4 . 4x = 12 . 1/4 (multiplied by ¼  inverse of 4).
x=3

• 4x  3 (mod 9)
(multiplied by inverse of 4 (mod 9); that is –2)
(-2) . 4x  (-2) . 3 (mod 9)
-8x  -6 (mod 9)

because –8  1 (mod 9), then x  -6 (mod 9).


all of integer which congruence to –6 (mod 9) are the solutions,
namely 3, 12, …, and –6, -15, …

62
practice
• An integer if divided by 3 have a remainder 2,
and if divided by 5 have a remainder 3. Find
those integer !

63
Solution
Suppose integer = x
x mod 3 = 2  x  2 (mod 3)
x mod 5 = 3  x  3 (mod 5)
thus, congruence system:
x  2 (mod 3) (i)
x  3 (mod 5) (ii)
the first congruence:
x = 2 + 3k1 (iii)
substitute (iii) to (ii):
2 + 3k1  3 (mod 5)  3k1  1 (mod 5)
then k1  2 (mod 5) or k1 = 2 + 5k2
64
x = 2 + 3k1
= 2 + 3 (2 + 5k2)
= 2 + 6 + 15k2
= 8 + 15k2
or
x  8 (mod 15)

All of value x which congruence to 8 (mod 15) is a solution,


namely
x = 8, x = 23, x = 38, …, x = -7, etc.

65
Chinese Remainder Problem

66
Chinese Remainder Problem
• Mathematician from Chinese propose a question:

Determine an integer which is divide by 5 have


remainder 3, if divided by 7 have remainder 5, and if
divided by 11 have remainder 7.

• Suppose the integer = x. Using linear congruence:


x  3 (mod 5)
x  5 (mod 7)
x  7 (mod 11)
67
Theorem (Chinese Remainder Theorem)

Suppose m1, m2, …, mn are positive integer


such that gcd(mi, mj) = 1 for i  j. The linear
congruence system

x  ak (mod mk)

have a unique solution in modulo m = m1  m2


 …  mn.

68
Example.
Solve the Sun Tse problem above !.
Solution:
x  3 (mod 5)  x = 3 + 5k1 (i)
substitute (i) to the second congruence:
3 + 5k1  5 (mod 7)  k1  6 (mod 7), or k1 = 6 + 7k2 (ii)
Substitute (ii) to (i):
x = 3 + 5k1 = 3 + 5(6 + 7k2) = 33 + 35k2 (iii)
Substitute (iii) to the third congruence:
33 + 35k2  7 (mod 11)  k2  9 (mod 11) or k2 = 9 + 11k3.
Substitute k2 to (iii) become:
x = 33 + 35(9 + 11k3) = 348 + 385k3
or x  348 (mod 385). This is a solution.
348 is least positive integer which is the solution of the problem.
Observe that 348 mod 5 = 3, 348 mod 7 = 5, and 348 mod 11 = 7.
And also observe that 385 = 5  7  11.
69
• This solution is unique:
m = m1  m2  m3 = 5  7  11 = 5  77 = = 7.55 = 11  35.
because 77 . 3  1 (mod 5),
55  6  1 (mod 7),
35  6  1 (mod 11),
so,
x  3  77  3 + 5  55  6 + 7  35  6 (mod 385)
 3813 (mod 385)
 348 (mod 385)

70
Prime Number

71
Prime Number
• A positive integer p (p > 1) called prime
number if it is only have divisor 1 and p.

• example: 23 is prime number because it is


only have divisor 1 and 23.

72
Prime number (cont.)
• Because prime number must be greater than 1, the
sequence of prime numbers is start from 2, that are
2, 3, 5, 7, 11, 13, ….

• All of the prime number are odd, it is only number 2


that even.

• If the number is not prime, called composite.


Suppose 20 is composite number 20 because divisor
of 20 are 2, 4, 5, and 10, beside 1 and 20.

73
The Fundamental Theorem of
Arithmetic
Every positive integer greater than or equal 2
can be composed as multiplication of one or
more prime number.

example.
9=33
100 = 2  2  5  5
13 = 13 (or 1  13)

74
Primarily testing
(i) divide n by amount of prime number, start
from 2, 3, … , prime number  n.

(ii) if n divided one of the prime number have


remainder 0, then n is composite number.

(ii) but if n divided by all of prime number  n


have remainder not zero, then n is prime number.

75
• example. Determine (i) 171 and (ii) 199 prime number
or composite number !.
Solution:
(i) 171 = 13.077. The prime number  171 are 2, 3,
5, 7, 11, 13.
Because 171 have factor 3, on the other hand 171 : 3 =
57 with remainder 0, then 171 is composite number.

(ii) 199 = 14.107. The prime number  199 are 2, 3,


5, 7, 11, 13.
Because 2, 3, 5, 7, 11, and 13 aren’t divisor of 199,
then 199 is prime number.

76
practice
Using primarily testing, determine the number
below prime or not !
(a) 111
(b) 127
(c) 139
(d) 143
(e) 231

77
Fermat Theorem
• If p is prime number and a are integer such
that gcd(a, p) = 1, then

ap–1  1 (mod p)

78
example. Determine 17 and 21 prime number or
composite number using Fermat Theorem !.
Let a = 2, because gcd(17, 2) = 1 and gcd(21, 2) = 1,
then:
(i) 217–1 = 65536  1 (mod 17)
because 17 are factor of (65536 – 1) = 65535,
thus, 17 is prime number.

(ii) 221–1 = 1048576 ≢ 1 (mod 21)


because 21 aren’t factor of (1048576 – 1) =
1048575, thus 21 isn’t prime number.

79
Application of Number Theory
• Cryptography
• Hash function
• ISBN (International Serial Book Number)
• Random-number generating
• Etc.

80
Assignment

Make a summary about application of


number theory on cryptography

81

You might also like