Lecture 8. Outline. 1. Modular Arithmetic. Clock Math!!! 2. Inverses for Modular Arithmetic: Greatest Common Divisor. 3. Euclid s GCD Algorithm

Similar documents
Modular Arithmetic: refresher.

Number Theory - Divisibility Number Theory - Congruences. Number Theory. June 23, Number Theory

Modular Arithmetic and Doomsday

The congruence relation has many similarities to equality. The following theorem says that congruence, like equality, is an equivalence relation.

Modular arithmetic Math 2320

Distribution of Primes

Fermat s little theorem. RSA.

Grade 6/7/8 Math Circles April 1/2, Modular Arithmetic

Groups, Modular Arithmetic and Geometry

ALGEBRA: Chapter I: QUESTION BANK

Introduction to Modular Arithmetic

Number Theory/Cryptography (part 1 of CSC 282)

Calculators will not be permitted on the exam. The numbers on the exam will be suitable for calculating by hand.

MAT Modular arithmetic and number theory. Modular arithmetic

p 1 MAX(a,b) + MIN(a,b) = a+b n m means that m is a an integer multiple of n. Greatest Common Divisor: We say that n divides m.

CMPSCI 250: Introduction to Computation. Lecture #14: The Chinese Remainder Theorem David Mix Barrington 4 October 2013

SOLUTIONS TO PROBLEM SET 5. Section 9.1

CMPSCI 250: Introduction to Computation. Lecture #14: The Chinese Remainder Theorem David Mix Barrington 24 February 2012

Carmen s Core Concepts (Math 135)

MODULAR ARITHMETIC II: CONGRUENCES AND DIVISION

Modular Arithmetic. claserken. July 2016

Modular Arithmetic. Kieran Cooney - February 18, 2016

b) Find all positive integers smaller than 200 which leave remainder 1, 3, 4 upon division by 3, 5, 7 respectively.

Solutions for the 2nd Practice Midterm

Overview. The Big Picture... CSC 580 Cryptography and Computer Security. January 25, Math Basics for Cryptography

6.2 Modular Arithmetic

Discrete Math Class 4 ( )

Cryptography Lecture 1: Remainders and Modular Arithmetic Spring 2014 Morgan Schreffler Office: POT 902

Data security (Cryptography) exercise book

The Chinese Remainder Theorem

A Quick Introduction to Modular Arithmetic

Grade 7/8 Math Circles February 9-10, Modular Arithmetic

6. Find an inverse of a modulo m for each of these pairs of relatively prime integers using the method

Math 412: Number Theory Lecture 6: congruence system and

Grade 7 & 8 Math Circles October 12, 2011 Modular Arithmetic

Applications of Fermat s Little Theorem and Congruences

Math 255 Spring 2017 Solving x 2 a (mod n)

PART I: NO CALCULATOR (115 points)

University of British Columbia. Math 312, Midterm, 6th of June 2017

Introduction To Modular Arithmetic

Discrete Mathematics & Mathematical Reasoning Multiplicative Inverses and Some Cryptography

Collection of rules, techniques and theorems for solving polynomial congruences 11 April 2012 at 22:02

1 = 3 2 = 3 ( ) = = = 33( ) 98 = = =

Solutions to Problem Set 6 - Fall 2008 Due Tuesday, Oct. 21 at 1:00

1.6 Congruence Modulo m

Grade 6 Math Circles March 8-9, Modular Arithmetic

Cryptography, Number Theory, and RSA

Number Theory: Modulus Math

Sheet 1: Introduction to prime numbers.

Grade 6 Math Circles. Divisibility

Math 127: Equivalence Relations

Class 8: Square Roots & Cube Roots (Lecture Notes)

MATH 135 Algebra, Solutions to Assignment 7

Practice Midterm 2 Solutions

Assignment 2. Due: Monday Oct. 15, :59pm

Number Theory. Konkreetne Matemaatika

Quantitative Aptitude Preparation Numbers. Prepared by: MS. RUPAL PATEL Assistant Professor CMPICA, CHARUSAT

Solutions for the Practice Questions

Numbers (8A) Young Won Lim 6/21/17

Numbers (8A) Young Won Lim 5/22/17

Numbers (8A) Young Won Lim 5/24/17

Exam 1 7 = = 49 2 ( ) = = 7 ( ) =

Solutions to Exam 1. Problem 1. a) State Fermat s Little Theorem and Euler s Theorem. b) Let m, n be relatively prime positive integers.

Example Enemy agents are trying to invent a new type of cipher. They decide on the following encryption scheme: Plaintext converts to Ciphertext

Grade 6 Math Circles March 1-2, Introduction to Number Theory

NUMBER THEORY AMIN WITNO

Public Key Cryptography

Divisibility. Igor Zelenko. SEE Math, August 13-14, 2012

Public Key Cryptography Great Ideas in Theoretical Computer Science Saarland University, Summer 2014

Introduction. and Z r1 Z rn. This lecture aims to provide techniques. CRT during the decription process in RSA is explained.

Multiples and Divisibility

4th Grade Mathematics Mathematics CC

Power = 36² mod 99 Power = 9 5 a 5 = 0 x = 81 Power = 9² mod 99 Power = 81 6 a 6 = 1 x = 81 x 81 mod 99 x = 27 7 a 7 = 1 x = 27 x 27 mod 99 x = 36

Constructions of Coverings of the Integers: Exploring an Erdős Problem

Solutions for the Practice Final

Linear Congruences. The solutions to a linear congruence ax b (mod m) are all integers x that satisfy the congruence.

4) If your birthday fell on a Sunday this year, what day will it fall on next year? 5) If it is autumn now, what season will it be in 100 seasons?

Mathematics Explorers Club Fall 2012 Number Theory and Cryptography

Squares and Square roots

Place Value (Multiply) March 21, Simplify each expression then write in standard numerical form. 400 thousands thousands = thousands =

Implementation / Programming: Random Number Generation

XSEED Summative Assessment Test 2. Maths, Test 2. XSEED Education Maths Grade 4 1

Algorithmic Number Theory and Cryptography (CS 303)

MATH 324 Elementary Number Theory Solutions to Practice Problems for Final Examination Monday August 8, 2005

Table of Contents. Table of Contents 1

CS1800 Discrete Structures Fall 2016 Profs. Aslam, Gold, Ossowski, Pavlu, & Sprague 7 November, CS1800 Discrete Structures Midterm Version C

Adding Fractions with Different Denominators. Subtracting Fractions with Different Denominators

ON MODULI FOR WHICH THE FIBONACCI SEQUENCE CONTAINS A COMPLETE SYSTEM OF RESIDUES S. A. BURR Belt Telephone Laboratories, Inc., Whippany, New Jersey

Study Material. For. Shortcut Maths

CHAPTER 2. Modular Arithmetic

ELEMENTS OF NUMBER THEORY & CONGRUENCES. Lagrange, Legendre and Gauss. Mth Mathematicst

Discrete Mathematics and Probability Theory Spring 2018 Ayazifar and Rao Midterm 2 Solutions

Mock AMC 10 Author: AlcumusGuy

Math 1111 Math Exam Study Guide

Final exam. Question Points Score. Total: 150

Calculators will not be permitted on the exam. The numbers on the exam will be suitable for calculating by hand.

Removing the Fear of Fractions from Your Students Thursday, April 16, 2015: 9:30 AM-10:30 AM 157 A (BCEC) Lead Speaker: Joseph C.

Unit 1. Activity 1. Whole numbers. 1. Copy and complete each number pattern.

Congruence. Solving linear congruences. A linear congruence is an expression in the form. ax b (modm)

Math 1111 Math Exam Study Guide

Transcription:

Lecture 8. Outline. 1. Modular Arithmetic. Clock Math!!! 2. Inverses for Modular Arithmetic: Greatest Common Divisor. 3. Euclid s GCD Algorithm

Clock Math If it is 1:00 now. What time is it in 5 hours? 6:00! What time is it in 15 hours? 16:00! Actually 4:00. 16 is the same as 4 with respect to a 12 hour clock system. Clock time equivalent up to to addition/subtraction of 12. What time is it in 100 hours? 101:00! or 5:00. 5 is the same as 101 for a 12 hour clock system. Clock time equivalent up to addition of any integer multiple of 12. Custom is only to use the representative in {1,...,11,12}

Day of the week. Today is Wednesday. What day is it a year from now? on September 14, 2017? Number days. 0 for Sunday, 1 for Monday,..., 6 for Saturday. Today: day 3. 3 days from now. day 6 or Saturday. 23 days from now. day 26 or day 5, which is Friday! two days are equivalent up to addition/subtraction of multiple of 7. 9 days from now is day 5 again, Friday! What day is it a year from now? Next year is not a leap year. So 365 days from now. Day 3+365 or day 368. Smallest representation: subtract 7 until smaller than 7. divide and get remainder. 368/7 leaves quotient of 52 and remainder 4. or September 14, 2017 is Day 4, a Thursday.

Years and years... 80 years from now? September 14, 2096 20 leap years. 366*20 days 60 regular years. 365*60 days It is day 3 + 366 20 + 365 60. Equivalent to? Hmm. What is remainder of 366 when dividing by 7? 2. What is remainder of 365 when dividing by 7? 1 Today is day 3. Get Day: 3 + 20*2 + 60*1 = 103 Remainder when dividing by 7? 5. Or September 14, 2096 is Friday! Further Simplify Calculation: 20 has remainder 6 when divided by 7. 60 has remainder 4 when divided by 7. Get Day: 3 + 6*2 + 4*1 = 19. Or Day 5. September 14, 2096 is Friday. Reduce at any time in calculation!

Modular Arithmetic: Basics. x is congruent to y modulo m or x y (mod m) if and only if (x y) is divisible by m....or x and y have the same remainder w.r.t. m....or x = y + km for some integer k. Mod 7 equivalence classes: {..., 7,0,7,14,...} {..., 6,1,8,15,...}... Useful Fact: Addition, subtraction, multiplication can be done with any equivalent x and y. or a c (mod m) and b d (mod m) = a + b c + d (mod m) and a b = c d (mod m) Proof: If a c (mod m), then a = c + km for some integer k. If b d (mod m), then b = d + jm for some integer j. Therefore, a + b = c + d + (k + j)m and since k + j is integer. = a + b c + d (mod m). Can calculate with representative in {0,...,m 1}.

Notation x (mod m) or {0,...,m 1}. mod (x,m)- remainder of x divided by m in mod (x,m) = x x m m m x is quotient. mod (29,12) = 29 ( 29 12 ) 12 = 29 (2) 12 = 5 Recap: a b (mod m). Says two integers a and b are equivalent modulo m. Modulus is m

Inverses and Factors. Division: multiply by multiplicative inverse. 2x = 3 = (1/2) 2x = (1/2)3 = x = 3/2. Multiplicative inverse of x is y where xy = 1; 1 is multiplicative identity element. In modular arithmetic, 1 is the multiplicative identity element. Multiplicative inverse of x mod m is y with xy = 1 (mod m). For 4 modulo 7 inverse is 2: 2 4 8 1 (mod 7). Can solve 4x = 5 (mod 7). x 2 = 4x 3 = (mod 2 5 7) (mod ::: Check! 7) 4(3) = 12 = 5 (mod 7). For 8x = 810 modulo (mod12: 7) no multiplicative inverse! x = 3 (mod 7) Common Check! 4(3) factor = 12 of = 4 5 (mod = 7). 8k 12l is a multiple of four for any l and k = 8k 1 (mod 12) for any k.

Greatest Common Divisor and Inverses. Thm: If greatest common divisor of x and m, gcd(x,m), is 1, then x has a multiplicative inverse modulo m. Proof = : The set S = {0x,1x,...,(m 1)x} contains y 1 mod m if all distinct modulo m. Pigenhole principle: Each of m numbers in S correspond to different one of m equivalence classes modulo m. = One must correspond to 1 modulo m. If not distinct, then a,b {0,...,m 1}, where (ax bx (mod m)) = (a b)x 0 (mod m) Or (a b)x = km for some integer k. gcd(x,m) = 1 = Prime factorization of m and x do not contain common primes. = (a b) factorization contains all primes in m s factorization. So (a b) has to be multiple of m. = (a b) m. But a,b {0,...m 1}. Contradiction.

Proof review. Consequence. Thm: If gcd(x,m) = 1, then x has a multiplicative inverse modulo m. Proof Sketch: The set S = {0x,1x,...,(m 1)x} contains y 1 mod m if all distinct modulo m.... For x = 4 and m = 6. All products of 4... S = {0(4),1(4),2(4),3(4),4(4),5(4)} = {0,4,8,12,16,20} reducing (mod 6) S = {0,4,2,0,4,2} Not distinct. Common factor 2. For x = 5 and m = 6. S = {0(5),1(5),2(5),3(5),4(5),5(5)} = {0,5,4,3,2,1} All distinct, contains 1! 5 is multiplicative inverse of 5 (mod 6). 5x = 3 (mod 6) What is x? Multiply both sides by 5. x = 15 = 3 (mod 6) 4x = 3 (mod 6) No solutions. Can t get an odd. 4x = 2 (mod 6) Two solutions! x = 2,5 (mod 6) Very different for elements with inverses.

Finding inverses. How to find the inverse? How to find if x has an inverse modulo m? Find gcd (x,m). Greater than 1? No multiplicative inverse. Equal to 1? Mutliplicative inverse. Algorithm: Try all numbers up to x to see if it divides both x and m. Very slow. Next: A Faster algorithm.

Midterm1!!! Watch Piazza for Logistics! Watch Piazza for Advice! Study/review sessions this weekend! See Piazza. Important reminders: 1. Midterm room assignment: based on your official section enrollment. 2. Grading option form is due tonight. Details are on Piazza. Any other issues... Email logistics@eecs70.org / Private message on piazza. Happy Studying!!!!!!!!!!!!!!!!!