AF2. Turn off your phones Primes, gcd, some examples, reading.

Slides:



Advertisements
Similar presentations
The Fundamental Theorem of Arithmetic. Primes p > 1 is prime if the only positive factors are 1 and p if p is not prime it is composite The Fundamental.
Advertisements

CS 202 Epp section ?? Aaron Bloomfield
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.
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.
1 Section 2.4 The Integers and Division. 2 Number Theory Branch of mathematics that includes (among other things): –divisibility –greatest common divisor.
Chapter Primes and Greatest Common Divisors ‒Primes ‒Greatest common divisors and least common multiples 1.
22C:19 Discrete Math Integers and Modular Arithmetic Fall 2010 Sukumar Ghosh.
Elementary Number Theory and Methods of Proof. Basic Definitions An integer n is an even number if there exists an integer k such that n = 2k. An integer.
CSE115/ENGR160 Discrete Mathematics 03/17/11 Ming-Hsuan Yang UC Merced 1.
CSE 321 Discrete Structures Winter 2008 Lecture 8 Number Theory: Modular Arithmetic.
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):
1 Integers and Division CS/APMA 202 Rosen section 2.4 Aaron Bloomfield.
WHOLE NUMBERS; INTEGERS Whole numbers: Z 0,+ = the natural numbers  {0}. Integers:
Fall 2002CMSC Discrete Structures1 Let us get into… Number Theory.
Quiz 2 key.
CSCI 1900 Discrete Structures
© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Sixth Edition, Mc Graw-Hill, 2007 Chapter 3 (Part 2): The Fundamentals: Algorithms, the.
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.
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
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.
COMP 170 L2 Page 1 L05: Inverses and GCDs l Objective: n When does have an inverse? n How to compute the inverse? n Need: Greatest common dividers (GCDs)
MATH 224 – Discrete Mathematics
Module :MA3036NI Cryptography and Number Theory Lecture Week 7
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.
1 Introduction to Abstract Mathematics Chapter 3: Elementary Number Theory and Methods of Proofs Instructor: Hayk Melikya Direct.
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.
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.
Chapter Integers and Algorithms Representations of integers
Chapter 2 (Part 1): The Fundamentals: Algorithms, the Integers & Matrices The Integers and Division (Section 2.4)
CSE 311: Foundations of Computing Fall 2014 Lecture 12: Primes, GCD.
Module #9 – Number Theory 1/5/ Algorithms, The Integers and Matrices.
Internet Engineering Czesław Smutnicki Discrete Mathematics – Numbers Theory.
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.
Week 4 - Wednesday.  What did we talk about last time?  Finished DES  AES.
CSE 311: Foundations of Computing Fall 2013 Lecture 12: Primes, GCD, modular inverse.
1 Discrete Structures – CNS2300 Text Discrete Mathematics and Its Applications Kenneth H. Rosen (5 th Edition) Chapter 2 The Fundamentals: Algorithms,
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,
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.
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,
Number-Theoretic Algorithms
Lecture 4 The Euclidean Algorithm
CS 210 Discrete Mathematics The Integers and Division (Section 3.4)
MA/CSSE 473 Day 06 Euclid's Algorithm.
MA/CSSE 473 Day 06 Euclid's Algorithm.
Integers and Division Section 3.4.
CMSC Discrete Structures
CSE 504 Discrete Mathematics & Foundations of Computer Science
Number Theory (Chapter 7)
Foundations of Discrete Mathematics
Week #5 – 23/25/27 September 2002 Prof. Marie desJardins
The Integers & Division
CMSC 203, Section 0401 Discrete Structures Fall 2004 Matt Gaston
Copyright © Zeph Grunschlag,
Divisibility and Modular Arithmetic
Presentation transcript:

AF2

Turn off your phones

Primes, gcd, some examples, reading

Primes p>1 is prime if the only positive factors are 1 and p if p is not prime it is composite The Fundamental Theorem of Arithmetic Every positive integer can be expressed as a unique product of primes

How many prime numbers are there? Is there a largest prime number? assume we know all the prime numbers let p be the largest prime multiply all the primes together add 1 call this n n is not divisible by 2, we get remainder 1 n is not divisible by 3, we get remainder 1 n is not divisible by 5, we get remainder 1 … n is not divisible by p, we get remainder 1 But, by the FTA we know n has a prime factorisation Therefore n must have a prime divisor > p Therefore there is no greatest prime Due to Euclid

PRIMES Therefore, the divisor a or b is either prime or due to the fundamental theorem of arithmetic, can be expressed as a product of primes

How big a prime do we want? for RSA encryption “The most efficient factorisation methods (1999) require billions of years to factor 400 digit integers. Consequently … when 200 digit primes … messages encrypted … cannot be found in a reasonable time.” “When new factorisation techniques are found … it will be necessary to use larger primes to ensure secrecy/security of messages.”

gcd, a geometric view We have a floor to tile The floor is 57 units wide and 152 units long What is the largest square tile we can use to tile the floor this will be the least number of square tiles!

57 19 gcd, a geometric view Find gcd(57,152) 19 is the answer we need 24 tiles

Theorem  when a = b.q + r  greatest common divisor of a and b is also  greatest common divisor of b and r  i.e. gcd(a,b) = gcd(b,r)

A proof follows The proof is based on what we already know about division

RTP: gcd(a,b) = gcd(b,r) where a = b.q + r Sketch of the proof Show that common divisors of a and b are also common divisors of b and r (1) show that if some d|a and d|b then d|r (2) show that if some d|b and d|r then d|a (3) conclude that a common divisor of a and b is also a common divisor of b and r (4) consequently gcd(a,b) = gcd(b,r)

RTP: gcd(a,b) = gcd(b,r) where a = b.q + r (1) show that if some d|a and d|b then d|r a = b.q + r  a - b.q = r We have already proved that if d|b then d|b.q if d|a and d|b.q then d|(a - b.q) (a – b.q) = r  d|r Consequently a common divisor of a and b also divides r

RTP: gcd(a,b) = gcd(b,r) where a = b.q + r (2) show that if some d|b and d|r then d|a a = b.q + r We have already proved that if d|b then d|b.q if d|b.q and d|r then d|(b.q + r) (b.q + r) = a  d|a Consequently a common divisor of b and r also divides a

RTP: gcd(a,b) = gcd(b,r) where a = b.q + r (3) conclude that a common divisor of a and b is also a common divisor of b and r From (1) and (2) we have proved that P a common divisor of a and b is also a divisor of r P a common divisor of b and r is also a divisor of a P consequently a common divisor of a and b is also a common divisor of b and r

RTP: gcd(a,b) = gcd(b,r) where a = b.q + r (4) consequently gcd(a,b) = gcd(b,r) From (3) we can conclude that the greatest common divisor of a and b is also a greatest common divisor of b and r

This suggests an algorithm  given a and b  if a = 0 then b is the gcd  if b = 0 then a is the gcd  otherwise  a  b = q remainder r  we have established that we can substitute  gcd(a,b) with gcd(b,r)  now compute gcd(b,r)  note, r is decreasing!

gcd(a,b) if b = 0 then a else gcd(b,a mod b) gcd(a,b) while b  0 do begin r := a mod b; a := b; b := r; end; a (0) gcd(a,b) (1) if b = 0 goto 6 (2) let r := a mod b (3) a := b (4) b := r (5) goto (1) (6) return(a)

[gcd(a:integer,b:integer) : integer -> if (b = 0) a else gcd(b,a mod b)] [relativePrime(a:integer,b:integer) : boolean -> gcd(a,b) = 1] Try gcd(414,662) and then gcd(662,414) gcd(120,500) and gcd(500,120) list all numbers relative prime to 22

I invented an algorithm more than 2200 years before anyone build a computer

New topic Numbers But I guess you already know this stuff so I will be fast

Numbers A number to the base b it has k+1 terms the a’s are all in the range 0 to b-1 what is base 2 in base 10 peter base 26 in base 10

Numbers what is base 2 in base 10 peter base 26 in base 10

Numbers Hexadecimal: to the base 16 Use digits 0 to 9 then A, B, C, D, E, and F Octal: base 8

Convert from one base to another (b) Given the number n, divide it by b to get a new number and a remainder The remainder is the least significant digit. Now repeat the process The remainder is then the second least significant digit Keep going

Convert from one base to another (b) Find the binary expansion of

Adding numbers Assume our numbers are held in arrays and the least significant digit is on the left hand side with index 0 This is the “old school” way of doing it NOTE: pseudo code!

A thought, challenge How does a computer read in integers? We assume that characters are read in one by one If on the input stream we have the sequence/string “23189” read() will deliver “2” and the next read() will deliver “3”, and the next “1”

Numbers  Can you do arithmetic in different bases?  I expect so  Can you do addition, multiplication, subtraction, division  in different bases? (I expect so)  Do you know the algorithm for this?  Again, I expect so. Are these fair assumptions?