0% found this document useful (0 votes)
57 views269 pages

Chapter 4. Number Theory and Cryptography

The document outlines topics in number theory and cryptography, including the integers and division, algorithms, primes, and greatest common divisors. It first defines division of integers and provides examples. It then presents an algorithm to find the quotient and remainder of integer division. Finally, it describes the division algorithm, defining the divisor, dividend, quotient, and remainder.

Uploaded by

levohonghuy2004
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
57 views269 pages

Chapter 4. Number Theory and Cryptography

The document outlines topics in number theory and cryptography, including the integers and division, algorithms, primes, and greatest common divisors. It first defines division of integers and provides examples. It then presents an algorithm to find the quotient and remainder of integer division. Finally, it describes the division algorithm, defining the divisor, dividend, quotient, and remainder.

Uploaded by

levohonghuy2004
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 269

The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Chapter 4. Number Theory and


Cryptography

Lai Văn Phút

Ngày 23 tháng 6 năm 2022

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Contents

1. The Integers and Division

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Contents

1. The Integers and Division


2. Integers and Algorithms

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Contents

1. The Integers and Division


2. Integers and Algorithms
3. Primes and Greatest Common Divisors

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Division

Definition. Let a and b are integers, then b is said to be


divisible by a (or b is a multiple of a, or a is a divisor of b,
or a divides b), if there exists an integer k such that
b = ka. We also write a |b

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Division

Definition. Let a and b are integers, then b is said to be


divisible by a (or b is a multiple of a, or a is a divisor of b,
or a divides b), if there exists an integer k such that
b = ka. We also write a |b
Example.
1. 3 - 13

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Division

Definition. Let a and b are integers, then b is said to be


divisible by a (or b is a multiple of a, or a is a divisor of b,
or a divides b), if there exists an integer k such that
b = ka. We also write a |b
Example.
1. 3 - 13
2. 4 | 12

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Division

Definition. Let a and b are integers, then b is said to be


divisible by a (or b is a multiple of a, or a is a divisor of b,
or a divides b), if there exists an integer k such that
b = ka. We also write a |b
Example.
1. 3 - 13
2. 4 | 12
3. Let n and d be positive integer. How many positive
integers not exceeding (≤) n are divisible by d ?

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Division

Definition. Let a and b are integers, then b is said to be


divisible by a (or b is a multiple of a, or a is a divisor of b,
or a divides b), if there exists an integer k such that
b = ka. We also write a |b
Example.
1. 3 - 13
2. 4 | 12
3. Let n and d be positive integer. How many positive
integers not exceeding (≤) n are divisible by d ?

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Division

Definition. Let a and b are integers, then b is said to be


divisible by a (or b is a multiple of a, or a is a divisor of b,
or a divides b), if there exists an integer k such that
b = ka. We also write a |b
Example.
1. 3 - 13
2. 4 | 12
3. Let n and d be positive integer. How many positive
integers not exceeding (≤) n are divisible by d ?
Suppose d |m =⇒ m = kd. We have
n
0 < kd ≤ n =⇒ k ≤ . Thus, the number of those integers
d
are b dn c

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

An algorithm to find k

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

An algorithm to find k

1. Let i = 0

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

An algorithm to find k

1. Let i = 0
2. If (i + 1)d > n then k = i

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

An algorithm to find k

1. Let i = 0
2. If (i + 1)d > n then k = i
3. Othersewise go back to step 2. with i is replaced by
i +1

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

An algorithm to find k

1. Let i = 0
2. If (i + 1)d > n then k = i
3. Othersewise go back to step 2. with i is replaced by
i +1

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

An algorithm to find k

1. Let i = 0
2. If (i + 1)d > n then k = i
3. Othersewise go back to step 2. with i is replaced by
i +1
Notes.
• Let r = n − kd . Then we have n = kd + r. The integers
k and r are called the quotient (thương) and the
remainder (số dư) in the division of n by d.

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

An algorithm to find k

1. Let i = 0
2. If (i + 1)d > n then k = i
3. Othersewise go back to step 2. with i is replaced by
i +1
Notes.
• Let r = n − kd . Then we have n = kd + r. The integers
k and r are called the quotient (thương) and the
remainder (số dư) in the division of n by d.
• Thus the above algorithm allows us to find the
quotient and the remainder of the division algorithm
(thuật toán chia).
Lai Văn Phút Chapter 4. Number Theory and Cryptography
The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

The Division algorithm


Let a be an integer and d a positive integer. Then there
are unique integers q and r such that

a = dq + r, 0 ≤ r < d

• d is called the divisor (số chia),

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

The Division algorithm


Let a be an integer and d a positive integer. Then there
are unique integers q and r such that

a = dq + r, 0 ≤ r < d

• d is called the divisor (số chia),


• a the dividend (số bị chia),

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

The Division algorithm


Let a be an integer and d a positive integer. Then there
are unique integers q and r such that

a = dq + r, 0 ≤ r < d

• d is called the divisor (số chia),


• a the dividend (số bị chia),
• q the quotient (thương) and r the remainder (số dư).

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

The Division algorithm


Let a be an integer and d a positive integer. Then there
are unique integers q and r such that

a = dq + r, 0 ≤ r < d

• d is called the divisor (số chia),


• a the dividend (số bị chia),
• q the quotient (thương) and r the remainder (số dư).

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

The Division algorithm


Let a be an integer and d a positive integer. Then there
are unique integers q and r such that

a = dq + r, 0 ≤ r < d

• d is called the divisor (số chia),


• a the dividend (số bị chia),
• q the quotient (thương) and r the remainder (số dư).
Note. We also write q = a div d, r = a mod d.

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

The Division algorithm


Let a be an integer and d a positive integer. Then there
are unique integers q and r such that

a = dq + r, 0 ≤ r < d

• d is called the divisor (số chia),


• a the dividend (số bị chia),
• q the quotient (thương) and r the remainder (số dư).
Note. We also write q = a div d, r = a mod d.
Example.
1. Find the quotient and the remainder in the division of
101 by 11

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

The Division algorithm


Let a be an integer and d a positive integer. Then there
are unique integers q and r such that

a = dq + r, 0 ≤ r < d

• d is called the divisor (số chia),


• a the dividend (số bị chia),
• q the quotient (thương) and r the remainder (số dư).
Note. We also write q = a div d, r = a mod d.
Example.
1. Find the quotient and the remainder in the division of
101 by 11
2. Find the quotient and the remainder in the division of
–11 by 3
Lai Văn Phút Chapter 4. Number Theory and Cryptography
The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Solution

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Quizz

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Quizz

Ans: b
Lai Văn Phút Chapter 4. Number Theory and Cryptography
The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Quizz

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Quizz

Ans: d

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

The Congruences (đồng dư)

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

The Congruences (đồng dư)

6|(17 − 5)?

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

The Congruences (đồng dư)

6|(17 − 5)?→ 17 ≡ 5 mod 6

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

The Congruences (đồng dư)

6|(17 − 5)?→ 17 ≡ 5 mod 6

Example. Are the following congruences true?


• 17 ≡ 5 (mod 6)

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

The Congruences (đồng dư)

6|(17 − 5)?→ 17 ≡ 5 mod 6

Example. Are the following congruences true?


• 17 ≡ 5 (mod 6)
• 24 ≡ 14 (mod 6)

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Solution

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Theorem

1. Let a, b be integers and m is a positive integer. Then


a ≡ b (mod m) if and only if a mod m = b mod m.

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Theorem

1. Let a, b be integers and m is a positive integer. Then


a ≡ b (mod m) if and only if a mod m = b mod m.
2. Let a, b be integers and m is a positive integer. Then
a ≡ b (mod m) if and only if there is an integer k such
that a = b + km.

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Theorem

1. Let a, b be integers and m is a positive integer. Then


a ≡ b (mod m) if and only if a mod m = b mod m.
2. Let a, b be integers and m is a positive integer. Then
a ≡ b (mod m) if and only if there is an integer k such
that a = b + km.
3. let m is 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).

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Theorem

1. Let a, b be integers and m is a positive integer. Then


a ≡ b (mod m) if and only if a mod m = b mod m.
2. Let a, b be integers and m is a positive integer. Then
a ≡ b (mod m) if and only if there is an integer k such
that a = b + km.
3. let m is 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).

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Theorem

1. Let a, b be integers and m is a positive integer. Then


a ≡ b (mod m) if and only if a mod m = b mod m.
2. Let a, b be integers and m is a positive integer. Then
a ≡ b (mod m) if and only if there is an integer k such
that a = b + km.
3. let m is 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).
Corollary. Let a, b are integers and m is a positive integer.
Then
1. (a + b) mod m = (a mod m+b mod m)(mod m)

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Theorem

1. Let a, b be integers and m is a positive integer. Then


a ≡ b (mod m) if and only if a mod m = b mod m.
2. Let a, b be integers and m is a positive integer. Then
a ≡ b (mod m) if and only if there is an integer k such
that a = b + km.
3. let m is 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).
Corollary. Let a, b are integers and m is a positive integer.
Then
1. (a + b) mod m = (a mod m+b mod m)(mod m)
2. (ab) mod m = ((a mod m)(b mod m))(mod m)

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Applications of Congruences: Cryptography (mật


mã)

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Applications of Congruences: Cryptography (mật


mã)

f : Z26 → Z26 , f (p) = (p + k ) mod 26: bijection


• Encryption (mã hóa) f (p) = (p + k ) mod 26

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Applications of Congruences: Cryptography (mật


mã)

f : Z26 → Z26 , f (p) = (p + k ) mod 26: bijection


• Encryption (mã hóa) f (p) = (p + k ) mod 26
• Decryption (giải mã) f −1 (p) = (p − k ) mod 26

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Example.

Example.
1. What is the secret message produced from the
message “MEET YOU IN THE PARK” using the Caesar
cipher (k=3)?

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Example.

Example.
1. What is the secret message produced from the
message “MEET YOU IN THE PARK” using the Caesar
cipher (k=3)?
2. Decrypt the ciphertext message “LEWLYPLUJL PZ H
NYLHA ALHJOLY” that was encrypted with the shift
cipher with shift k = 7.

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Example.

Example.
1. What is the secret message produced from the
message “MEET YOU IN THE PARK” using the Caesar
cipher (k=3)?
2. Decrypt the ciphertext message “LEWLYPLUJL PZ H
NYLHA ALHJOLY” that was encrypted with the shift
cipher with shift k = 7.
3. What letter replaces the letter K when the function
f (p) = (7p + 3)mod26 is used for encryption?

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Solution

”MEET YOU IN THE PARK”


→ 12 4 4 19-24 14 20-8 13- 19 7 4-15 0 17 10
f (p) = (p + 3) mod 26, so:
f(12)=15mod26=15

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Solution

”MEET YOU IN THE PARK”


→ 12 4 4 19-24 14 20-8 13- 19 7 4-15 0 17 10
f (p) = (p + 3) mod 26, so:
f(12)=15mod26=15
f(4)=7mod26=7

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Solution

”MEET YOU IN THE PARK”


→ 12 4 4 19-24 14 20-8 13- 19 7 4-15 0 17 10
f (p) = (p + 3) mod 26, so:
f(12)=15mod26=15
f(4)=7mod26=7
......

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Solution

”MEET YOU IN THE PARK”


→ 12 4 4 19-24 14 20-8 13- 19 7 4-15 0 17 10
f (p) = (p + 3) mod 26, so:
f(12)=15mod26=15
f(4)=7mod26=7
......

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Solution

”MEET YOU IN THE PARK”


→ 12 4 4 19-24 14 20-8 13- 19 7 4-15 0 17 10
f (p) = (p + 3) mod 26, so:
f(12)=15mod26=15
f(4)=7mod26=7
......
→ 15 7 7 22-1 17 23- 11 16- 22 10 7- 18 3 20 13, so:

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Solution

”MEET YOU IN THE PARK”


→ 12 4 4 19-24 14 20-8 13- 19 7 4-15 0 17 10
f (p) = (p + 3) mod 26, so:
f(12)=15mod26=15
f(4)=7mod26=7
......
→ 15 7 7 22-1 17 23- 11 16- 22 10 7- 18 3 20 13, so:
”PHHW BRX LQ WHK SDUN”

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Solution

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Solution

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Solution

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Solution

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Solution

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Solution

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Quizz

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Quizz

Ans: d

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Applications of Congruences: Pseudorandom


Numbers (số giả ngẫu nhiên)

xn+1 = (axn + c ) mod m

Notes.
• a: Multiplier (nhân tử) (2 ≤ a < m)

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Applications of Congruences: Pseudorandom


Numbers (số giả ngẫu nhiên)

xn+1 = (axn + c ) mod m

Notes.
• a: Multiplier (nhân tử) (2 ≤ a < m)
• c: Increment (số gia) (0 ≤< m)

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Applications of Congruences: Pseudorandom


Numbers (số giả ngẫu nhiên)

xn+1 = (axn + c ) mod m

Notes.
• a: Multiplier (nhân tử) (2 ≤ a < m)
• c: Increment (số gia) (0 ≤< m)
• x0 : seed (hạt giống) (0 ≤ x0 < m)

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Applications of Congruences: Pseudorandom


Numbers (số giả ngẫu nhiên)

xn+1 = (axn + c ) mod m

Notes.
• a: Multiplier (nhân tử) (2 ≤ a < m)
• c: Increment (số gia) (0 ≤< m)
• x0 : seed (hạt giống) (0 ≤ x0 < m)
• m: modulus (mođun)

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Applications of Congruences: Pseudorandom


Numbers (số giả ngẫu nhiên)

xn+1 = (axn + c ) mod m

Notes.
• a: Multiplier (nhân tử) (2 ≤ a < m)
• c: Increment (số gia) (0 ≤< m)
• x0 : seed (hạt giống) (0 ≤ x0 < m)
• m: modulus (mođun)

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Applications of Congruences: Pseudorandom


Numbers (số giả ngẫu nhiên)

xn+1 = (axn + c ) mod m

Notes.
• a: Multiplier (nhân tử) (2 ≤ a < m)
• c: Increment (số gia) (0 ≤< m)
• x0 : seed (hạt giống) (0 ≤ x0 < m)
• m: modulus (mođun)
Example.(Random numbers from 0 to 8) Find the
sequence of pseudorandom numbers generated by the
linear congruential method with modulus m = 9, multiplier
a = 7, increment c = 4, and seed x0 = 3.

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Applications of Congruences: Pseudorandom


Numbers (số giả ngẫu nhiên)

xn+1 = (axn + c ) mod m

Notes.
• a: Multiplier (nhân tử) (2 ≤ a < m)
• c: Increment (số gia) (0 ≤< m)
• x0 : seed (hạt giống) (0 ≤ x0 < m)
• m: modulus (mođun)
Example.(Random numbers from 0 to 8) Find the
sequence of pseudorandom numbers generated by the
linear congruential method with modulus m = 9, multiplier
a = 7, increment c = 4, and seed x0 = 3.m = 9, a = 7, c =
4, x0 = 3 =⇒ xn+1 = 7xn + 4
Lai Văn Phút Chapter 4. Number Theory and Cryptography
The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Applications of Congruences: Pseudorandom


Numbers (số giả ngẫu nhiên)

xn+1 = (axn + c ) mod m

Notes.
• a: Multiplier (nhân tử) (2 ≤ a < m)
• c: Increment (số gia) (0 ≤< m)
• x0 : seed (hạt giống) (0 ≤ x0 < m)
• m: modulus (mođun)
Example.(Random numbers from 0 to 8) Find the
sequence of pseudorandom numbers generated by the
linear congruential method with modulus m = 9, multiplier
a = 7, increment c = 4, and seed x0 = 3.m = 9, a = 7, c =
4, x0 = 3 =⇒ xn+1 = 7xn + 4 =⇒ x1 , x2 , ...
Lai Văn Phút Chapter 4. Number Theory and Cryptography
The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Solution.

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Example.

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Applications of Congruences: Hashing Function

H (k ) = k mod m
Using in searching data in memory
• k: data searched,

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Applications of Congruences: Hashing Function

H (k ) = k mod m
Using in searching data in memory
• k: data searched,
• m: memory block.

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Applications of Congruences: Hashing Function

H (k ) = k mod m
Using in searching data in memory
• k: data searched,
• m: memory block.

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Applications of Congruences: Hashing Function

H (k ) = k mod m
Using in searching data in memory
• k: data searched,
• m: memory block.
Example. Find the memory locations assigned by the
hashing function h(k ) = k mod 111 to the records of
customers with Social Security numbers 064212848 and
037149212.

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Applications of Congruences: Hashing Function

H (k ) = k mod m
Using in searching data in memory
• k: data searched,
• m: memory block.
Example. Find the memory locations assigned by the
hashing function h(k ) = k mod 111 to the records of
customers with Social Security numbers 064212848 and
037149212.
h(064212848) = 064212848 mod 111 = 14

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Applications of Congruences: Hashing Function

H (k ) = k mod m
Using in searching data in memory
• k: data searched,
• m: memory block.
Example. Find the memory locations assigned by the
hashing function h(k ) = k mod 111 to the records of
customers with Social Security numbers 064212848 and
037149212.
h(064212848) = 064212848 mod 111 = 14

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Applications of Congruences: Hashing Function

H (k ) = k mod m
Using in searching data in memory
• k: data searched,
• m: memory block.
Example. Find the memory locations assigned by the
hashing function h(k ) = k mod 111 to the records of
customers with Social Security numbers 064212848 and
037149212.
h(064212848) = 064212848 mod 111 = 14→memory
location 14.
h(037149212) = 037149212 mod 111 = 65

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Applications of Congruences: Hashing Function

H (k ) = k mod m
Using in searching data in memory
• k: data searched,
• m: memory block.
Example. Find the memory locations assigned by the
hashing function h(k ) = k mod 111 to the records of
customers with Social Security numbers 064212848 and
037149212.
h(064212848) = 064212848 mod 111 = 14→memory
location 14.
h(037149212) = 037149212 mod 111 = 65

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Applications of Congruences: Hashing Function

H (k ) = k mod m
Using in searching data in memory
• k: data searched,
• m: memory block.
Example. Find the memory locations assigned by the
hashing function h(k ) = k mod 111 to the records of
customers with Social Security numbers 064212848 and
037149212.
h(064212848) = 064212848 mod 111 = 14→memory
location 14.
h(037149212) = 037149212 mod 111 = 65 → memory
location 65.
Lai Văn Phút Chapter 4. Number Theory and Cryptography
The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Representations of Integers

n = ak bk + ak −1 bk −1 + ... + a1 b + a0 . Denote (ak ak −1 ...a1 a0 )b


Notes.
• n: positive integer.

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Representations of Integers

n = ak bk + ak −1 bk −1 + ... + a1 b + a0 . Denote (ak ak −1 ...a1 a0 )b


Notes.
• n: positive integer.
• b > 1: integer.

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Representations of Integers

n = ak bk + ak −1 bk −1 + ... + a1 b + a0 . Denote (ak ak −1 ...a1 a0 )b


Notes.
• n: positive integer.
• b > 1: integer.
• a0 , a1 , ..., ak < b, ak 6= 0: nonnegative integer.

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Representations of Integers

n = ak bk + ak −1 bk −1 + ... + a1 b + a0 . Denote (ak ak −1 ...a1 a0 )b


Notes.
• n: positive integer.
• b > 1: integer.
• a0 , a1 , ..., ak < b, ak 6= 0: nonnegative integer.

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Representations of Integers

n = ak bk + ak −1 bk −1 + ... + a1 b + a0 . Denote (ak ak −1 ...a1 a0 )b


Notes.
• n: positive integer.
• b > 1: integer.
• a0 , a1 , ..., ak < b, ak 6= 0: nonnegative integer.
This is the base b expansion of the integer n.

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Representations of Integers

n = ak bk + ak −1 bk −1 + ... + a1 b + a0 . Denote (ak ak −1 ...a1 a0 )b


Notes.
• n: positive integer.
• b > 1: integer.
• a0 , a1 , ..., ak < b, ak 6= 0: nonnegative integer.
This is the base b expansion of the integer n.
Examples.
1. (241)10 = ?

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Representations of Integers

n = ak bk + ak −1 bk −1 + ... + a1 b + a0 . Denote (ak ak −1 ...a1 a0 )b


Notes.
• n: positive integer.
• b > 1: integer.
• a0 , a1 , ..., ak < b, ak 6= 0: nonnegative integer.
This is the base b expansion of the integer n.
Examples.
1. (241)10 = ?

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Representations of Integers

n = ak bk + ak −1 bk −1 + ... + a1 b + a0 . Denote (ak ak −1 ...a1 a0 )b


Notes.
• n: positive integer.
• b > 1: integer.
• a0 , a1 , ..., ak < b, ak 6= 0: nonnegative integer.
This is the base b expansion of the integer n.
Examples.
1. (241)10 = ? → (241)10 = 2.102 + 4.101 + 1.100 = 241
2. (7016)8 = ?

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Representations of Integers

n = ak bk + ak −1 bk −1 + ... + a1 b + a0 . Denote (ak ak −1 ...a1 a0 )b


Notes.
• n: positive integer.
• b > 1: integer.
• a0 , a1 , ..., ak < b, ak 6= 0: nonnegative integer.
This is the base b expansion of the integer n.
Examples.
1. (241)10 = ? → (241)10 = 2.102 + 4.101 + 1.100 = 241
2. (7016)8 = ?

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Representations of Integers

n = ak bk + ak −1 bk −1 + ... + a1 b + a0 . Denote (ak ak −1 ...a1 a0 )b


Notes.
• n: positive integer.
• b > 1: integer.
• a0 , a1 , ..., ak < b, ak 6= 0: nonnegative integer.
This is the base b expansion of the integer n.
Examples.
1. (241)10 = ? → (241)10 = 2.102 + 4.101 + 1.100 = 241
2. (7016)8 = ? →
(7016)8 = 7.83 + 0.82 + 1.81 + 6.80 = 3598 = (3598)10
3. Suppose that the letters A through F represent the
digits corresponding to the numbers 10 through 15 (in
decimal notation). Find (2AE0B )16
Lai Văn Phút Chapter 4. Number Theory and Cryptography
The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Representations of Integers

n = ak bk + ak −1 bk −1 + ... + a1 b + a0 . Denote (ak ak −1 ...a1 a0 )b


Notes.
• n: positive integer.
• b > 1: integer.
• a0 , a1 , ..., ak < b, ak 6= 0: nonnegative integer.
This is the base b expansion of the integer n.
Examples.
1. (241)10 = ? → (241)10 = 2.102 + 4.101 + 1.100 = 241
2. (7016)8 = ? →
(7016)8 = 7.83 + 0.82 + 1.81 + 6.80 = 3598 = (3598)10
3. Suppose that the letters A through F represent the
digits corresponding to the numbers 10 through 15 (in
decimal notation). Find (2AE0B )16
Lai Văn Phút Chapter 4. Number Theory and Cryptography
The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Representations of Integers

n = ak bk + ak −1 bk −1 + ... + a1 b + a0 . Denote (ak ak −1 ...a1 a0 )b


Notes.
• n: positive integer.
• b > 1: integer.
• a0 , a1 , ..., ak < b, ak 6= 0: nonnegative integer.
This is the base b expansion of the integer n.
Examples.
1. (241)10 = ? → (241)10 = 2.102 + 4.101 + 1.100 = 241
2. (7016)8 = ? →
(7016)8 = 7.83 + 0.82 + 1.81 + 6.80 = 3598 = (3598)10
3. Suppose that the letters A through F represent the
digits corresponding to the numbers 10 through 15 (in
decimal notation). Find (2AE0B )16 →= 175627
Lai Văn Phút Chapter 4. Number Theory and Cryptography
The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Common Bases Expansions

• Decimal Expansions (b = 10) (thập phân)

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Common Bases Expansions

• Decimal Expansions (b = 10) (thập phân)


• Binary Expansions (b = 2) (nhị phân)

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Common Bases Expansions

• Decimal Expansions (b = 10) (thập phân)


• Binary Expansions (b = 2) (nhị phân)
• Octal Expansions (b = 8) (bát phân)

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Common Bases Expansions

• Decimal Expansions (b = 10) (thập phân)


• Binary Expansions (b = 2) (nhị phân)
• Octal Expansions (b = 8) (bát phân)
• Hexadecimal Expansions (b = 16) (thập lục phân)

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Examples.

a. Find 2 expansion of (241)10

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Examples.

a. Find 2 expansion of (241)10


b. Find 8 expansion of (12345)10

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Examples.

a. Find 2 expansion of (241)10


b. Find 8 expansion of (12345)10
c. Find 16 expansion of (177130)10

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Sol a.

241 = 120.2 + 1

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Sol a.

241 = 120.2 + 1
= 60.22 + 1

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Sol a.

241 = 120.2 + 1
= 60.22 + 1
= 30.23 + 1

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Sol a.

241 = 120.2 + 1
= 60.22 + 1
= 30.23 + 1
= 15.24 + 1

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Sol a.

241 = 120.2 + 1
= 60.22 + 1
= 30.23 + 1
= 15.24 + 1
= (7.2 + 1).24 + 1 =
7.25 + 24 + 1

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Sol a.

241 = 120.2 + 1
= 60.22 + 1
= 30.23 + 1
= 15.24 + 1
= (7.2 + 1).24 + 1 =
7.25 + 24 + 1
= (3.2 + 1).25 + 24 + 1 =
3.26 + 25 + 24 + 1

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Sol a.

241 = 120.2 + 1
= 60.22 + 1
= 30.23 + 1
= 15.24 + 1
= (7.2 + 1).24 + 1 =
7.25 + 24 + 1
= (3.2 + 1).25 + 24 + 1 =
3.26 + 25 + 24 + 1
(1.2 + 1).26 + 25 + 24 + 1 =
27 + 26 + 25 + 24 + 1

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Sol a.

241 = 120.2 + 1
= 60.22 + 1
= 30.23 + 1
= 15.24 + 1
= (7.2 + 1).24 + 1 =
7.25 + 24 + 1
= (3.2 + 1).25 + 24 + 1 =
3.26 + 25 + 24 + 1
(1.2 + 1).26 + 25 + 24 + 1 =
27 + 26 + 25 + 24 + 1

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Sol a.

241 = 120.2 + 1
= 60.22 + 1
= 30.23 + 1
= 15.24 + 1
= (7.2 + 1).24 + 1 =
7.25 + 24 + 1
= (3.2 + 1).25 + 24 + 1 =
3.26 + 25 + 24 + 1
(1.2 + 1).26 + 25 + 24 + 1 =
27 + 26 + 25 + 24 + 1
Thus, (241)10 = 241 = (11110001)2

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Sol a.

241 = 120.2 + 1 241 =


= 60.22
+1 2.120 + 1
3
= 30.2 + 1
= 15.24 + 1
= (7.2 + 1).24 + 1 =
7.25 + 24 + 1
= (3.2 + 1).25 + 24 + 1 =
3.26 + 25 + 24 + 1
(1.2 + 1).26 + 25 + 24 + 1 =
27 + 26 + 25 + 24 + 1
Thus, (241)10 = 241 = (11110001)2

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Sol a.

241 = 120.2 + 1 241 =


= 60.22
+1 2.120 + 1
3
= 30.2 + 1 120 =
2.60 + 0
= 15.24 + 1
= (7.2 + 1).24 + 1 =
7.25 + 24 + 1
= (3.2 + 1).25 + 24 + 1 =
3.26 + 25 + 24 + 1
(1.2 + 1).26 + 25 + 24 + 1 =
27 + 26 + 25 + 24 + 1
Thus, (241)10 = 241 = (11110001)2

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Sol a.

241 = 120.2 + 1 241 =


= 60.22
+1 2.120 + 1
3
= 30.2 + 1 120 =
2.60 + 0
= 15.24 + 1
60 = 2.30 + 0
= (7.2 + 1).24 + 1 =
7.25 + 24 + 1
= (3.2 + 1).25 + 24 + 1 =
3.26 + 25 + 24 + 1
(1.2 + 1).26 + 25 + 24 + 1 =
27 + 26 + 25 + 24 + 1
Thus, (241)10 = 241 = (11110001)2

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Sol a.

241 = 120.2 + 1 241 =


= 60.22
+1 2.120 + 1
3
= 30.2 + 1 120 =
2.60 + 0
= 15.24 + 1
60 = 2.30 + 0
= (7.2 + 1).24 + 1 =
7.25 + 24 + 1 30 = 2.15 + 0
= (3.2 + 1).25 + 24 + 1 =
3.26 + 25 + 24 + 1
(1.2 + 1).26 + 25 + 24 + 1 =
27 + 26 + 25 + 24 + 1
Thus, (241)10 = 241 = (11110001)2

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Sol a.

241 = 120.2 + 1 241 =


= 60.22
+1 2.120 + 1
3
= 30.2 + 1 120 =
2.60 + 0
= 15.24 + 1
60 = 2.30 + 0
= (7.2 + 1).24 + 1 =
7.25 + 24 + 1 30 = 2.15 + 0
= (3.2 + 1).25 + 24 + 1 = 15 = 2.7 + 1
3.26 + 25 + 24 + 1
(1.2 + 1).26 + 25 + 24 + 1 =
27 + 26 + 25 + 24 + 1
Thus, (241)10 = 241 = (11110001)2

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Sol a.

241 = 120.2 + 1 241 =


= 60.22
+1 2.120 + 1
3
= 30.2 + 1 120 =
2.60 + 0
= 15.24 + 1
60 = 2.30 + 0
= (7.2 + 1).24 + 1 =
7.25 + 24 + 1 30 = 2.15 + 0
= (3.2 + 1).25 + 24 + 1 = 15 = 2.7 + 1
3.26 + 25 + 24 + 1 7 = 2.3 + 1
(1.2 + 1).26 + 25 + 24 + 1 =
27 + 26 + 25 + 24 + 1
Thus, (241)10 = 241 = (11110001)2

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Sol a.

241 = 120.2 + 1 241 =


= 60.22
+1 2.120 + 1
3
= 30.2 + 1 120 =
2.60 + 0
= 15.24 + 1
60 = 2.30 + 0
= (7.2 + 1).24 + 1 =
7.25 + 24 + 1 30 = 2.15 + 0
= (3.2 + 1).25 + 24 + 1 = 15 = 2.7 + 1
3.26 + 25 + 24 + 1 7 = 2.3 + 1
(1.2 + 1).26 + 25 + 24 + 1 = 3 = 2.1 + 1
27 + 26 + 25 + 24 + 1
Thus, (241)10 = 241 = (11110001)2

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Sol a.

241 = 120.2 + 1 241 =


= 60.22
+1 2.120 + 1
3
= 30.2 + 1 120 =
2.60 + 0
= 15.24 + 1
60 = 2.30 + 0
= (7.2 + 1).24 + 1 =
7.25 + 24 + 1 30 = 2.15 + 0
= (3.2 + 1).25 + 24 + 1 = 15 = 2.7 + 1
3.26 + 25 + 24 + 1 7 = 2.3 + 1
(1.2 + 1).26 + 25 + 24 + 1 = 3 = 2.1 + 1
27 + 26 + 25 + 24 + 1 1 = 2.0 + 1
Thus, (241)10 = 241 = (11110001)2

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Sol a.

241 = 120.2 + 1 241 =


= 60.22
+1 2.120 + 1
3
= 30.2 + 1 120 =
2.60 + 0
= 15.24 + 1
60 = 2.30 + 0
= (7.2 + 1).24 + 1 =
7.25 + 24 + 1 30 = 2.15 + 0
= (3.2 + 1).25 + 24 + 1 = 15 = 2.7 + 1
3.26 + 25 + 24 + 1 7 = 2.3 + 1
(1.2 + 1).26 + 25 + 24 + 1 = 3 = 2.1 + 1
27 + 26 + 25 + 24 + 1 1 = 2.0 + 1
Thus, (241)10 = 241 = (11110001)2

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Sol a.

241 = 120.2 + 1 241 =


= 60.22
+1 2.120 + 1
3
= 30.2 + 1 120 =
2.60 + 0
= 15.24 + 1
60 = 2.30 + 0
= (7.2 + 1).24 + 1 =
7.25 + 24 + 1 30 = 2.15 + 0
= (3.2 + 1).25 + 24 + 1 = 15 = 2.7 + 1
6 5 4
3.2 + 2 + 2 + 1 7 = 2.3 + 1
6 5 4
(1.2 + 1).2 + 2 + 2 + 1 = 3 = 2.1 + 1
7 6 5
2 +2 +2 +2 +1 4
1 = 2.0 + 1
Thus, (241)10 = 241 = (11110001)2 Thus, (241)10 =
241 =
(11110001)2
Lai Văn Phút Chapter 4. Number Theory and Cryptography
The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Solution.

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Solution.

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Constructing Base b Expansions

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Constructing Base b Expansions

Example. Find base 2 expansion of 241.

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Solution.

q = 241 6= 0
k=0: a0 = 241 mod 2 = 1, q = 241 div 2 = 120 6= 0

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Solution.

q = 241 6= 0
k=0: a0 = 241 mod 2 = 1, q = 241 div 2 = 120 6= 0
k=1:a1 = 0, q = 60

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Solution.

q = 241 6= 0
k=0: a0 = 241 mod 2 = 1, q = 241 div 2 = 120 6= 0
k=1:a1 = 0, q = 60
k=2:a2 = 0, q = 30

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Solution.

q = 241 6= 0
k=0: a0 = 241 mod 2 = 1, q = 241 div 2 = 120 6= 0
k=1:a1 = 0, q = 60
k=2:a2 = 0, q = 30
k=3:a3 = 0, q = 15

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Solution.

q = 241 6= 0
k=0: a0 = 241 mod 2 = 1, q = 241 div 2 = 120 6= 0
k=1:a1 = 0, q = 60
k=2:a2 = 0, q = 30
k=3:a3 = 0, q = 15
k=4:a4 = 1, q = 7

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Solution.

q = 241 6= 0
k=0: a0 = 241 mod 2 = 1, q = 241 div 2 = 120 6= 0
k=1:a1 = 0, q = 60
k=2:a2 = 0, q = 30
k=3:a3 = 0, q = 15
k=4:a4 = 1, q = 7
k=5:a5 = 1, q = 3

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Solution.

q = 241 6= 0
k=0: a0 = 241 mod 2 = 1, q = 241 div 2 = 120 6= 0
k=1:a1 = 0, q = 60
k=2:a2 = 0, q = 30
k=3:a3 = 0, q = 15
k=4:a4 = 1, q = 7
k=5:a5 = 1, q = 3
k=6:a6 = 1, 1 = 1

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Solution.

q = 241 6= 0
k=0: a0 = 241 mod 2 = 1, q = 241 div 2 = 120 6= 0
k=1:a1 = 0, q = 60
k=2:a2 = 0, q = 30
k=3:a3 = 0, q = 15
k=4:a4 = 1, q = 7
k=5:a5 = 1, q = 3
k=6:a6 = 1, 1 = 1
k=7:a7 = 1, q = 0

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Solution.

q = 241 6= 0
k=0: a0 = 241 mod 2 = 1, q = 241 div 2 = 120 6= 0
k=1:a1 = 0, q = 60
k=2:a2 = 0, q = 30
k=3:a3 = 0, q = 15
k=4:a4 = 1, q = 7
k=5:a5 = 1, q = 3
k=6:a6 = 1, 1 = 1
k=7:a7 = 1, q = 0

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Solution.

q = 241 6= 0
k=0: a0 = 241 mod 2 = 1, q = 241 div 2 = 120 6= 0
k=1:a1 = 0, q = 60
k=2:a2 = 0, q = 30
k=3:a3 = 0, q = 15
k=4:a4 = 1, q = 7
k=5:a5 = 1, q = 3
k=6:a6 = 1, 1 = 1
k=7:a7 = 1, q = 0
→ 11110001,so 241 = (11110001)2

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Quizz

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Quizz

Ans: a

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Quizz

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Quizz

Ans:b

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Binary Operations: Addition


Rules.
0 + 0 = 0, 1 + 0 = 1, 1 + 1 = 0( remind 1)

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Binary Operations: Addition


Rules.
0 + 0 = 0, 1 + 0 = 1, 1 + 1 = 0( remind 1)
Add a = (1110)2 and b = (1011)2

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Binary Operations: Addition


Rules.
0 + 0 = 0, 1 + 0 = 1, 1 + 1 = 0( remind 1)
Add a = (1110)2 and b = (1011)2

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Binary Operations: Addition


Rules.
0 + 0 = 0, 1 + 0 = 1, 1 + 1 = 0( remind 1)
Add a = (1110)2 and b = (1011)2

1 = 0.2 + 1

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Binary Operations: Addition


Rules.
0 + 0 = 0, 1 + 0 = 1, 1 + 1 = 0( remind 1)
Add a = (1110)2 and b = (1011)2

1 = 0.2 + 1
2 = 1.2 + 0

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Binary Operations: Addition


Rules.
0 + 0 = 0, 1 + 0 = 1, 1 + 1 = 0( remind 1)
Add a = (1110)2 and b = (1011)2

1 = 0.2 + 1
2 = 1.2 + 0
2 = 1.2 + 0

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Binary Operations: Addition


Rules.
0 + 0 = 0, 1 + 0 = 1, 1 + 1 = 0( remind 1)
Add a = (1110)2 and b = (1011)2

1 = 0.2 + 1
2 = 1.2 + 0
2 = 1.2 + 0
3 = 1.2 + 1

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Binary Operations: Addition


Rules.
0 + 0 = 0, 1 + 0 = 1, 1 + 1 = 0( remind 1)
Add a = (1110)2 and b = (1011)2

1 = 0.2 + 1
2 = 1.2 + 0
2 = 1.2 + 0
3 = 1.2 + 1
1 = 0.2 + 1

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Binary Operations: Addition


Rules.
0 + 0 = 0, 1 + 0 = 1, 1 + 1 = 0( remind 1)
Add a = (1110)2 and b = (1011)2

1 = 0.2 + 1
2 = 1.2 + 0
2 = 1.2 + 0
3 = 1.2 + 1
1 = 0.2 + 1

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Binary Operations: Addition


Rules.
0 + 0 = 0, 1 + 0 = 1, 1 + 1 = 0( remind 1)
Add a = (1110)2 and b = (1011)2

1 = 0.2 + 1
2 = 1.2 + 0
2 = 1.2 + 0
3 = 1.2 + 1
1 = 0.2 + 1
Thus, (1110)2 + (1011)2 = (11001)2
Lai Văn Phút Chapter 4. Number Theory and Cryptography
The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Binary Operations: Difference

Rules.
• 0−0 = 0

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Binary Operations: Difference

Rules.
• 0−0 = 0
• 1−0 = 1

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Binary Operations: Difference

Rules.
• 0−0 = 0
• 1−0 = 1
• 1−1 = 0

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Binary Operations: Difference

Rules.
• 0−0 = 0
• 1−0 = 1
• 1−1 = 0
• 0 − 1 = 1( remind − 1)

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Binary Operations: Difference

Rules.
• 0−0 = 0
• 1−0 = 1
• 1−1 = 0
• 0 − 1 = 1( remind − 1)
• −1 − 1 = 0( remind − 1)

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Binary Operations: Difference

Rules.
• 0−0 = 0
• 1−0 = 1
• 1−1 = 0
• 0 − 1 = 1( remind − 1)
• −1 − 1 = 0( remind − 1)

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Binary Operations: Difference

Rules.
• 0−0 = 0
• 1−0 = 1
• 1−1 = 0
• 0 − 1 = 1( remind − 1)
• −1 − 1 = 0( remind − 1)
Let a = (1110)2 and b = (1011)2 . Find a − b

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Binary Operations: Difference

Rules.
• 0−0 = 0
• 1−0 = 1
• 1−1 = 0
• 0 − 1 = 1( remind − 1)
• −1 − 1 = 0( remind − 1)
Let a = (1110)2 and b = (1011)2 . Find a − b
(1110)2 − (1011)2 = (11)2

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Binary Operations: Multiplication

Find the product of a = (110)2 and b = (101)2

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Binary Operations: Multiplication

Find the product of a = (110)2 and b = (101)2

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Binary Operations: Multiplication

Find the product of a = (110)2 and b = (101)2

Thus, (110)2 .(101)2 = (11110)2

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Binary Operations: Division

Find quotient and remainder (if exists) in the division of


(100010)2 by (110)2

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Binary Operations: Division

Find quotient and remainder (if exists) in the division of


(100010)2 by (110)2

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Binary Operations: Division

Find quotient and remainder (if exists) in the division of


(100010)2 by (110)2

Thus, the quotient q = 101 and remainder r = 100

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Addition Algorithm

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Addition Algorithm

Example. Find (1110)2 + (1011)2

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Solution

c=0
j = 0 :d = b 0+12+0 c = b0.5c = 0
s0 = 1, c = 0

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Solution

c=0
j = 0 :d = b 0+12+0 c = b0.5c = 0
s0 = 1, c = 0
j = 1 :d = b 1+12+0 c = b1c = 1
s1 = 0, c = 1

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Solution

c=0
j = 0 :d = b 0+12+0 c = b0.5c = 0
s0 = 1, c = 0
j = 1 :d = b 1+12+0 c = b1c = 1
s1 = 0, c = 1
j = 2 :d = 1
s2 = 0, c = 1

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Solution

c=0
j = 0 :d = b 0+12+0 c = b0.5c = 0
s0 = 1, c = 0
j = 1 :d = b 1+12+0 c = b1c = 1
s1 = 0, c = 1
j = 2 :d = 1
s2 = 0, c = 1
j = 3 :d = 1
s3 = 1, c = 1

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Solution

c=0
j = 0 :d = b 0+12+0 c = b0.5c = 0
s0 = 1, c = 0
j = 1 :d = b 1+12+0 c = b1c = 1
s1 = 0, c = 1
j = 2 :d = 1
s2 = 0, c = 1
j = 3 :d = 1
s3 = 1, c = 1
s4 = 1

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Solution

c=0
j = 0 :d = b 0+12+0 c = b0.5c = 0
s0 = 1, c = 0
j = 1 :d = b 1+12+0 c = b1c = 1
s1 = 0, c = 1
j = 2 :d = 1
s2 = 0, c = 1
j = 3 :d = 1
s3 = 1, c = 1
s4 = 1

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Solution

c=0
j = 0 :d = b 0+12+0 c = b0.5c = 0
s0 = 1, c = 0
j = 1 :d = b 1+12+0 c = b1c = 1
s1 = 0, c = 1
j = 2 :d = 1
s2 = 0, c = 1
j = 3 :d = 1
s3 = 1, c = 1
s4 = 1
→ 10011, so the sum is (11001)2

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Multiplication Algorithm

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Multiplication Algorithm

Example. Find the product of (110)2 and (101)2


Lai Văn Phút Chapter 4. Number Theory and Cryptography
The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Solution.

j = 0 : b0 = 1 → c0 =
110

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Solution.

j = 0 : b0 = 1 → c0 =
110
j = 1 : b1 = 0 → c1 =
0000

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Solution.

j = 0 : b0 = 1 → c0 =
110
j = 1 : b1 = 0 → c1 =
0000
j = 2 : b2 = 1 → c2 =
11000

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Solution.

j = 0 : b0 = 1 → c0 =
110
j = 1 : b1 = 0 → c1 =
0000
j = 2 : b2 = 1 → c2 =
11000

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Solution.

p=0
j = 0 : b0 = 1 → c0 =
110 j = 0 : p = 0 + 110 =
110
j = 1 : b1 = 0 → c1 =
0000
j = 2 : b2 = 1 → c2 =
11000

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Solution.

p=0
j = 0 : b0 = 1 → c0 =
110 j = 0 : p = 0 + 110 =
110
j = 1 : b1 = 0 → c1 =
0000 j=1:p=
110 + 0000 = 0110
j = 2 : b2 = 1 → c2 =
11000

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Solution.

p=0
j = 0 : b0 = 1 → c0 =
110 j = 0 : p = 0 + 110 =
110
j = 1 : b1 = 0 → c1 =
0000 j=1:p=
110 + 0000 = 0110
j = 2 : b2 = 1 → c2 =
11000 j=2:p=
0110 + 11000 = 11110

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Solution.

p=0
j = 0 : b0 = 1 → c0 =
110 j = 0 : p = 0 + 110 =
110
j = 1 : b1 = 0 → c1 =
0000 j=1:p=
110 + 0000 = 0110
j = 2 : b2 = 1 → c2 =
11000 j=2:p=
0110 + 11000 = 11110

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Solution.

p=0 →
j = 0 : b0 = 1 → c0 =
110 j = 0 : p = 0 + 110 =
110
j = 1 : b1 = 0 → c1 =
0000 j=1:p=
110 + 0000 = 0110
j = 2 : b2 = 1 → c2 =
11000 j=2:p=
0110 + 11000 = 11110
p = 11110. Hence, the product (11110)2

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Division Algorithm

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Division Algorithm

Example. Find the quotient and the remainder in the


division of 101 by 11

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Solution.

q = 0, r = |101| = 101

r = 101 ≥ 11 = d →
r = 101 − 11 = 90, q =
0+1 = 1

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Solution.

q = 0, r = |101| = 101

r = 101 ≥ 11 = d →
r = 101 − 11 = 90, q =
0+1 = 1
r = 90 ≥ 11 = d →
r = 79, q = 2

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Solution.

q = 0, r = |101| = 101

r = 101 ≥ 11 = d →
r = 101 − 11 = 90, q =
0+1 = 1
r = 90 ≥ 11 = d →
r = 79, q = 2
r = 79 ≥ 11 = d →
r = 61, q = 3

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Solution.

q = 0, r = |101| = 101

r = 101 ≥ 11 = d →
r = 101 − 11 = 90, q =
0+1 = 1
r = 90 ≥ 11 = d →
r = 79, q = 2
r = 79 ≥ 11 = d →
r = 61, q = 3
r = 61 ≥ 11 = d →
r = 57, q = 4

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Solution.

q = 0, r = |101| = 101

r = 101 ≥ 11 = d →
r = 101 − 11 = 90, q =
0+1 = 1
r = 90 ≥ 11 = d →
r = 79, q = 2
r = 79 ≥ 11 = d →
r = 61, q = 3
r = 61 ≥ 11 = d →
r = 57, q = 4
r = 57 ≥ 11 = d →
r = 46, q = 5

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Solution.

q = 0, r = |101| = 101

r = 101 ≥ 11 = d →
r = 101 − 11 = 90, q =
0+1 = 1
r = 90 ≥ 11 = d →
r = 79, q = 2
r = 79 ≥ 11 = d →
r = 61, q = 3
r = 61 ≥ 11 = d →
r = 57, q = 4
r = 57 ≥ 11 = d →
r = 46, q = 5

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Solution.

q = 0, r = |101| = 101

r = 101 ≥ 11 = d → r = 46 ≥ 11 = d →
r = 101 − 11 = 90, q = r = 35, q = 6
0+1 = 1
r = 90 ≥ 11 = d →
r = 79, q = 2
r = 79 ≥ 11 = d →
r = 61, q = 3
r = 61 ≥ 11 = d →
r = 57, q = 4
r = 57 ≥ 11 = d →
r = 46, q = 5

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Solution.

q = 0, r = |101| = 101

r = 101 ≥ 11 = d → r = 46 ≥ 11 = d →
r = 101 − 11 = 90, q = r = 35, q = 6
0+1 = 1 r = 35 ≥ 11 = d →
r = 90 ≥ 11 = d → r = 24, q = 7
r = 79, q = 2
r = 79 ≥ 11 = d →
r = 61, q = 3
r = 61 ≥ 11 = d →
r = 57, q = 4
r = 57 ≥ 11 = d →
r = 46, q = 5

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Solution.

q = 0, r = |101| = 101

r = 101 ≥ 11 = d → r = 46 ≥ 11 = d →
r = 101 − 11 = 90, q = r = 35, q = 6
0+1 = 1 r = 35 ≥ 11 = d →
r = 90 ≥ 11 = d → r = 24, q = 7
r = 79, q = 2 r = 24 ≥ 11 = d →
r = 79 ≥ 11 = d → r = 13, q = 8
r = 61, q = 3
r = 61 ≥ 11 = d →
r = 57, q = 4
r = 57 ≥ 11 = d →
r = 46, q = 5

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Solution.

q = 0, r = |101| = 101

r = 101 ≥ 11 = d → r = 46 ≥ 11 = d →
r = 101 − 11 = 90, q = r = 35, q = 6
0+1 = 1 r = 35 ≥ 11 = d →
r = 90 ≥ 11 = d → r = 24, q = 7
r = 79, q = 2 r = 24 ≥ 11 = d →
r = 79 ≥ 11 = d → r = 13, q = 8
r = 61, q = 3 r = 13 ≥ 11 = d →
r = 61 ≥ 11 = d → r = 2, q = 9
r = 57, q = 4
r = 57 ≥ 11 = d →
r = 46, q = 5

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Solution.

q = 0, r = |101| = 101

r = 101 ≥ 11 = d → r = 46 ≥ 11 = d →
r = 101 − 11 = 90, q = r = 35, q = 6
0+1 = 1 r = 35 ≥ 11 = d →
r = 90 ≥ 11 = d → r = 24, q = 7
r = 79, q = 2 r = 24 ≥ 11 = d →
r = 79 ≥ 11 = d → r = 13, q = 8
r = 61, q = 3 r = 13 ≥ 11 = d →
r = 61 ≥ 11 = d → r = 2, q = 9
r = 57, q = 4 r = 2 ≥ 11 = d(!)
r = 57 ≥ 11 = d →
r = 46, q = 5

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Solution.

q = 0, r = |101| = 101

r = 101 ≥ 11 = d → r = 46 ≥ 11 = d →
r = 101 − 11 = 90, q = r = 35, q = 6
0+1 = 1 r = 35 ≥ 11 = d →
r = 90 ≥ 11 = d → r = 24, q = 7
r = 79, q = 2 r = 24 ≥ 11 = d →
r = 79 ≥ 11 = d → r = 13, q = 8
r = 61, q = 3 r = 13 ≥ 11 = d →
r = 61 ≥ 11 = d → r = 2, q = 9
r = 57, q = 4 r = 2 ≥ 11 = d(!)
r = 57 ≥ 11 = d →
r = 46, q = 5

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Solution.

q = 0, r = |101| = 101

r = 101 ≥ 11 = d → r = 46 ≥ 11 = d →
r = 101 − 11 = 90, q = r = 35, q = 6
0+1 = 1 r = 35 ≥ 11 = d →
r = 90 ≥ 11 = d → r = 24, q = 7
r = 79, q = 2 r = 24 ≥ 11 = d →
r = 79 ≥ 11 = d → r = 13, q = 8
r = 61, q = 3 r = 13 ≥ 11 = d →
r = 61 ≥ 11 = d → r = 2, q = 9
r = 57, q = 4 r = 2 ≥ 11 = d(!)
r = 57 ≥ 11 = d → Hence, (q = 9, r = 2)
r = 46, q = 5

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Modular Exponentiation

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Modular Exponentiation

Example. Find 3644 mod 645

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Solution.
We have b = 3, m = 645, 644 = (1010000100)2

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Solution.
We have b = 3, m = 645, 644 = (1010000100)2
x =1
power = 3 mod 645 = 3
i = 0 : a0 = 0 → x = 1, power = 32 mod 645 = 9

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Solution.
We have b = 3, m = 645, 644 = (1010000100)2
x =1
power = 3 mod 645 = 3
i = 0 : a0 = 0 → x = 1, power = 32 mod 645 = 9
i = 1 : a1 = 0 → x = 1, power = 92 mod 645 = 81

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Solution.
We have b = 3, m = 645, 644 = (1010000100)2
x =1
power = 3 mod 645 = 3
i = 0 : a0 = 0 → x = 1, power = 32 mod 645 = 9
i = 1 : a1 = 0 → x = 1, power = 92 mod 645 = 81
i = 2 : a2 = 1 → x = 1.81 mod 645 = 81, power =
812 mod 645 = 111

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Solution.
We have b = 3, m = 645, 644 = (1010000100)2
x =1
power = 3 mod 645 = 3
i = 0 : a0 = 0 → x = 1, power = 32 mod 645 = 9
i = 1 : a1 = 0 → x = 1, power = 92 mod 645 = 81
i = 2 : a2 = 1 → x = 1.81 mod 645 = 81, power =
812 mod 645 = 111
i = 3 : a3 = 0 → x = 81, power = 1112 mod 645 = 66

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Solution.
We have b = 3, m = 645, 644 = (1010000100)2
x =1
power = 3 mod 645 = 3
i = 0 : a0 = 0 → x = 1, power = 32 mod 645 = 9
i = 1 : a1 = 0 → x = 1, power = 92 mod 645 = 81
i = 2 : a2 = 1 → x = 1.81 mod 645 = 81, power =
812 mod 645 = 111
i = 3 : a3 = 0 → x = 81, power = 1112 mod 645 = 66
i = 4 : a4 = 0 → x = 81, power = 662 mod 645 = 486

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Solution.
We have b = 3, m = 645, 644 = (1010000100)2
x =1
power = 3 mod 645 = 3
i = 0 : a0 = 0 → x = 1, power = 32 mod 645 = 9
i = 1 : a1 = 0 → x = 1, power = 92 mod 645 = 81
i = 2 : a2 = 1 → x = 1.81 mod 645 = 81, power =
812 mod 645 = 111
i = 3 : a3 = 0 → x = 81, power = 1112 mod 645 = 66
i = 4 : a4 = 0 → x = 81, power = 662 mod 645 = 486
i = 5 : a5 = 0 → x = 81, power = 4862 mod 645 = 126

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Solution.
We have b = 3, m = 645, 644 = (1010000100)2
x =1
power = 3 mod 645 = 3
i = 0 : a0 = 0 → x = 1, power = 32 mod 645 = 9
i = 1 : a1 = 0 → x = 1, power = 92 mod 645 = 81
i = 2 : a2 = 1 → x = 1.81 mod 645 = 81, power =
812 mod 645 = 111
i = 3 : a3 = 0 → x = 81, power = 1112 mod 645 = 66
i = 4 : a4 = 0 → x = 81, power = 662 mod 645 = 486
i = 5 : a5 = 0 → x = 81, power = 4862 mod 645 = 126
i = 6 : a6 = 0 → x = 81, power = 1262 mod 645 = 396

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Solution.
We have b = 3, m = 645, 644 = (1010000100)2
x =1
power = 3 mod 645 = 3
i = 0 : a0 = 0 → x = 1, power = 32 mod 645 = 9
i = 1 : a1 = 0 → x = 1, power = 92 mod 645 = 81
i = 2 : a2 = 1 → x = 1.81 mod 645 = 81, power =
812 mod 645 = 111
i = 3 : a3 = 0 → x = 81, power = 1112 mod 645 = 66
i = 4 : a4 = 0 → x = 81, power = 662 mod 645 = 486
i = 5 : a5 = 0 → x = 81, power = 4862 mod 645 = 126
i = 6 : a6 = 0 → x = 81, power = 1262 mod 645 = 396
i = 7 : a7 = 1 → x = (81.396) mod 645 = 471, power =
3962 mod 645 = 81

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Solution.
We have b = 3, m = 645, 644 = (1010000100)2
x =1
power = 3 mod 645 = 3
i = 0 : a0 = 0 → x = 1, power = 32 mod 645 = 9
i = 1 : a1 = 0 → x = 1, power = 92 mod 645 = 81
i = 2 : a2 = 1 → x = 1.81 mod 645 = 81, power =
812 mod 645 = 111
i = 3 : a3 = 0 → x = 81, power = 1112 mod 645 = 66
i = 4 : a4 = 0 → x = 81, power = 662 mod 645 = 486
i = 5 : a5 = 0 → x = 81, power = 4862 mod 645 = 126
i = 6 : a6 = 0 → x = 81, power = 1262 mod 645 = 396
i = 7 : a7 = 1 → x = (81.396) mod 645 = 471, power =
3962 mod 645 = 81
i = 8 : a8 = 0 → x = 471, power = 812 mod 645 = 111
Lai Văn Phút Chapter 4. Number Theory and Cryptography
The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Solution.

i = 9 : a9 = 1 → x = (471.111) mod 645 = 36, power =


1112 mod 645 = 66

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Solution.

i = 9 : a9 = 1 → x = (471.111) mod 645 = 36, power =


1112 mod 645 = 66

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Solution.

i = 9 : a9 = 1 → x = (471.111) mod 645 = 36, power =


1112 mod 645 = 66
→ x = 36. Hence, 3644 mod 645 = 36

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Primes

Definition.
• A positive integer p greater than 1 is called prime (số
nguyên tố) if the only positive factors (ước số) are 1
and p.

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Primes

Definition.
• A positive integer p greater than 1 is called prime (số
nguyên tố) if the only positive factors (ước số) are 1
and p.
• A positive integer that is greater than 1 and is not
prime is called composite (hợp số).

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Example.

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

The fundamental theorem of arithmetic (ĐL cơ


bản của số học)

Every positive integer greater than 1 can be written


uniquely as a prime or as the product of two or more
primes where the prime factors are written in order of
nondecreasing size.

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

The fundamental theorem of arithmetic (ĐL cơ


bản của số học)

Every positive integer greater than 1 can be written


uniquely as a prime or as the product of two or more
primes where the prime factors are written in order of
nondecreasing size.
Examples. Find the prime factorizations of 100, 999, and
1024.

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

The fundamental theorem of arithmetic (ĐL cơ


bản của số học)

Every positive integer greater than 1 can be written


uniquely as a prime or as the product of two or more
primes where the prime factors are written in order of
nondecreasing size.
Examples. Find the prime factorizations of 100, 999, and
1024.
Solution.
100 = 22 .52

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

The fundamental theorem of arithmetic (ĐL cơ


bản của số học)

Every positive integer greater than 1 can be written


uniquely as a prime or as the product of two or more
primes where the prime factors are written in order of
nondecreasing size.
Examples. Find the prime factorizations of 100, 999, and
1024.
Solution.
100 = 22 .52
999 = 33 .37

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

The fundamental theorem of arithmetic (ĐL cơ


bản của số học)

Every positive integer greater than 1 can be written


uniquely as a prime or as the product of two or more
primes where the prime factors are written in order of
nondecreasing size.
Examples. Find the prime factorizations of 100, 999, and
1024.
Solution.
100 = 22 .52
999 = 33 .37
1024 = 210

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Theorem

If n is a composite integer, then n has a


√prime divisor
(ước nguyên tố) less than or equal to n.

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Theorem

If n is a composite integer, then n has a


√prime divisor
(ước nguyên tố) less than or equal to n.

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Theorem

If n is a composite integer, then n has a


√prime divisor
(ước nguyên tố) less than or equal to n.
Examples.
1. Show that 101 is prime.

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Theorem

If n is a composite integer, then n has a


√prime divisor
(ước nguyên tố) less than or equal to n.
Examples.
1. Show that 101 is prime.
2. Find the prime factorization of 7007.

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Solutions.

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Solutions.

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Theorem

1. There are infinite many primes.

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Theorem

1. There are infinite many primes.


2. (The prime number theorem)The ratio of π (x ), the
number of primes not exceeding x and x/lnx
approaches 1 and grows with bound ( lnx: natural
logarithm of x).

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Greatest Common Divisors


Definition. Let a, b be integers, not both zero. The largest
integer d such that d|a and d|b is called the greatest
common divisor (ước chung lớn nhất) of a and b.
Notation. gcd (a, b)

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Greatest Common Divisors


Definition. Let a, b be integers, not both zero. The largest
integer d such that d|a and d|b is called the greatest
common divisor (ước chung lớn nhất) of a and b.
Notation. gcd (a, b)
To find gcd (a, b):

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Greatest Common Divisors


Definition. Let a, b be integers, not both zero. The largest
integer d such that d|a and d|b is called the greatest
common divisor (ước chung lớn nhất) of a and b.
Notation. gcd (a, b)
To find gcd (a, b):

Examples.
1. gcd (24, 36)

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Greatest Common Divisors


Definition. Let a, b be integers, not both zero. The largest
integer d such that d|a and d|b is called the greatest
common divisor (ước chung lớn nhất) of a and b.
Notation. gcd (a, b)
To find gcd (a, b):

Examples.
1. gcd (24, 36)

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Greatest Common Divisors


Definition. Let a, b be integers, not both zero. The largest
integer d such that d|a and d|b is called the greatest
common divisor (ước chung lớn nhất) of a and b.
Notation. gcd (a, b)
To find gcd (a, b):

Examples.
1. gcd (24, 36)→ gcd (24, 36) = 12
2. gcd (17, 22)
Lai Văn Phút Chapter 4. Number Theory and Cryptography
The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Greatest Common Divisors


Definition. Let a, b be integers, not both zero. The largest
integer d such that d|a and d|b is called the greatest
common divisor (ước chung lớn nhất) of a and b.
Notation. gcd (a, b)
To find gcd (a, b):

Examples.
1. gcd (24, 36)→ gcd (24, 36) = 12
2. gcd (17, 22)
Lai Văn Phút Chapter 4. Number Theory and Cryptography
The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Greatest Common Divisors


Definition. Let a, b be integers, not both zero. The largest
integer d such that d|a and d|b is called the greatest
common divisor (ước chung lớn nhất) of a and b.
Notation. gcd (a, b)
To find gcd (a, b):

Examples.
1. gcd (24, 36)→ gcd (24, 36) = 12
2. gcd (17, 22)→ gcd (17, 22) = 1
Lai Văn Phút Chapter 4. Number Theory and Cryptography
The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Definition.

• The integers a, b are relatively prime (nguyên tố cùng


nhau) if their greatest common divisor is 1

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Definition.

• The integers a, b are relatively prime (nguyên tố cùng


nhau) if their greatest common divisor is 1
• The integers a1 , a2 , a3 , . . . , an are pairwise relatively
prime (đôi 1 nguyên tố cùng nhau) if gcd (ai , aj ) = 1
whenever 1 ≤ i < j ≤ n

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Definition.

• The integers a, b are relatively prime (nguyên tố cùng


nhau) if their greatest common divisor is 1
• The integers a1 , a2 , a3 , . . . , an are pairwise relatively
prime (đôi 1 nguyên tố cùng nhau) if gcd (ai , aj ) = 1
whenever 1 ≤ i < j ≤ n

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Definition.

• The integers a, b are relatively prime (nguyên tố cùng


nhau) if their greatest common divisor is 1
• The integers a1 , a2 , a3 , . . . , an are pairwise relatively
prime (đôi 1 nguyên tố cùng nhau) if gcd (ai , aj ) = 1
whenever 1 ≤ i < j ≤ n
Examples. Show that
7, 10, 11, 17, 23 are pairwise relatively prime.

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Definition.

• The integers a, b are relatively prime (nguyên tố cùng


nhau) if their greatest common divisor is 1
• The integers a1 , a2 , a3 , . . . , an are pairwise relatively
prime (đôi 1 nguyên tố cùng nhau) if gcd (ai , aj ) = 1
whenever 1 ≤ i < j ≤ n
Examples. Show that
7, 10, 11, 17, 23 are pairwise relatively prime.
17, 22 are relative prime.

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

The Least common multiple


Definition. The Least common multiple (bội chung nhỏ
nhất) of the positive integer a and b is the smallest integer
that is divisible by both a and b.
Notation. lcm(a, b)

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

The Least common multiple


Definition. The Least common multiple (bội chung nhỏ
nhất) of the positive integer a and b is the smallest integer
that is divisible by both a and b.
Notation. lcm(a, b)
To find lcm(a, b):

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

The Least common multiple


Definition. The Least common multiple (bội chung nhỏ
nhất) of the positive integer a and b is the smallest integer
that is divisible by both a and b.
Notation. lcm(a, b)
To find lcm(a, b):

Examples.
1. lcm(12, 36)

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

The Least common multiple


Definition. The Least common multiple (bội chung nhỏ
nhất) of the positive integer a and b is the smallest integer
that is divisible by both a and b.
Notation. lcm(a, b)
To find lcm(a, b):

Examples.
1. lcm(12, 36)

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

The Least common multiple


Definition. The Least common multiple (bội chung nhỏ
nhất) of the positive integer a and b is the smallest integer
that is divisible by both a and b.
Notation. lcm(a, b)
To find lcm(a, b):

Examples.
1. lcm(12, 36)→ lcm(12, 36) = 36
2. lcm(7, 17)
Lai Văn Phút Chapter 4. Number Theory and Cryptography
The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

The Least common multiple


Definition. The Least common multiple (bội chung nhỏ
nhất) of the positive integer a and b is the smallest integer
that is divisible by both a and b.
Notation. lcm(a, b)
To find lcm(a, b):

Examples.
1. lcm(12, 36)→ lcm(12, 36) = 36
2. lcm(7, 17)
Lai Văn Phút Chapter 4. Number Theory and Cryptography
The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

The Least common multiple


Definition. The Least common multiple (bội chung nhỏ
nhất) of the positive integer a and b is the smallest integer
that is divisible by both a and b.
Notation. lcm(a, b)
To find lcm(a, b):

Examples.
1. lcm(12, 36)→ lcm(12, 36) = 36
2. lcm(7, 17)→ lcm(7, 17) = 119
Lai Văn Phút Chapter 4. Number Theory and Cryptography
The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Theorem

Let a, b be positive integers then


ab = gcd (a, b).lcm(a, b)

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Theorem

Let a, b be positive integers then


ab = gcd (a, b).lcm(a, b)
Example. gcd(8, 12) = 4, lcm(8,12)=24 → 8.12 = 4.24

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

The Euclidean Algorithm

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

The Euclidean Algorithm

Example. Find gcd (24, 36)

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Solution.

x = 24
y = 36
y = 36 6= 0 : r = 24 mod 36 = 24, x = 36, y = 24

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Solution.

x = 24
y = 36
y = 36 6= 0 : r = 24 mod 36 = 24, x = 36, y = 24
y = 24 6= 0 : r = 36 mod 24 = 12, x = 24, y = 12

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Solution.

x = 24
y = 36
y = 36 6= 0 : r = 24 mod 36 = 24, x = 36, y = 24
y = 24 6= 0 : r = 36 mod 24 = 12, x = 24, y = 12
y = 12 6= 0 : r = 24 mod 12 = 0, x = 12, y = 0

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Solution.

x = 24
y = 36
y = 36 6= 0 : r = 24 mod 36 = 24, x = 36, y = 24
y = 24 6= 0 : r = 36 mod 24 = 12, x = 24, y = 12
y = 12 6= 0 : r = 24 mod 12 = 0, x = 12, y = 0
y = 0 6 = 0( ! )

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Solution.

x = 24
y = 36
y = 36 6= 0 : r = 24 mod 36 = 24, x = 36, y = 24
y = 24 6= 0 : r = 36 mod 24 = 12, x = 24, y = 12
y = 12 6= 0 : r = 24 mod 12 = 0, x = 12, y = 0
y = 0 6 = 0( ! )

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Solution.

x = 24
y = 36
y = 36 6= 0 : r = 24 mod 36 = 24, x = 36, y = 24
y = 24 6= 0 : r = 36 mod 24 = 12, x = 24, y = 12
y = 12 6= 0 : r = 24 mod 12 = 0, x = 12, y = 0
y = 0 6 = 0( ! )
→ return 12. Hence, gcd (24, 36) = 12

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Euler ϕ-function

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Euler ϕ-function

Example. Find ϕ(10) and ϕ(100)

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Quizz

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Quizz

Ans: b

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Quizz

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Quizz

Ans: a

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

The Integers and Division

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

The Integers and Division

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

The Integers and Division

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

The Integers and Division

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Primes and Greatest Common Divisors

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Primes and Greatest Common Divisors

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Integers and Algorithms

Lai Văn Phút Chapter 4. Number Theory and Cryptography


The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems

Integers and Algorithms

Lai Văn Phút Chapter 4. Number Theory and Cryptography

You might also like