CSCI 1900 Discrete Structures

Slides:



Advertisements
Similar presentations
Copyright © Cengage Learning. All rights reserved. CHAPTER 5 SEQUENCES, MATHEMATICAL INDUCTION, AND RECURSION SEQUENCES, MATHEMATICAL INDUCTION, AND RECURSION.
Advertisements

Study Guides Quantitative - Arithmetic - Numbers, Divisibility Test, HCF and LCM Mycatstudy.com.
5.1 Number Theory. The study of numbers and their properties. The numbers we use to count are called the Natural Numbers or Counting Numbers.
Sets, Combinatorics, Probability, and Number Theory Mathematical Structures for Computer Science Chapter 3 Copyright © 2006 W.H. Freeman & Co.MSCS Slides.
1 Section 2.4 The Integers and Division. 2 Number Theory Branch of mathematics that includes (among other things): –divisibility –greatest common divisor.
Section 5-4 Greatest Common Factor and Least Common Multiple.
Chapter Primes and Greatest Common Divisors ‒Primes ‒Greatest common divisors and least common multiples 1.
February 19, 2015Applied Discrete Mathematics Week 4: Number Theory 1 The Growth of Functions Question: If f(x) is O(x 2 ), is it also O(x 3 )? Yes. x.
Copyright © 2013, 2010, and 2007, Pearson Education, Inc.
CSC2110 Discrete Mathematics Tutorial 5 GCD and Modular Arithmetic
Discrete Structures Chapter 2 Part B Mathematical Induction
1 Section 2.5 Integers and Algorithms. 2 Euclidean algorithm for finding gcd Where L is a larger number, and S is a smaller number, to find gcd(L,S):
Mathematics of Cryptography Part I: Modular Arithmetic, Congruence,
Division in the Integers Theorem 1. If n and m are integers and n>0, then m=qn+r for unique integers q and r with 0
Properties of the Integers: Mathematical Induction
WHOLE NUMBERS; INTEGERS Whole numbers: Z 0,+ = the natural numbers  {0}. Integers:
Fall 2002CMSC Discrete Structures1 Let us get into… Number Theory.
Chapter Number Theory 4 4 Copyright © 2013, 2010, and 2007, Pearson Education, Inc.
Quiz 2 key.
Mathematics of Cryptography Part I: Modular Arithmetic, Congruence,
Integers Number Theory = Properties of Integers
Chapter 2 The Fundamentals: Algorithms, the Integers, and Matrices
1 Properties of Integers Objectives At the end of this unit, students should be able to: State the division algorithm Apply the division algorithm Find.
9/2/2015Discrete Structures1 Let us get into… Number Theory.
Slide 5-1 Copyright © 2005 Pearson Education, Inc. SEVENTH EDITION and EXPANDED SEVENTH EDITION.
Quantitative - Arithmetic - Numbers, Divisibility Test, HCF and LCM
(CSC 102) Discrete Structures Lecture 10.
© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Sixth Edition, Mc Graw-Hill, 2007 Chapter 3 (Part 3): The Fundamentals: Algorithms, the.
Mathematics of Cryptography Part I: Modular Arithmetic
February 24, 2015Applied Discrete Mathematics Week 4: Number Theory 1 Modular Arithmetic Let a be an integer and m be a positive integer. We denote by.
3.4/3.5 The Integers and Division/ Primes and Greatest Common Divisors Let each of a and b be integers. We say that a divides b, in symbols a | b, provided.
Module :MA3036NI Cryptography and Number Theory Lecture Week 7
Number Theory.  A prime number is a natural number greater than 1 that has exactly two factors (or divisors), itself and 1.  Prime numbers less than.
The Integers & Division. a divides b if a is not zero there is a m such that a.m = b “a is a factor of b” “b is a multiple of a” a|b Division.
WIKIPEDIA HAS MANY MORE DIVISIBILITY RULES. EXAMPLE Since 52=13(4) is divisible by 4, is divisible by 4 Since 452=56(8)+4 is not divisible.
The Integers. The Division Algorithms A high-school question: Compute 58/17. We can write 58 as 58 = 3 (17) + 7 This forms illustrates the answer: “3.
CompSci 102 Discrete Math for Computer Science
Copyright © Zeph Grunschlag, Basic Number Theory Zeph Grunschlag.
Copyright © 2009 Pearson Education, Inc. Chapter 5 Section 1 - Slide 1 Chapter 1 Number Theory and the Real Number System.
MA/CSSE 473 Day 06 Euclid's Algorithm. MA/CSSE 473 Day 06 Student Questions Odd Pie Fight Euclid's algorithm (if there is time) extended Euclid's algorithm.
Foundations of Discrete Mathematics Chapter 4 By Dr. Dalia M. Gil, Ph.D.
Module #9 – Number Theory 1/5/ Algorithms, The Integers and Matrices.
Slide Copyright © 2009 Pearson Education, Inc. Unit 1 Number Theory MM-150 SURVEY OF MATHEMATICS – Jody Harris.
Application: Algorithms Lecture 20 Section 3.8 Wed, Feb 21, 2007.
Greatest Common Divisors & Least Common Multiples  Definition 4 Let a and b be integers, not both zero. The largest integer d such that d|a and d|b is.
CSCI 115 Chapter 1 Fundamentals. CSCI 115 §1.1 Sets and Subsets.
Slide Copyright © 2009 Pearson Education, Inc. 5.1 Number Theory.
AF2. Turn off your phones Primes, gcd, some examples, reading.
1 Discrete Structures – CNS2300 Text Discrete Mathematics and Its Applications Kenneth H. Rosen (5 th Edition) Chapter 2 The Fundamentals: Algorithms,
Chapter 4 With Question/Answer Animations 1. Chapter Summary Divisibility and Modular Arithmetic - Sec 4.1 – Lecture 16 Integer Representations and Algorithms.
Ch04-Number Theory and Cryptography 1. Introduction to Number Theory Number theory is about integers and their properties. We will start with the basic.
Module #9 – Number Theory 6/11/20161 Chapter 3 Algorithms, Integers and Matrices.
Number Theory Lecture 1 Text book: Discrete Mathematics and its Applications, 7 th Edition.
Slide Copyright © 2009 Pearson Education, Inc. Slide Copyright © 2009 Pearson Education, Inc. Chapter 1 Number Theory and the Real Number System.
Unit 1 MM 150: Number Theory and the Real Number System Prof. Carolyn Dupee July 3, 2012.
Fuw-Yi Yang1 Textbook: Introduction to Cryptography 2nd ed. By J.A. Buchmann Chap 1 Integers Department of Computer Science and Information Engineering,
Chapter 3 The Fundamentals: Algorithms, the integers, and matrices Section 3.4: The integers and division Number theory: the part of mathematics involving.
Agenda Review:  Relation Properties Lecture Content:  Divisor and Prime Number  Binary, Octal, Hexadecimal Review & Exercise.
Number Theory. Introduction to Number Theory Number theory is about integers and their properties. We will start with the basic principles of divisibility,
The Euclidean Algorithm
MA/CSSE 473 Day 06 Euclid's Algorithm.
CMSC Discrete Structures
CSE 504 Discrete Mathematics & Foundations of Computer Science
MATH301- DISCRETE MATHEMATICS Copyright © Nahid Sultana Dr. Nahid Sultana Chapter 4: Number Theory and Cryptography.
Applied Discrete Mathematics Week 4: Number Theory
Foundations of Discrete Mathematics
The Integers & Division
CMSC 203, Section 0401 Discrete Structures Fall 2004 Matt Gaston
Copyright © Zeph Grunschlag,
Divisibility and Modular Arithmetic
Presentation transcript:

CSCI 1900 Discrete Structures Integers Reading: Kolman, Section 1.4

Divisibility If one integer, n, divides into a second integer, m, without producing a remainder, then we say that “n divides m”. Denoted n | m If one integer, n, does not divide evenly into a second integer, m, i.e., mn produces a remainder, then we say that “n does not divide m”

Some Properties of Divisibility If n | m, then there exists a q such that m = qn The absolute values of both q and n are less than the absolute value of m, i.e., |n| < |m| and |q| < |m| Examples: 4 | 24: 24 = 46 and both 4 and 6 are less than 24. 5 | 135: 135 = 527 and both 5 and 27 are less than 135 Simple properties of divisibility (proofs on page 21) If a | b and a | c, then a | (b + c) If a | b and a | c, where b > c, then a | (b - c) If a | b or a | c, then a | bc If a | b and b | c, then a | c

Prime Numbers A number p is called prime if the only positive integers that divide p are p and 1. Examples of prime numbers: 2, 3, 5, 7, 11, and 13. There is a science to determining prime numbers. The following slides present some computer algorithms that can be used to determine if a number n>1 is prime.

Basic Primer Number Algorithm First, check if n=2. If it is, n is prime. Otherwise, proceed to step 2. Check to see if each integer k is a divisor of n where 1<k<(n-1). If none of the values of k are divisors of n, then n is prime

Better Prime Number Algorithm Note that if n=mk, then either m or k is less than n. Therefore, we don't need to check for values of k greater than n. First check if n=2. If it is, n is prime. Otherwise, proceed to step 2. Check to see if each integer k is a divisor of n where 1<k<n. If none of the values of k are divisors of n, then n is prime

Even Better Prime Number Algorithm Note that if k | n, and k is even, then 2 | n. Therefore, if 2 does not divide n, then no even number can be a divisor of n. (If a | b and b | c, then a | c) First check if n=2. If it is, n is prime. Otherwise, proceed to step 2. Check if 2 | n. If so, n is not prime. Otherwise, proceed to step 3. Check to see if each odd integer k is a divisor of n where 1<k<n. If none of the values of k are divisors of n, then n is prime.

Even2 Better Prime Number Algorithm Note that if k | n, and d | k, then d | n. Therefore, if d does not divide n, then no multiple of d can be a divisor of n. First check if n=2. If it is, n is prime. Otherwise, proceed to step 2. Use a sequence k = 2, 3, 5, 7, 11, 13, 17, … up to n to check if k | n. If none are the values of k are divisors of n, then n is prime. (Note that list is a list of prime numbers!)

Factoring a Number into its Primes Dividing a number into its multiples over and over again until the multiples cannot be divided any longer shows us that any number can eventually be broken down into prime numbers. Examples: 9 = 33 = 32 24 = 83 = 2223 = 233 315 = 3105 = 3335 = 3357 = 3257 Basically, this means that any number can be broken into multiples of prime numbers.

Factoring into Primes (continued) Each row of the table below presents a different number factored into its primes. The numbers in the columns represent the number of each particular prime can be factored out of each original value. 2 3 5 7 11 13 17 540 1 85 96 315

Factoring into Primes (continued) Every positive integer n > 1 can be broken into multiples of prime numbers. n = p1k1p2k2p3k3p4k4 …psks p1 < p2 < p3 < p4 < …< ps

Methods for Factoring 2 | n  If least significant digit of n is divisible by 2 (i.e., n is even), then 2 divides n 3 | n  If the sum of all the digits of n down to a single digit equals 3, 6, or 9, then 3 divides n. For example, is 17,587,623 divisible by 3? 1 + 7 + 5 + 8 + 7 + 6 + 2 + 3 = 39 3 + 9 = 12 1 + 2 = 3  YES! 3 divides 17,587,623

Methods for Factoring (continued) Does 7 divide n? Remove least significant digit (one’s place) from n and multiply it by two. Subtract the doubled number from the remaining digits. If result is divisible by 7, then original number was divisible by 7 Repeat if unable to determine from result.

Methods for Factoring (continued) Examples of checking for divisibility by 7 1,876  187 – 12 = 175  17 – 10 = 7  4,923  492 – 6 = 486  48 – 12 = 36  34,461  3,446 – 2 = 3,444  344 – 8 = 336  33 – 12 = 21 

Methods for Factoring (continued) Does 11 divide n? Starting with the most significant digit of n, adding the first digit, subtracting the next digit, adding the third digit, subtracting the fourth, and so on. If the result is 0 or a multiple of 11, then the original number is divisible by 11. Repeat if unable to determine from result.

Methods for factoring (continued) Examples of checking for divisibility by 11 285311670611  2 – 8 + 5 – 3 + 1 – 1 + 6 – 7 + 0 – 6 + 1 – 1 = –11  279048  2 – 7 + 9 – 0 + 4 – 8 = 0 

Methods for Factoring (continued) Does 13 divide n? Delete the last digit (one’s place) from n. Subtract nine times the deleted digit from the remaining number. If what is left is divisible by 13, then so is the original number. Repeat if unable to determine from result.

General Observation of Integers If n and m are integers and n > 0, we can write m = qn + r for integers q and r with 0 < r < n. For specific integers m and n, there is only one set of values for q and for r. If r = 0, then m is a multiple of n, i.e., n | m.

Examples of m = qn + r If n is 3 and m is 16, then 16 = 5(3) + 1 so q = 5 and r = 1 If n is 10 and m is 3, then 3 = 0(10) + 3 so q = 0 and r = 3 If n is 5 and m is –11, then – 11 = – 3(5) + 4 so q = – 3 and r = 4

Greatest Common Divisor If a, b, and k are in Z+, and k | a and k | b, we say that k is a common divisor. If d is the largest such k, d is called the greatest common divisor (GCD). d is a multiple of every k, i.e., every k divides d.

GCD Example Find the GCD of 540 and 315: 540 = 22  33  5 315 = 32  5  7 540 and 315 share the divisors 3, 32, 5, 35, and 325 (Look at it as the number of possible ways to combine 3, 3, and 5) The largest is the GCD  325 = 45 31545 = 7 and 54045=12

Theorems of the GCD Assume d is GCD(a, b) d = sa + tb for some integers s and t. (s and t are not necessarily positive.) If c is any other common divisor of a and b, then c | d If d is the GCD(a, b), then d | a and d | b Assume d is the GCD(a, b). If c | a and c | b, then c | d There is a horrendous proof of these theorems on page 22 of our textbook. You are not responsible for this proof!

GCD Theorem If a and b are in Z+, a>b, then GCD(a,b) = GCD(a, a+b) If c divides a and b, it divides a+b (this is from the earlier “divides” theorems) Since b = a-(a-b) = -a+(a+b), then a common divisor of a and (a+b) also divides a and b Since all c that divide a or b must also divide b and b+a, then they have the same complete set of divisors and therefore the same GCD.

Euclidean Algorithm The Euclidean Algorithm is a recursive algorithm that can be used to find GCD (a, b) It is based on the fact that for any two integers, a > b, there exists a k and r such that: a = kb + r Since if a | b and a | c, then a | (b + c), then we know that the GCD (a,b) must also divide r. Therefore, the GCD (a,b) = GCD(b,r)

Euclidean Algorithm Process For two integers a and b where a > b > 0 a = k1b + r1, where k1 is in Z+ and 0 < r1 < b If r1 = 0, then b | a and b the is GCD(a, b) If r1  0, then if some integer n divides a and b, then it must also divide r1. Similarly, if n divides b and r1, then it must divide a. Go back to top substituting b for a and r1 for b. Repeat until rn = 0 and kn will be GCD

Least Common Multiple If a, b, and k are in Z+, and a | k, b | k, we say that k is a common multiple of a and b. The smallest such k, call it c, is called the least common multiple or LCM of a and b We write c = LCM(a,b)

Deriving the LCM We can obtain LCM from a, b, and GCD(a,b) For any integers a and b, we can write a = p1a1 p2a2 …pkak and b = p1b1 p2b2 …pkbk GCD(a,b) = p1min(a1,b1) p2min(a2,b2) …pkmin(ak,bk) LCM(a,b) = p1max(a1,b1) p2max(a2,b2) …pkmax(ak,bk) Since, GCD(a,b)LCM(a,b) = p1(a1+b1) p2(a2+b2) …pk(ak+bk) = p1a1 p1b1 p2a2 p2b2 …pkak pkbk = ab Therefore, LCM(a,b) = ab/GCD(a,b)

Mod-n function If z is a nonnegative integer, the mod-n function, fn(z), is defined as fn(z) = r if z = qn + r For example: f3(14) = 2 because 14 = 43 + 2 f7(153) = 6 because 153 = 217 + 6

Representation of integers We are used to decimal, but in reality, it is only one of many ways to describe an integer We say that a decimal value is the “base 10 expansion of n” or the “decimal expansion of n” If b>1 is an integer, then every positive integer n can be uniquely expressed in the form: n = dkbk + dk-1bk-1 + dk-2bk-2 + … + d1b1 + d0b0 where 0 < di < b, i = 0, 1, …, k

Proof that There is Exactly One Base Expansion Proof is on bottom of page 27 Basis of proof is that n = dkbk + r If dk > bk, then k was not the largest non-negative integer so that bk < n. If r > bk, then dk isn’t large enough Go back to 1 replacing n with r. This time, remember that k = k-1, because r must be less than bk Repeat until k=0.

Quick way to determine base b expansion of n Note that d0 is the remainder after dividing n by b. Note also that once n is divided by b, quotient is made up of: (n-r)/b = (dkbk-1 dk-1bk-2+ dk-2bk-3+ … + d1) Therefore, we can go back to step 1 to determine d1

Example: Determine base 5 expansion of decimal 432 432 = 86*5 + 2 (remainder is d0 digit) 86 = 17*5 + 1 (remainder is d1 digit) 17 = 3*5 + 2 (remainder is d2 digit) 3 = 0*5 + 3 (remainder is d3 digit) 43210 = 32125 Verify this using powers of 5 expansion: 32125 = 353 + 252 + 151 + 250 = 3125 + 225 + 15 + 21 = 375 + 50 + 5 + 2 = 423

Example: Determine base 8 expansion of decimal 704 704 = 88*8 + 0 (remainder is d0 digit) 88 = 11*8 + 0 (remainder is d1 digit) 11 = 1*8 + 3 (remainder is d2 digit) 1 = 0*8 + 1 (remainder is d3 digit) 70410 = 13008 Verify this using powers of 8 expansion: 32125 = 183 + 382 + 081 + 080 = 1512 + 364 + 08 + 01 = 512 + 192 = 70410