LECTURE 5 Learning Objectives  To apply division algorithm  To apply the Euclidean algorithm.

Slides:



Advertisements
Similar presentations
MAT 320 Spring 2011 Section = 276 · = 44 · = 12 · = 8 · = 4 ·2 + 0 Start by dividing the smaller number into.
Advertisements

Cryptography and Network Security
Prime and Composite Numbers
Section 4.1: Primes, Factorization, and the Euclidean Algorithm Practice HW (not to hand in) From Barr Text p. 160 # 6, 7, 8, 11, 12, 13.
Study Guides Quantitative - Arithmetic - Numbers, Divisibility Test, HCF and LCM Mycatstudy.com.
Thinking Mathematically
Decimals and Fractions
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.
Thinking Mathematically
1 Section 2.4 The Integers and Division. 2 Number Theory Branch of mathematics that includes (among other things): –divisibility –greatest common divisor.
Definition of a Prime Number
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.
Greatest Common Divisor. Definitions Let a and b be two non-zero integers. The greatest common divisor of a and b, denoted gcd(a,b) is the largest of.
Fractions and Rational Expressions
Factors, Fractions, and Exponents
Chapter II. THE INTEGERS
Number Theory Divides: b divides a if there is a whole number q such that a = qb. Factor: b will be a factor of a. Divisor: b is also a divisor of a. Multiple:
Mathematics of Cryptography Part I: Modular Arithmetic, Congruence,
Fall 2002CMSC Discrete Structures1 Let us get into… Number Theory.
BY MISS FARAH ADIBAH ADNAN IMK
Multiples If a number divides exactly into another number, the second is a multiple of the first. Example 3, 6, 9, 12, 15, 18 10, 12, 14, 16, 18, 20 are.
Least Common Multiple (LCM)
The Integers and Division
Mathematics of Cryptography Part I: Modular Arithmetic, Congruence,
Highest Common Factors & Lowest common Multiples 9Y4 Tuesday 30 th November 2004.
Chapter Number Theory 4 4 Copyright © 2013, 2010, and 2007, Pearson Education, Inc.
CSCI 1900 Discrete Structures
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.
Quantitative - Arithmetic - Numbers, Divisibility Test, HCF and LCM
© 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
CPSC 3730 Cryptography and Network Security
Numbers MST101. Number Types 1.Counting Numbers (natural numbers) 2.Whole Numbers 3.Fractions – represented by a pair of whole numbers a/b where b ≠ 0.
Prerequisites: Fundamental Concepts of Algebra
Factors
Factors and Multiples. Definition of Factors and Multiples If one number is a factor of a second number or divides the second (as 3 is a factor of 12),
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.
5.1 Divisibility. Natural Numbers The set of natural numbers or counting numbers is {1,2,3,4,5,6,…}
Data Security and Encryption (CSE348) 1. Lecture # 12 2.
Copyright © Zeph Grunschlag, Basic Number Theory Zeph Grunschlag.
Factoring using GCF interpret parts of an expressions such as terms, factors, and coefficient.
Rational Numbers and Fields
MAT 320 Spring 2008 Section 1.2.  Start with two integers for which you want to find the GCD. Apply the division algorithm, dividing the smaller number.
Factors Prime Factors Multiples Common Factors and Highest Common Factor (HCF) Factors and Multiples Common Multiples and Lowest Common Multiple (LCM)
Math 409/409G History of Mathematics Books VII – IX of the Elements Part 1: Divisibility.
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.
Application: Algorithms Lecture 19 Section 3.8 Tue, Feb 20, 2007.
Slide Copyright © 2009 Pearson Education, Inc. 5.1 Number Theory.
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.
Number Theory: Prime and Composite Numbers
Number Theory Lecture 1 Text book: Discrete Mathematics and its Applications, 7 th Edition.
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,
Factors
Integers and Division Section 3.4.
Thinking Critically 4.1 Divisibility Of Natural Numbers
MATH301- DISCRETE MATHEMATICS Copyright © Nahid Sultana Dr. Nahid Sultana Chapter 4: Number Theory and Cryptography.
Applied Discrete Mathematics Week 4: Number Theory
Repetition and Loop Statements
Prime Factorization Course
L.C.M (Lowest Common Multiple) & G.C.F (Greatest Common Factor)
Copyright © 2013, 2010, and 2007, Pearson Education, Inc.
Copyright © Zeph Grunschlag,
Application: Algorithms
Applied Discrete Mathematics Week 10: Introduction to Counting
Presentation transcript:

LECTURE 5 Learning Objectives  To apply division algorithm  To apply the Euclidean algorithm

Algorithms An algorithm is a systematic procedures (instructions) for calculation. Algorithms are basic to computer programs. Essentially, a program implements one or more algorithms. Therefore, algorithmic complexity is important. In this Lecture, we will study a few algorithms: Division algorithm Euclidean algorithm Primality testing

Activity 1 Card RMIT University; Taylor's College Card Card Card Pick a integer between 0 to 15 Is it on Card A? Is it on Card B? Is it on Card C? Is it on Card D?

Activity 2 Write a set of instructions (algorithms) to write all the integers from 0 to 10. RMIT University; Taylor's College

Algorithm example 1 RMIT University; Taylor's College

The Division Algorithm

RMIT University; Taylor's College Algorithms

RMIT University; Taylor's College The Division Algorithm

If a > 0, then (floor of a/b) Example: a = 31, b = 7 So a = bq + r gives 31 = 7 ∙ Given a, b: Valid input requires a, b to be integers and b > 0

The Euclidean Algorithm

Factors (or Divisors) and Multiple

Common Factor Let m, n be positive integers. A positive integer q is a common factor or common divisor of m and n if it divides (is a divisor, or factor, of) both of them Examples: 1. What is the common factor for 16 and What is the common factor for 15 and 30

Common Multiple A positive integer p is a common multiple of m and n if it is a multiple of both of them Examples: 1. Which of the following is the common multiple of 3 and 6? Which of the following is the common multiple of 4 and 9? RMIT University; Taylor's College

Greatest Common Divisor (GCD) Let m, n be positive integers. The GCD (greatest common divisor) of m and n is the greatest number which is a common divisor of both of them It’s also called the highest common factor or HCF

Example 1 What is the GCD of 18 and 24? gcd (18, 24) = 6 ? There is a systematic procedure for getting the GCD. It’s the Euclidean algorithm.

Least Common Multiple Given integers m and n, their least common multiple (LCM) is the smallest number which is a multiple of them both Examples: 1. What is the LCM of 8 and 6? 2. What is the LCM of 3 and 4? The least common multiple of 2 positive integers equals their product divided by their greatest common divisor

Euclidean Algorithm We can get the gcd by using the Euclidean algorithm. This involves repeated application of the division algorithm: a = bq + r Euclidean Algorithm When the remainder becomes zero, we look back to the previous remainder, r n+1. This must be the gcd of a and b.

Example 2 RMIT University; Taylor's College gcd (96, 22) = ? 96 = 4 ∙ = 2 ∙ = 1 ∙ = 3 ∙ 2 The last nonzero remainder was 2. Therefore, gcd (96, 22) = 2. No remainder

Example 3 RMIT University; Taylor's College gcd (63, 256) = ? 256 = 4 ∙ = 15 ∙ = 1 ∙ = 3 ∙ 1 The last nonzero remainder was 1. Therefore, gcd (63, 256) = 1. No remainder

Extension to the Euclidean Algorithm If d = gcd(m, n) then d can be expressed as a linear combination d = xm + yn of m and n, where x and y are integers To find x and y, we work back through the steps of the Euclidean algorithm from bottom to top

Example 4 It can be shown that gcd(22, 96) = 2: 96 = 4 ∙ = 2 ∙ = 1 ∙ = 3 ∙ 2 Now we want to express 2 as a linear combination 2 = x(22) + y(96). We use the second-last line to make 2 the subject of the equation: 2 = 8 – 1 ∙ 6 Next we use the third-last line to express 6 in terms of 22 and 8, substituting this into the equation we’ve just produced: 2 = 8 – 1 ∙ 6 = 8 – 1 ∙ (22 – 2 ∙ 8) = 8 – 1 ∙ ∙ 2 ∙ 8 = 3 ∙ 8 – 1 ∙ 22

Example 4 (cont.) Finally we use the fourth-last line to express 8 in terms of 96 and 22, substitution this into our most recent equation 2 = 3 ∙ 8 – 1 ∙ 22 2= 3 ∙ (96 – 4 ∙ 22) – 1 ∙ 22 2= 3 ∙ 96 – 3 ∙ 4 ∙ 22 – 1 ∙ 22 2= 3 ∙ 96 – 13 ∙ 22 x=3, y=-4

Example 5 It can be shown that the gcd of 63 and 256 equals 1: 256 = 4 ∙ = 15 ∙ = 1 ∙ = 3 ∙ 1 Then we work upwards from the second-last line, as follows: 1 = ∙ 3 = 4 – 1 ∙ (63 – 15 ∙ 4) = ∙ ∙ 15 ∙ 4 = 16 ∙ 4 – 1 ∙ 63 = 16 ∙ (256 – 4 ∙ 63) – 1 ∙ 63 = 16 ∙ 256 – 64 ∙ ∙ 63 = 16 ∙ 256 – 65 ∙ 63 So 1 = 16 ∙ 256 – 65 ∙ 63. In this example, 63 and 256 are relatively prime.

Prime Numbers A prime number is an integer ≥ 2 which has no factors except itself and 1 Prime numbers: 2, 3, 5, 7, … Prime numbers play a vital role in coding and cryptography We say two positive integers are relatively prime (in relation to each other) if their gcd equals 1 So 63 and 256 are relatively prime (to each other), even though neither of them is a prime number RMIT University; Taylor's College

accessed 1 st September 2009 BBC News (online) dated 5 th December 2001

Prime Number

Activity 3 Write down the first ten prime numbers

The End

RMIT University; Taylor's College

Prime Number