Arithmetic Algorithms, Part 1
|
|
- Hugo Henry
- 5 years ago
- Views:
Transcription
1 Arithmetic Algorithms, Part 1 DPV Chapter 1 Jim Royer EECS January 18, 2019 Royer Arithmetic Algorithms, Part 1 1/ 15
2 Multiplication à la Français function multiply(a, b) // input: two n-bit integers a and b with b 0 // output: a b if b = 0 then return 0 c multiply(a, b/2 ) if b is even then return (2 c) else return (a + 2 c) Correctness A proof by induction on b. Base Case: b = 0. Then multiply(a, b) = 0, which is correct. Induction Step: b > 0. (IH = Induction Hypothesis) IH: multiply(a, b ) = a b for b = 0,..., b 1. By the IH, c = a b/2 Case: b is even. Then: Case: b is odd. Then: (2 c) = 2 (a (b/2)) = a (2 (b/2)). = a b. (a + 2 c) = a + 2 (a b/2 ) = a (2 b/2 + 1) = a b. Royer Arithmetic Algorithms, Part 1 2/ 15
3 Multiplication à la Français, Continued function multiply(a, b) // input: two n-bit integers a and b with b 0 // output: a b if b = 0 then return 0 c multiply(a, b/2 ) if b is even then return (2 c) else return (a + 2 c) Run-time analysis n recursive calls (b drops by 1-bit in each call). O(n) cost of each step on the recursion. n O(n) = O(n 2 ). (Why?) Royer Arithmetic Algorithms, Part 1 3/ 15
4 Division Correctness Case a = 0:... Case a even and > 0:... Case a odd:... function divide(a,b) // input: two n-bit integers a and b with a 0 and b > 0 // output: (q, r) where a = q b + r and 0 r < b if a = 0 then return (0, 0) (q, r ) divide( a/2, b) q 2 q r 2 r if a is odd then r r + 1 if r b then r r b; q q + 1 return (q, r) Run-time analysis: Homework problem. On the board. On the board. Exercise for the reader. Royer Arithmetic Algorithms, Part 1 4/ 15
5 Arithmetic Algorithms, Part 1 Division Division function divide(a,b) // input: two n-bit integers a and b with a 0 and b > 0 // output: (q, r) where a = q b + r and 0 r < b if a = 0 then return (0, 0) (q, r ) divide( a/2, b) q 2 q r 2 r if a is odd then r r + 1 if r b then r r b; q q + 1 return (q, r) Correctness Case a = 0:... On the board. Case a even and > 0:... On the board. Case a odd:... Exercise for the reader. Run-time analysis: Homework problem. Case a = 0. Then q = r = 0 and a = 0 = 0 b + 0 = q b + r and 0 = r b. Case a > 0 and a is even. Then q = 2q and r = 2r where (q, r ) = divide( a/2, b). IH: For a { 0,..., a 1 }, (q, r ) = divide(a, b) is such that a = q b + r and 0 r < b. Since a/2 < a, the IH applies with a = a/2. Hence, a/2 = q b + r and 0 r < b. Since 2 a/2 = a, a = 2 a/2 = 2q b + 2r and 0 2r < 2b SUBCASE: 2r < b: Then q = 2q and r = 2r and we are done. SUBCASE: 2r b: Then q = 2q + 1 and r = 2r b and we are done.
6 Modular Arithmetic Definition Suppose a, b, N N. (i) a b def a divides b, i.e., b = k a for some k N. (ii) a b (mod N) def N (a b) a b = k N for some integer k. The substitution rule Suppose a a (mod N) and b b (mod N). Then a + b a + b (mod N) and a b a b (mod N). Modular addition, subtraction, and multiplication Suppose N is n bits long and 0 a, b < N. Then computing (a + b) mod N and (a b) mod N can be done in Θ(n) time. (a b) mod N can be done in Θ(n 2 ) time. Royer Arithmetic Algorithms, Part 1 5/ 15
7 Modular Exponentiation Exponentiation via repeated squaring 1, if b = 0; a b = (a b/2 ) 2, if b > 0 and even; a (a b/2 ) 2, if b is odd. function modexp(a, b, N) // input: a, b, and N :: three n-bit integers // with 0 a, b and 1 < N // output: a b mod N if b = 0 then return 1 c modexp(a, b/2, N) if b is even then return c 2 mod N else return (a c 2 ) mod N Example: x 1000 via 15 multiplies x 1000 = (x 500 ) 2 x 500 = (x 250 ) 2 x 250 = x (x 125 ) 2 x 125 = x (x 62 ) 2 x 62 = (x 31 ) 2 x 31 = x (x 15 ) 2 x 15 = x (x 7 ) 2 x 7 = x (x 3 ) 2 x 3 = x (x) 2 Royer Arithmetic Algorithms, Part 1 6/ 15
8 Modular Exponentiation, Continued function modexp(a, b, N) // input: a, b, and N :: three n-bit integers with 0 a, b and 1 < N // output: a b mod N if b = 0 then return 1 c modexp(a, b/2, N) if b is even then return c 2 mod N else return (a c 2 ) mod N Correctness: Easy. Runtime: Let n = the number of bits in max(a, b, N). At most n-many recursive calls. Why? In each call, two or three n-bit numbers are multiplied at cost Θ(n 2 ). n Θ(n 2 ) = Θ(n 3 ). Why? Royer Arithmetic Algorithms, Part 1 7/ 15
9 Euclid s algorithm for greatest common divisor Definition The greatest common divisor of a and b N is the largest d N such that d divides both a and b. I.E.: gcd(a, b) = max { d d a & d b }. Example 1035 = & 759 = gcd(1035, 759) = 3 23 = 69. For a > 0, gcd(0, a) = a. gcd(0, 0) = 0 by convention. Euclid s Rule Suppose a, b N +. Then gcd(a, b) = gcd(b, a mod b). Proof on next page Royer Arithmetic Algorithms, Part 1 8/ 15
10 Euclid s Rule: Suppose a, b N +. Then gcd(a, b) = gcd(b, a mod b). Proof. Recall: gcd(u, v) = def max({ d d u & d v }). Claim 1. If d a & d b, then ( x, y Z) [ d (x a + y b) ]. [Proof on Board] Observe: (a) a = a b b + 1 (a mod b) (b) a mod b = 1 a + ( a b ) b By (a) & Claim 1, gcd(b, a mod b) a. Since gcd(b, a mod b) b, we have: gcd(b, a mod b) gcd(a, b). (Why?) By (b) & Claim 1, gcd(a, b) (a mod b). Since gcd(a, b) b, we have: gcd(a, b) gcd(b, a mod b). (Why?) gcd(a, b) = gcd(b, a mod b). Royer Arithmetic Algorithms, Part 1 9/ 15
11 Euclid s algorithm, continued Euclid s Rule Suppose a, b N +. Then gcd(a, b) = gcd(b, a mod b). function Euclid(a, b) // Input: integers a and b with a b 0. // Output: the g.c.d. of a and b. if b = 0 then return a else return Euclid(b, a mod b). Correctness. Easy. Royer Arithmetic Algorithms, Part 1 10/ 15
12 Euclid s algorithm, Runtime analysis function Euclid(a, b) // Input: integers a and b with a b 0. Output: the g.c.d. of a and b. if b = 0 then return a else return Euclid(b, a mod b). Lemma Suppose a b > 0. Then (a mod b) < a/2. Proof. Case: b a/2. Then: (a mod b) < b a/2. Case: b > a/2. Then: (a mod b) = (a b) (a a/2) = a/2. Since Euclid(a, b) = Euclid(b, a mod b) = Euclid(a mod b, b mod (a mod b)) (generally), every two steps the a and b values are at least halved. On n-bit numbers, Euclid stops after 2n recursions. On n-bit numbers, mod (i.e., a division) costs O(n 2 ) 2n O(n 2 ) = O(n 3 ). Royer Arithmetic Algorithms, Part 1 11/ 15
13 The extended Euclid algorithm Lemma Suppose d a & d b & d = xa + yb for some x, y Z. Then d = gcd(a, b). Proof. Royer Arithmetic Algorithms, Part 1 12/ 15
14 The extended Euclid algorithm Lemma Suppose d a & d b & d = xa + yb for some x, y Z. Then d = gcd(a, b). Proof. Since d a and d b, then d gcd(a, b). Royer Arithmetic Algorithms, Part 1 12/ 15
15 The extended Euclid algorithm Lemma Suppose d a & d b & d = xa + yb for some x, y Z. Then d = gcd(a, b). Proof. Since d a and d b, then d gcd(a, b). Since gcd(a, b) a & gcd(a, b) b, Royer Arithmetic Algorithms, Part 1 12/ 15
16 The extended Euclid algorithm Lemma Suppose d a & d b & d = xa + yb for some x, y Z. Then d = gcd(a, b). Proof. Since d a and d b, then d gcd(a, b). Since gcd(a, b) a & gcd(a, b) b, then gcd(a, b) (xa + yb), Royer Arithmetic Algorithms, Part 1 12/ 15
17 The extended Euclid algorithm Lemma Suppose d a & d b & d = xa + yb for some x, y Z. Then d = gcd(a, b). Proof. Since d a and d b, then d gcd(a, b). Since gcd(a, b) a & gcd(a, b) b, then gcd(a, b) (xa + yb), i.e., gcd(a, b) d. Royer Arithmetic Algorithms, Part 1 12/ 15
18 The extended Euclid algorithm Lemma Suppose d a & d b & d = xa + yb for some x, y Z. Then d = gcd(a, b). Proof. Since d a and d b, then d gcd(a, b). Since gcd(a, b) a & gcd(a, b) b, then gcd(a, b) (xa + yb), i.e., gcd(a, b) d. Therefore, gcd(a, b) d. Royer Arithmetic Algorithms, Part 1 12/ 15
19 The extended Euclid algorithm Lemma Suppose d a & d b & d = xa + yb for some x, y Z. Then d = gcd(a, b). Proof. Since d a and d b, then d gcd(a, b). Since gcd(a, b) a & gcd(a, b) b, then gcd(a, b) (xa + yb), i.e., gcd(a, b) d. Therefore, gcd(a, b) d. Therefore, d = gcd(a, b). Royer Arithmetic Algorithms, Part 1 12/ 15
20 The extended Euclid algorithm Lemma Suppose d a & d b & d = xa + yb for some x, y Z. Then d = gcd(a, b). Proof. Since d a and d b, then d gcd(a, b). Since gcd(a, b) a & gcd(a, b) b, then gcd(a, b) (xa + yb), i.e., gcd(a, b) d. Therefore, gcd(a, b) d. Therefore, d = gcd(a, b). function extended-euclid(a, b) // Input: integers a and b with a b 0. // Output: (x, y, d) where d = gcd(a, b) and d = xa + yb. if b = 0 then return (1, 0, a). (x, y, d) = extended-euclid(b, a mod b) return (y, x a/b y, d) Royer Arithmetic Algorithms, Part 1 12/ 15
21 The extended Euclid algorithm: Base case function extended-euclid(a, b) // Input: integers a and b with a b 0. // Output: (x, y, d) where d = gcd(a, b) and d = xa + yb. if b = 0 then return (1, 0, a). (x, y, d) = extended-euclid(b, a mod b) return (y, x a/b y, d) Proof of correctness, base case. Base case: b = 0. gcd(a, b) = a & a = 1 a + 0 b. So (1, 0, a) is right. Royer Arithmetic Algorithms, Part 1 13/ 15
22 The extended Euclid algorithm: Induction Step function extended-euclid(a, b) // Input: integers a and b with a b 0. // Output: (x, y, d) where d = gcd(a, b) and d = xa + yb. if b = 0 then return (1, 0, a). (x, y, d) = extended-euclid(b, a mod b) return (y, x a/b y, d) Proof of correctness, induction step. Suppose b > 0. IH: extended-euclid(a, b ) is correct for all a and each b = 0,..., b 1. Royer Arithmetic Algorithms, Part 1 14/ 15
23 The extended Euclid algorithm: Induction Step function extended-euclid(a, b) // Input: integers a and b with a b 0. // Output: (x, y, d) where d = gcd(a, b) and d = xa + yb. if b = 0 then return (1, 0, a). (x, y, d) = extended-euclid(b, a mod b) return (y, x a/b y, d) Proof of correctness, induction step. Suppose b > 0. IH: extended-euclid(a, b ) is correct for all a and each b = 0,..., b 1. Let (x, y, d) = extended-euclid(b, a mod b). Note: a mod b < b. Royer Arithmetic Algorithms, Part 1 14/ 15
24 The extended Euclid algorithm: Induction Step function extended-euclid(a, b) // Input: integers a and b with a b 0. // Output: (x, y, d) where d = gcd(a, b) and d = xa + yb. if b = 0 then return (1, 0, a). (x, y, d) = extended-euclid(b, a mod b) return (y, x a/b y, d) Proof of correctness, induction step. Suppose b > 0. IH: extended-euclid(a, b ) is correct for all a and each b = 0,..., b 1. Let (x, y, d) = extended-euclid(b, a mod b). Note: a mod b < b. So by the IH, gcd(b, a mod b) = d = x b + y (a mod b). Royer Arithmetic Algorithms, Part 1 14/ 15
25 The extended Euclid algorithm: Induction Step function extended-euclid(a, b) // Input: integers a and b with a b 0. // Output: (x, y, d) where d = gcd(a, b) and d = xa + yb. if b = 0 then return (1, 0, a). (x, y, d) = extended-euclid(b, a mod b) return (y, x a/b y, d) Proof of correctness, induction step. Suppose b > 0. IH: extended-euclid(a, b ) is correct for all a and each b = 0,..., b 1. Let (x, y, d) = extended-euclid(b, a mod b). Note: a mod b < b. So by the IH, gcd(b, a mod b) = d = x b + y (a mod b). So d = gcd(a, b). (Why?) Royer Arithmetic Algorithms, Part 1 14/ 15
26 The extended Euclid algorithm: Induction Step function extended-euclid(a, b) // Input: integers a and b with a b 0. // Output: (x, y, d) where d = gcd(a, b) and d = xa + yb. if b = 0 then return (1, 0, a). (x, y, d) = extended-euclid(b, a mod b) return (y, x a/b y, d) Proof of correctness, induction step. Suppose b > 0. IH: extended-euclid(a, b ) is correct for all a and each b = 0,..., b 1. Let (x, y, d) = extended-euclid(b, a mod b). Note: a mod b < b. So by the IH, gcd(b, a mod b) = d = x b + y (a mod b). So d = gcd(a, b). (Why?)... and d = x b + y (a mod b) = x b + y (a a b b) = y a + (x a b y ) b. Royer Arithmetic Algorithms, Part 1 14/ 15
27 Modular division Definition x is the multiplicative inverse of a mod N when a x 1 (mod N). The inverse might not exist! E.g., 2 1 mod 6 does not exist. Theorem (Modular Division Theorem) Suppose N > 2 and a { 1,..., N 1 }. (a) a has an inverse mod N gcd(a, N) = 1. (b) When a 1 mod N exists, (a 1 mod N) = (x mod N), where (x, y, 1) = extended-euclid(a, N) so that 1 = a x + N y. Royer Arithmetic Algorithms, Part 1 15/ 15
Algorithms (II) Yu Yu. Shanghai Jiaotong University
Algorithms (II) Yu Yu Shanghai Jiaotong University Chapter 1. Algorithms with Numbers Two seemingly similar problems Factoring: Given a number N, express it as a product of its prime factors. Primality:
More informationThis is a recursive algorithm. The procedure is guaranteed to terminate, since the second argument decreases each time.
8 Modular Arithmetic We introduce an operator mod. Let d be a positive integer. For c a nonnegative integer, the value c mod d is the remainder when c is divided by d. For example, c mod d = 0 if and only
More informationCSE20: Discrete Mathematics
Spring 2018 Today Greatest Common Divisor (GCD) Euclid s algorithm Proof of Correctness Reading: Chapter 4.3 Primes and GCD Universe: U = N = {0, 1, 2,...} a divides b (written a b) iff k.b = ak Set of
More informationNumber Theory Basics Z = {..., 2, 1, 0, 1, 2,...} For, b Z, we say that divides b if z = b for some. Notation: b Fact: for all, b, c Z:
Number Theory Basics Z = {..., 2, 1, 0, 1, 2,...} For, b Z, we say that divides b if z = b for some z Z Notation: b Fact: for all, b, c Z:, 1, and 0 0 = 0 b and b c = c b and c = (b + c) b and b = ±b 1
More informationHomework 3, solutions
Homework 3, solutions Problem 1. Read the proof of Proposition 1.22 (page 32) in the book. Using simialr method prove that there are infinitely many prime numbers of the form 3n 2. Solution. Note that
More informationAlgorithms CMSC Basic algorithms in Number Theory: Euclid s algorithm and multiplicative inverse
Algorithms CMSC-27200 Basic algorithms in Number Theory: Euclid s algorithm and multiplicative inverse Instructor: László Babai Last updated 02-14-2015. Z denotes the set of integers. All variables in
More information8 Primes and Modular Arithmetic
8 Primes and Modular Arithmetic 8.1 Primes and Factors Over two millennia ago already, people all over the world were considering the properties of numbers. One of the simplest concepts is prime numbers.
More informationCS 5319 Advanced Discrete Structure. Lecture 9: Introduction to Number Theory II
CS 5319 Advanced Discrete Structure Lecture 9: Introduction to Number Theory II Divisibility Outline Greatest Common Divisor Fundamental Theorem of Arithmetic Modular Arithmetic Euler Phi Function RSA
More informationCh 4.2 Divisibility Properties
Ch 4.2 Divisibility Properties - Prime numbers and composite numbers - Procedure for determining whether or not a positive integer is a prime - GCF: procedure for finding gcf (Euclidean Algorithm) - Definition:
More informationCOMP239: Mathematics for Computer Science II. Prof. Chadi Assi EV7.635
COMP239: Mathematics for Computer Science II Prof. Chadi Assi assi@ciise.concordia.ca EV7.635 The Euclidean Algorithm The Euclidean Algorithm Finding the GCD of two numbers using prime factorization is
More informationThe following is an informal description of Euclid s algorithm for finding the greatest common divisor of a pair of numbers:
Divisibility Euclid s algorithm The following is an informal description of Euclid s algorithm for finding the greatest common divisor of a pair of numbers: Divide the smaller number into the larger, and
More informationGreatest Common Divisor MATH Greatest Common Divisor. Benjamin V.C. Collins, James A. Swenson MATH 2730
MATH 2730 Greatest Common Divisor Benjamin V.C. Collins James A. Swenson The world s least necessary definition Definition Let a, b Z, not both zero. The largest integer d such that d a and d b is called
More information5: The Integers (An introduction to Number Theory)
c Oksana Shatalov, Spring 2017 1 5: The Integers (An introduction to Number Theory) The Well Ordering Principle: Every nonempty subset on Z + has a smallest element; that is, if S is a nonempty subset
More informationFinite Fields. Mike Reiter
1 Finite Fields Mike Reiter reiter@cs.unc.edu Based on Chapter 4 of: W. Stallings. Cryptography and Network Security, Principles and Practices. 3 rd Edition, 2003. Groups 2 A group G, is a set G of elements
More informationNOTES ON SIMPLE NUMBER THEORY
NOTES ON SIMPLE NUMBER THEORY DAMIEN PITMAN 1. Definitions & Theorems Definition: We say d divides m iff d is positive integer and m is an integer and there is an integer q such that m = dq. In this case,
More informationCS483 Design and Analysis of Algorithms
CS483 Design and Analysis of Algorithms Lectures 2-3 Algorithms with Numbers Instructor: Fei Li lifei@cs.gmu.edu with subject: CS483 Office hours: STII, Room 443, Friday 4:00pm - 6:00pm or by appointments
More informationBasic elements of number theory
Cryptography Basic elements of number theory Marius Zimand By default all the variables, such as a, b, k, etc., denote integer numbers. Divisibility a 0 divides b if b = a k for some integer k. Notation
More informationBasic elements of number theory
Cryptography Basic elements of number theory Marius Zimand 1 Divisibility, prime numbers By default all the variables, such as a, b, k, etc., denote integer numbers. Divisibility a 0 divides b if b = a
More informationThe Euclidean Algorithm and Multiplicative Inverses
1 The Euclidean Algorithm and Multiplicative Inverses Lecture notes for Access 2009 The Euclidean Algorithm is a set of instructions for finding the greatest common divisor of any two positive integers.
More information2. THE EUCLIDEAN ALGORITHM More ring essentials
2. THE EUCLIDEAN ALGORITHM More ring essentials In this chapter: rings R commutative with 1. An element b R divides a R, or b is a divisor of a, or a is divisible by b, or a is a multiple of b, if there
More informationMathematics for Computer Science Exercises for Week 10
Mathematics for Computer Science Exercises for Week 10 Silvio Capobianco Last update: 7 November 2018 Problems from Section 9.1 Problem 9.1. Prove that a linear combination of linear combinations of integers
More information2 Arithmetic. 2.1 Greatest common divisors. This chapter is about properties of the integers Z = {..., 2, 1, 0, 1, 2,...}.
2 Arithmetic This chapter is about properties of the integers Z = {..., 2, 1, 0, 1, 2,...}. (See [Houston, Chapters 27 & 28]) 2.1 Greatest common divisors Definition 2.16. If a, b are integers, we say
More informationcse 311: foundations of computing Spring 2015 Lecture 12: Primes, GCD, applications
cse 311: foundations of computing Spring 2015 Lecture 12: Primes, GCD, applications casting out 3s Theorem: A positive integer n is divisible by 3 if and only if the sum of its decimal digits is divisible
More informationINTEGERS. In this section we aim to show the following: Goal. Every natural number can be written uniquely as a product of primes.
INTEGERS PETER MAYR (MATH 2001, CU BOULDER) In this section we aim to show the following: Goal. Every natural number can be written uniquely as a product of primes. 1. Divisibility Definition. Let a, b
More informationBasic Algorithms in Number Theory
Basic Algorithms in Number Theory Algorithmic Complexity... 1 Basic Algorithms in Number Theory Francesco Pappalardi #2-b - Euclidean Algorithm. September 2 nd 2015 SEAMS School 2015 Number Theory and
More informationOWO Lecture: Modular Arithmetic with Algorithmic Applications
OWO Lecture: Modular Arithmetic with Algorithmic Applications Martin Otto Winter Term 2008/09 Contents 1 Basic ingredients 1 2 Modular arithmetic 2 2.1 Going in circles.......................... 2 2.2
More informationInverses. Today: finding inverses quickly. Euclid s Algorithm. Runtime. Euclid s Extended Algorithm.
Inverses Today: finding inverses quickly. Euclid s Algorithm. Runtime. Euclid s Extended Algorithm. Refresh Does 2 have an inverse mod 8? No. Does 2 have an inverse mod 9? Yes. 5 2(5) = 10 = 1 mod 9. Does
More informationHomework #2 solutions Due: June 15, 2012
All of the following exercises are based on the material in the handout on integers found on the class website. 1. Find d = gcd(475, 385) and express it as a linear combination of 475 and 385. That is
More informationNumber Theory. CSS322: Security and Cryptography. Sirindhorn International Institute of Technology Thammasat University CSS322. Number Theory.
CSS322: Security and Cryptography Sirindhorn International Institute of Technology Thammasat University Prepared by Steven Gordon on 29 December 2011 CSS322Y11S2L06, Steve/Courses/2011/S2/CSS322/Lectures/number.tex,
More informationIntroduction to Public-Key Cryptosystems:
Introduction to Public-Key Cryptosystems: Technical Underpinnings: RSA and Primality Testing Modes of Encryption for RSA Digital Signatures for RSA 1 RSA Block Encryption / Decryption and Signing Each
More informationInduction. Induction. Induction. Induction. Induction. Induction 2/22/2018
The principle of mathematical induction is a useful tool for proving that a certain predicate is true for all natural numbers. It cannot be used to discover theorems, but only to prove them. If we have
More informationAn Algorithm for Prime Factorization
An Algorithm for Prime Factorization Fact: If a is the smallest number > 1 that divides n, then a is prime. Proof: By contradiction. (Left to the reader.) A multiset is like a set, except repetitions are
More informationOutline. Number Theory and Modular Arithmetic. p-1. Definition: Modular equivalence a b [mod n] (a mod n) = (b mod n) n (a-b)
Great Theoretical Ideas In CS Victor Adamchik CS - Lecture Carnegie Mellon University Outline Number Theory and Modular Arithmetic p- p Working modulo integer n Definitions of Z n, Z n Fundamental lemmas
More informationLecture Notes. Advanced Discrete Structures COT S
Lecture Notes Advanced Discrete Structures COT 4115.001 S15 2015-01-13 Recap Divisibility Prime Number Theorem Euclid s Lemma Fundamental Theorem of Arithmetic Euclidean Algorithm Basic Notions - Section
More informationProof 1: Using only ch. 6 results. Since gcd(a, b) = 1, we have
Exercise 13. Consider positive integers a, b, and c. (a) Suppose gcd(a, b) = 1. (i) Show that if a divides the product bc, then a must divide c. I give two proofs here, to illustrate the different methods.
More informationCPSC 467: Cryptography and Computer Security
CPSC 467: Cryptography and Computer Security Michael J. Fischer Lecture 9 September 30, 2015 CPSC 467, Lecture 9 1/47 Fast Exponentiation Algorithms Number Theory Needed for RSA Elementary Number Theory
More informationCPSC 467b: Cryptography and Computer Security
CPSC 467b: Cryptography and Computer Security Michael J. Fischer Lecture 8 February 1, 2012 CPSC 467b, Lecture 8 1/42 Number Theory Needed for RSA Z n : The integers mod n Modular arithmetic GCD Relatively
More informationCS250: Discrete Math for Computer Science
CS250: Discrete Math for Computer Science L6: Euclid s Algorithm & Multiplicative Inverses Mod m Greatest Common Divisors, GCD If d a and d b then d is a common divisor of a and b. 1, 2, 3, and 6 are common
More informationCSC 474 Information Systems Security
CSC Information Systems Security Topic. Basic Number Theory CSC Dr. Peng Ning Basic Number Theory We are talking about integers! Divisor We say that b divides a if a = mb for some m, denoted b a. b is
More informationCHAPTER 6. Prime Numbers. Definition and Fundamental Results
CHAPTER 6 Prime Numbers Part VI of PJE. Definition and Fundamental Results 6.1. Definition. (PJE definition 23.1.1) An integer p is prime if p > 1 and the only positive divisors of p are 1 and p. If n
More informationIntermediate Math Circles February 29, 2012 Linear Diophantine Equations I
Intermediate Math Circles February 29, 2012 Linear Diophantine Equations I Diophantine equations are equations intended to be solved in the integers. We re going to focus on Linear Diophantine Equations.
More informationFall 2017 Test II review problems
Fall 2017 Test II review problems Dr. Holmes October 18, 2017 This is a quite miscellaneous grab bag of relevant problems from old tests. Some are certainly repeated. 1. Give the complete addition and
More informationMATH FINAL EXAM REVIEW HINTS
MATH 109 - FINAL EXAM REVIEW HINTS Answer: Answer: 1. Cardinality (1) Let a < b be two real numbers and define f : (0, 1) (a, b) by f(t) = (1 t)a + tb. (a) Prove that f is a bijection. (b) Prove that any
More informationWednesday, February 21. Today we will begin Course Notes Chapter 5 (Number Theory).
Wednesday, February 21 Today we will begin Course Notes Chapter 5 (Number Theory). 1 Return to Chapter 5 In discussing Methods of Proof (Chapter 3, Section 2) we introduced the divisibility relation from
More informationDiscrete Mathematics and Probability Theory Fall 2013 Vazirani Note 3
CS 70 Discrete Mathematics and Probability Theory Fall 2013 Vazirani Note 3 Modular Arithmetic In several settings, such as error-correcting codes and cryptography, we sometimes wish to work over a smaller
More informationNumber Theory Proof Portfolio
Number Theory Proof Portfolio Jordan Rock May 12, 2015 This portfolio is a collection of Number Theory proofs and problems done by Jordan Rock in the Spring of 2014. The problems are organized first by
More informationAlgorithmic number theory. Questions/Complaints About Homework? The division algorithm. Division
Questions/Complaints About Homework? Here s the procedure for homework questions/complaints: 1. Read the solutions first. 2. Talk to the person who graded it (check initials) 3. If (1) and (2) don t work,
More informationMONOALPHABETIC CIPHERS AND THEIR MATHEMATICS. CIS 400/628 Spring 2005 Introduction to Cryptography
MONOALPHABETIC CIPHERS AND THEIR MATHEMATICS CIS 400/628 Spring 2005 Introduction to Cryptography This is based on Chapter 1 of Lewand and Chapter 1 of Garrett. MONOALPHABETIC SUBSTITUTION CIPHERS These
More informationMathematical Foundations of Cryptography
Mathematical Foundations of Cryptography Cryptography is based on mathematics In this chapter we study finite fields, the basis of the Advanced Encryption Standard (AES) and elliptical curve cryptography
More informationCSE 311 Lecture 13: Primes and GCD. Emina Torlak and Kevin Zatloukal
CSE 311 Lecture 13: Primes and GCD Emina Torlak and Kevin Zatloukal 1 Topics Modular arithmetic applications A quick wrap-up of Lecture 12. Primes Fundamental theorem of arithmetic, Euclid s theorem, factoring.
More informationExercises Exercises. 2. Determine whether each of these integers is prime. a) 21. b) 29. c) 71. d) 97. e) 111. f) 143. a) 19. b) 27. c) 93.
Exercises Exercises 1. Determine whether each of these integers is prime. a) 21 b) 29 c) 71 d) 97 e) 111 f) 143 2. Determine whether each of these integers is prime. a) 19 b) 27 c) 93 d) 101 e) 107 f)
More informationRings and modular arithmetic
Chapter 8 Rings and modular arithmetic So far, we have been working with just one operation at a time. But standard number systems, such as Z, have two operations + and which interact. It is useful to
More information4 Powers of an Element; Cyclic Groups
4 Powers of an Element; Cyclic Groups Notation When considering an abstract group (G, ), we will often simplify notation as follows x y will be expressed as xy (x y) z will be expressed as xyz x (y z)
More information2x 1 7. A linear congruence in modular arithmetic is an equation of the form. Why is the solution a set of integers rather than a unique integer?
Chapter 3: Theory of Modular Arithmetic 25 SECTION C Solving Linear Congruences By the end of this section you will be able to solve congruence equations determine the number of solutions find the multiplicative
More informationMath Circle Beginners Group February 28, 2016 Euclid and Prime Numbers Solutions
Math Circle Beginners Group February 28, 2016 Euclid and Prime Numbers Solutions Warm-up Problems 1. What is a prime number? Give an example of an even prime number and an odd prime number. A prime number
More information12x + 18y = 50. 2x + v = 12. (x, v) = (6 + k, 2k), k Z.
Math 3, Fall 010 Assignment 3 Solutions Exercise 1. Find all the integral solutions of the following linear diophantine equations. Be sure to justify your answers. (i) 3x + y = 7. (ii) 1x + 18y = 50. (iii)
More informationD-MATH Algebra I HS18 Prof. Rahul Pandharipande. Solution 1. Arithmetic, Zorn s Lemma.
D-MATH Algebra I HS18 Prof. Rahul Pandharipande Solution 1 Arithmetic, Zorn s Lemma. 1. (a) Using the Euclidean division, determine gcd(160, 399). (b) Find m 0, n 0 Z such that gcd(160, 399) = 160m 0 +
More informationAn integer p is prime if p > 1 and p has exactly two positive divisors, 1 and p.
Chapter 6 Prime Numbers Part VI of PJE. Definition and Fundamental Results Definition. (PJE definition 23.1.1) An integer p is prime if p > 1 and p has exactly two positive divisors, 1 and p. If n > 1
More informationChapter 5.1: Induction
Chapter.1: Induction Monday, July 1 Fermat s Little Theorem Evaluate the following: 1. 1 (mod ) 1 ( ) 1 1 (mod ). (mod 7) ( ) 8 ) 1 8 1 (mod ). 77 (mod 19). 18 (mod 1) 77 ( 18 ) 1 1 (mod 19) 18 1 (mod
More informationDiscrete Mathematics and Probability Theory Summer 2014 James Cook Note 5
CS 70 Discrete Mathematics and Probability Theory Summer 2014 James Cook Note 5 Modular Arithmetic In several settings, such as error-correcting codes and cryptography, we sometimes wish to work over a
More informationDiscrete Mathematics and Probability Theory Fall 2018 Alistair Sinclair and Yun Song Note 6
CS 70 Discrete Mathematics and Probability Theory Fall 2018 Alistair Sinclair and Yun Song Note 6 1 Modular Arithmetic In several settings, such as error-correcting codes and cryptography, we sometimes
More informationElementary Properties of the Integers
Elementary Properties of the Integers 1 1. Basis Representation Theorem (Thm 1-3) 2. Euclid s Division Lemma (Thm 2-1) 3. Greatest Common Divisor 4. Properties of Prime Numbers 5. Fundamental Theorem of
More informationCHAPTER 4: EXPLORING Z
CHAPTER 4: EXPLORING Z MATH 378, CSUSM. SPRING 2009. AITKEN 1. Introduction In this chapter we continue the study of the ring Z. We begin with absolute values. The absolute value function Z N is the identity
More informationCourse: CS1050c (Fall '03) Homework2 Solutions Instructor: Prasad Tetali TAs: Kim, Woo Young: Deeparnab Chakrabarty:
Course: CS1050c (Fall '03) Homework2 Solutions Instructor: Prasad Tetali TAs: Kim, Woo Young: wooyoung@cc.gatech.edu, Deeparn Chakrarty: deepc@cc.gatech.edu Section 3.7 Problem 10: Prove that 3p 2 is irrational
More informationDiscrete Mathematics GCD, LCM, RSA Algorithm
Discrete Mathematics GCD, LCM, RSA Algorithm Abdul Hameed http://informationtechnology.pk/pucit abdul.hameed@pucit.edu.pk Lecture 16 Greatest Common Divisor 2 Greatest common divisor The greatest common
More informationChapter 4 Finite Fields
Chapter 4 Finite Fields Introduction will now introduce finite fields of increasing importance in cryptography AES, Elliptic Curve, IDEA, Public Key concern operations on numbers what constitutes a number
More information2x 1 7. A linear congruence in modular arithmetic is an equation of the form. Why is the solution a set of integers rather than a unique integer?
Chapter 3: Theory of Modular Arithmetic 25 SECTION C Solving Linear Congruences By the end of this section you will be able to solve congruence equations determine the number of solutions find the multiplicative
More informationThe Fundamental Theorem of Arithmetic
Chapter 1 The Fundamental Theorem of Arithmetic 1.1 Primes Definition 1.1. We say that p N is prime if it has just two factors in N, 1 and p itself. Number theory might be described as the study of the
More information1 Overview and revision
MTH6128 Number Theory Notes 1 Spring 2018 1 Overview and revision In this section we will meet some of the concerns of Number Theory, and have a brief revision of some of the relevant material from Introduction
More informationcse 311: foundations of computing Fall 2015 Lecture 12: Primes, GCD, applications
cse 311: foundations of computing Fall 2015 Lecture 12: Primes, GCD, applications n-bit unsigned integer representation Represent integer x as sum of powers of 2: If x = n 1 i=0 b i 2 i where each b i
More information2.5 정수와알고리즘 (Integers and Algorithms)
이산수학 () 2.5 정수와알고리즘 (Integers and Algorithms) 2006 년봄학기 문양세강원대학교컴퓨터과학과 Introduction Base-b representations of integers. (b진법표현 ) Especially: binary, hexadecimal, octal. Also, two s complement representation
More informationDivisibility in the Fibonacci Numbers. Stefan Erickson Colorado College January 27, 2006
Divisibility in the Fibonacci Numbers Stefan Erickson Colorado College January 27, 2006 Fibonacci Numbers F n+2 = F n+1 + F n n 1 2 3 4 6 7 8 9 10 11 12 F n 1 1 2 3 8 13 21 34 89 144 n 13 14 1 16 17 18
More informationMath Circle Beginners Group February 28, 2016 Euclid and Prime Numbers
Math Circle Beginners Group February 28, 2016 Euclid and Prime Numbers Warm-up Problems 1. What is a prime number? Give an example of an even prime number and an odd prime number. (a) Circle the prime
More informationArithmetic and Algebra
Arithmetic and Algebra Daniel Butnaru daniel.butnaru@uni-konstanz.de 15. Dezember 2006 Daniel Butnaru daniel.butnaru@uni-konstanz.de Arithmetic and Algebra 1/39 Outline 1 Introduction 2 Big Number Arithmetic
More informationBase-b representations of integers. (b 진법표현 ) Algorithms for computer arithmetic: Euclidean algorithm for finding GCD s.
이산수학 () 정수와알고리즘 (Integers and Algorithms) 2011년봄학기 강원대학교컴퓨터과학전공문양세 Introduction Base-b representations of integers. (b 진법표현 ) Especially: binary, hexadecimal, octal. Also, two s complement representation
More informationThe next sequence of lectures in on the topic of Arithmetic Algorithms. We shall build up to an understanding of the RSA public-key cryptosystem.
CS 70 Discrete Mathematics for CS Fall 2003 Wagner Lecture 10 The next sequence of lectures in on the topic of Arithmetic Algorithms. We shall build up to an understanding of the RSA public-key cryptosystem.
More informationElementary Number Theory Review. Franz Luef
Elementary Number Theory Review Principle of Induction Principle of Induction Suppose we have a sequence of mathematical statements P(1), P(2),... such that (a) P(1) is true. (b) If P(k) is true, then
More informationComputational Complexity - Pseudocode and Recursions
Computational Complexity - Pseudocode and Recursions Nicholas Mainardi 1 Dipartimento di Elettronica e Informazione Politecnico di Milano nicholas.mainardi@polimi.it June 6, 2018 1 Partly Based on Alessandro
More informationIntermediate Math Circles February 26, 2014 Diophantine Equations I
Intermediate Math Circles February 26, 2014 Diophantine Equations I 1. An introduction to Diophantine equations A Diophantine equation is a polynomial equation that is intended to be solved over the integers.
More informationECE 646 Lecture 5. Mathematical Background: Modular Arithmetic
ECE 646 Lecture 5 Mathematical Background: Modular Arithmetic Motivation: Public-key ciphers RSA as a trap-door one-way function PUBLIC KEY message ciphertext M C = f(m) = M e mod N C M = f -1 (C) = C
More informationCOMS W4995 Introduction to Cryptography September 29, Lecture 8: Number Theory
COMS W4995 Introduction to Cryptography September 29, 2005 Lecture 8: Number Theory Lecturer: Tal Malkin Scribes: Elli Androulaki, Mohit Vazirani Summary This lecture focuses on some basic Number Theory.
More informationNumbers. Çetin Kaya Koç Winter / 18
Çetin Kaya Koç http://koclab.cs.ucsb.edu Winter 2016 1 / 18 Number Systems and Sets We represent the set of integers as Z = {..., 3, 2, 1,0,1,2,3,...} We denote the set of positive integers modulo n as
More informationFall 2015 Lecture 14: Modular congruences. cse 311: foundations of computing
Fall 2015 Lecture 14: Modular congruences cse 311: foundations of computing If a and b are positive integers, then gcd a, b = gcd (b, a mod b) Useful GCD Fact Proof: By definition a = a div b b + (a mod
More informationSolution Sheet (i) q = 5, r = 15 (ii) q = 58, r = 15 (iii) q = 3, r = 7 (iv) q = 6, r = (i) gcd (97, 157) = 1 = ,
Solution Sheet 2 1. (i) q = 5, r = 15 (ii) q = 58, r = 15 (iii) q = 3, r = 7 (iv) q = 6, r = 3. 2. (i) gcd (97, 157) = 1 = 34 97 21 157, (ii) gcd (527, 697) = 17 = 4 527 3 697, (iii) gcd (2323, 1679) =
More informationChapter 5: The Integers
c Dr Oksana Shatalov, Fall 2014 1 Chapter 5: The Integers 5.1: Axioms and Basic Properties Operations on the set of integers, Z: addition and multiplication with the following properties: A1. Addition
More information2.3 In modular arithmetic, all arithmetic operations are performed modulo some integer.
CHAPTER 2 INTRODUCTION TO NUMBER THEORY ANSWERS TO QUESTIONS 2.1 A nonzero b is a divisor of a if a = mb for some m, where a, b, and m are integers. That is, b is a divisor of a if there is no remainder
More informationLecture 11: Number Theoretic Assumptions
CS 6903 Modern Cryptography April 24, 2008 Lecture 11: Number Theoretic Assumptions Instructor: Nitesh Saxena Scribe: Robert W.H. Fisher 1 General 1.1 Administrative Homework 3 now posted on course website.
More informationLecture 3.1: Public Key Cryptography I
Lecture 3.1: Public Key Cryptography I CS 436/636/736 Spring 2015 Nitesh Saxena Today s Informative/Fun Bit Acoustic Emanations http://www.google.com/search?source=ig&hl=en&rlz=&q=keyboard+acoustic+em
More informationBasic Algorithms in Number Theory
Basic Algorithms in Number Theory Algorithmic Complexity... 1 Basic Algorithms in Number Theory Francesco Pappalardi Discrete Logs, Modular Square Roots & Euclidean Algorithm. July 20 th 2010 Basic Algorithms
More information4. Number Theory (Part 2)
4. Number Theory (Part 2) Terence Sim Mathematics is the queen of the sciences and number theory is the queen of mathematics. Reading Sections 4.8, 5.2 5.4 of Epp. Carl Friedrich Gauss, 1777 1855 4.3.
More informationChapter 2. Divisibility. 2.1 Common Divisors
Chapter 2 Divisibility 2.1 Common Divisors Definition 2.1.1. Let a and b be integers. A common divisor of a and b is any integer that divides both a and b. Suppose that a and b are not both zero. By Proposition
More informationLecture 8: Number theory
KTH - Royal Institute of Technology NADA, course: 2D1458 Problem solving and programming under pressure Autumn 2005 for Fredrik Niemelä Authors: Johnne Adermark and Jenny Melander, 9th Nov 2005 Lecture
More informationNumber theory. Myrto Arapinis School of Informatics University of Edinburgh. October 9, /29
Number theory Myrto Arapinis School of Informatics University of Edinburgh October 9, 2014 1/29 Division Definition If a and b are integers with a 6= 0, then a divides b if there exists an integer c such
More information18 Divisibility. and 0 r < d. Lemma Let n,d Z with d 0. If n = qd+r = q d+r with 0 r,r < d, then q = q and r = r.
118 18. DIVISIBILITY 18 Divisibility Chapter V Theory of the Integers One of the oldest surviving mathematical texts is Euclid s Elements, a collection of 13 books. This book, dating back to several hundred
More informationSome Facts from Number Theory
Computer Science 52 Some Facts from Number Theory Fall Semester, 2014 These notes are adapted from a document that was prepared for a different course several years ago. They may be helpful as a summary
More informationNumber theory (Chapter 4)
EECS 203 Spring 2016 Lecture 10 Page 1 of 8 Number theory (Chapter 4) Review Questions: 1. Does 5 1? Does 1 5? 2. Does (129+63) mod 10 = (129 mod 10)+(63 mod 10)? 3. Does (129+63) mod 10 = ((129 mod 10)+(63
More informationLecture 4: Number theory
Lecture 4: Number theory Rajat Mittal IIT Kanpur In the next few classes we will talk about the basics of number theory. Number theory studies the properties of natural numbers and is considered one of
More informationLecture 10: HMAC and Number Theory
CS 6903 Modern Cryptography April 15, 2010 Lecture 10: HMAC and Number Theory Instructor: Nitesh Saxena Scribes: Anand Bidla, Samiksha Saxena,Varun Sanghvi 1 HMAC A Hash-based Message Authentication Code
More informationIntroduction to Cryptology. Lecture 19
Introduction to Cryptology Lecture 19 Announcements HW6 due today HW7 due Thursday 4/20 Remember to sign up for Extra Credit Agenda Last time More details on AES/DES (K/L 6.2) Practical Constructions of
More information