0% found this document useful (0 votes)
45 views

DS Lecture-10 Num TH

The document provides an overview of number theory concepts including divisibility, modular arithmetic, primes, greatest common divisors, and the Euclidean algorithm. It defines key terms like division, congruence, prime numbers, and discusses algorithms for finding factors, primes, and greatest common divisors.

Uploaded by

Zara
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
45 views

DS Lecture-10 Num TH

The document provides an overview of number theory concepts including divisibility, modular arithmetic, primes, greatest common divisors, and the Euclidean algorithm. It defines key terms like division, congruence, prime numbers, and discusses algorithms for finding factors, primes, and greatest common divisors.

Uploaded by

Zara
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 34

DISCRETE STRUCTURES

Overview of Lecture
Number theory (Chap 4)
• Divisibility & Modular Arithmetic
• Primes & Greatest Common Divisors
• The Sieve of Eratosthenes
• The Eucledian algorithm
SECTION 4.1 DIVISIBILITY AND
MODULAR ARITHMETIC

• Division
• Division algorithm
• Modular arithmetic
• Arithmatic modulo m
Number Theory

Study of the set of integers and their properties is known as number theory.
Division

Definition
1. If a and b are integers with a = 0, we say that a divides b if there is an integer c
such that b = ac, or equivalently, if is an integer.
2. When a divides b we say that a is a factor or divisor of b, and that b is a multiple
of a.
3. The notation a | b denotes that a divides b. We write a | b when a does not divide
b.
Basic Properties Of Divisibility

• Let a, b, and c be integers, where a = 0. Then


(i) if a | b and a | c, then a | (b + c)
(ii) if a | b, then a | bc for all integers c
(iii) if a | b and b | c, then a | c.
Division Algorithm

• Let a be an integer and d a positive integer. Then there are unique integers q and
r, with 0 ≤ r ≤ d such that

a = dq + r
• In the above division algorithm, d is called the divisor, a is called the dividend, q
is called the quotient, and r is called the remainder. This notation is used to
express the quotient and remainder:
q = a div d, r = a mod d.
Division Algorithm

• Example: What are the quotient and remainder when −11 is divided by 3?
Division Algorithm

• Example: What are the quotient and remainder when −11 is divided by 3?
• Solution: We have
−11 = 3(−4) + 1.
Hence, the quotient when −11 is divided by 3 is −4 = −11 div 3, and the remainder is 1 = −11 mod
3.

• Example: Can we use -2 as remainder because


−11 = 3(−3) − 2
Division Algorithm

• Solution:
No. Because remainder cannot be negative. Consequently, the remainder is not −2, even though
−11 = 3(−3) − 2
because r = −2 does not satisfy 0 ≤ r < 3
Modular Arithmetic- Congruence

• If a and b are integers and m is a positive integer, then


a is congruent to b modulo m, if m divides a − b.
• Notation: a ≡ b (mod m)
• We say that a ≡ b (mod m) is a congruence and that m is its modulus.
• If a and b are not congruent modulo m, we write a ≡ b (mod m).
Modular Arithmetic-Theorem 1

• Let a and b be integers, and let m be a positive integer.

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


• Example: Determine whether 17 is congruent to 5 modulo 6 and whether 24 and
14 are congruent modulo 6.
Modular Arithmetic-Theorem 2
• Let m be a positive integer.
If a ≡ b (mod m) and c ≡ d (mod m), then
1. a + c ≡ b + d (mod m)
2. ac ≡ bd (mod m).
• Example:
Because 7 ≡ 2 (mod 5) and 11 ≡ 1 (mod 5), it follows from this theorem that
1. 18 = 7 + 11 ≡ 2 + 1 = 3 (mod 5)
2. 77 = 7 · 11 ≡ 2 · 1 = 2 (mod 5).
Arithmetic Modulo m

• We can define Arithmetic operations on Zm, the set of nonnegative integers less than m, that is, the set

{0, 1,...,m − 1}.


• We define addition of these integers, denoted by +m by

a +m b = (a + b) mod m

and we define multiplication of these integers, denoted by .m by

a .m b = (a · b) mod m
• The operations +m and .m are called addition and multiplication modulo m and when we use these
operations, we are said to be doing arithmetic modulo m.
Arithmetic Modulo m

• Example: Use the definition of addition and multiplication in Zm or Z11 to find

7 +11 9 and 7 .11 9.


Arithmetic Modulo m

• Example: Use the definition of addition and multiplication in Zm to find 7 +11 9 and

7 .11 9.

• Solution:
Using the definition of addition modulo 11, we find that
7 +11 9 = (7 + 9) mod 11 = 16 mod 11 = 5

and by definition by of multiplication we find that


7 .11 9 = (7 · 9) mod 11 = 63 mod 11 = 8.

Hence 7 +11 9 = 5 and 7 .11 9 = 8.


Arithmetic Modulo m
Activity

1. Does 17 divide each of these numbers? a) 68 b) 84 c) 357 d) 1001


2. Show that if a | b and b | a, where a and b are integers, then a = b or a = −b.
3. What are the quotient and remainder when
a) 19 is divided by 7?
b) −111 is divided by 11?

4. What time does a 12-hour clock read a) 80 hours after it reads 11:00? b) 40 hours before it reads
12:00? c) 100 hours after it reads 6:00?
SECTION 4.3 PRIMES AND
GREATEST COMMON DIVISORS

• Primes
• Trial division
• The Sieve of Erstosthenes
• GCD
• Pairwise relatively prime
• The Eucledian algorithm
Primes

• A prime is an integer greater than 1 that is divisible by no positive integers other than 1
and itself.
• A positive integer that is greater than 1 and is not prime is called composite.
• Example:
The integer 7 is prime because its only positive factors are 1 and 7, whereas the integer 9
is composite because it is divisible by 3.
The Fundamental Theorem Of Arithmetic

• Every 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 non-decreasing
size.
• Example: The prime factorizations of 100, 641, 999, and 1024 are given by
100 = 2 · 2 · 5 · 5 = 22 52
641 = 641
999 = 3 · 3 · 3 · 37 = 33 · 37
1024 = 2 · 2 · 2 · 2 · 2 · 2 · 2 · 2 · 2 · 2 = 210
TRIAL DIVISION

• It is often important to show that a given integer is prime. For instance, in


cryptology, large primes are used in some methods for making messages secret.
One procedure for showing that an integer is prime is based on the following
observation

Show that 101 is prime


Sieve Of Eratosthenes

It is a simple and efficient algorithm for finding all prime numbers up to a given limit. The
algorithm :
• Create a list of all numbers from 2 to the given limit.
• Start with the first number in the list (2) and mark it as prime.
• For each multiple of the current prime number (2), mark it as composite (i.e., not prime).
• Move to the next unmarked number in the list and repeat steps 2-3 until all numbers have been
processed.
• At the end of the algorithm, all unmarked numbers in the list are prime. This is because any
number that is composite (not prime) has already been marked as such by its prime factors.
Sieve Of Eratosthenes
Greatest Common Divisors

• Let a and b be integers, not both zero.


• The largest integer d such that d | a and d | b is called the greatest common divisor of a and b.
The greatest common divisor of a and b is denoted by gcd(a, b).
• Example1 : What is the greatest common divisor of 24 and 36?
• Solution: The positive common divisors of 24 and 36 are 1, 2, 3, 4, 6, and 12. Hence, gcd(24, 36)
= 12.
• Example 2: What is the greatest common divisor of 17 and 22?
Greatest Common Divisors
Relatively Prime

• The integers a and b are relatively prime if their greatest common divisor is 1.
• The integers a1, a2,...,an are pairwise relatively prime if gcd(ai, aj ) = 1
• Example: Determine whether the integers 10, 17, and 21 are pairwise relatively prime and
whether the integers 10, 19, and 24 are pairwise relatively prime.
• Solution:
Because gcd(10, 17) = 1, gcd(10, 21) = 1, and gcd(17, 21) = 1, we conclude that 10, 17, and
21 are pairwise relatively prime.
Because gcd(10, 24) = 2 > 1, we see that 10, 19, and 24 are not pairwise relatively prime.
GCD-Prime Factorization

• Another way to find the gcd of two positive integers is to use the prime
factorizations of these integers.
• Example: Because the prime factorizations of 120 and 500 are
120 = 2 · 2 · 2 · 3 · 5 and 500 = 2 · 2 · 5 · 5 · 5
the greatest common divisor is
gcd(120, 500) = 2min(3,2) 3min(1,0) 5min(1,3) = 22 30 51 = 20
GCD- Euclidean Algorithm

The Euclidean algorithm is a way to find the greatest common divisor of two
positive integers.
• Basic Euclidean Algorithm for GCD:
The algorithm is based on the below facts.
If we subtract a smaller number from a larger one (we reduce a larger number),
GCD doesn’t change. So if we keep subtracting repeatedly the larger of two, we
end up with GCD.
Now instead of subtraction, if we divide the smaller number, the algorithm
stops when we find the remainder 0.
Euclidean Algorithm
Find the greatest common divisor of 414 and 662 using the Euclidean algorithm.
Solution:
Successive uses of the division algorithm give:
662 = 414 · 1 + 248
414 = 248 · 1 + 166
248 = 166 · 1 + 82
166 = 82 · 2 + 2
82 = 2 · 41.
Hence, gcd(414, 662) = 2, because 2 is the last nonzero remainder
Activity
1. Determine whether each of these integers is prime.
a) 21 b) 29 c) 71 d) 97
2. Find the prime factorization of each of these integers.
b) 88 b) 126 c) 729
3. Determine whether the integers in each of these sets are pairwise relatively prime.
c) 11, 15, 19 b) 14, 15, 21 c) 12, 17, 31, 37 d) 7, 8, 9, 11
• Find gcd(1000, 625) and lcm(1000, 625) and verify that gcd(1000, 625) ⋅ lcm(1000, 625) = 1000
⋅ 625
Thank you

You might also like