Modular arithmetic Math 2320

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

MODULAR ARITHMETIC II: CONGRUENCES AND DIVISION

Modular Arithmetic and Doomsday

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

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

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

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

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

Applications of Fermat s Little Theorem and Congruences

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

Modular Arithmetic. claserken. July 2016

Carmen s Core Concepts (Math 135)

MAT Modular arithmetic and number theory. Modular arithmetic

1.6 Congruence Modulo m

Distribution of Primes

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

Groups, Modular Arithmetic and Geometry

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

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

6.2 Modular Arithmetic

A Quick Introduction to Modular Arithmetic

Modular Arithmetic. Kieran Cooney - February 18, 2016

Solutions for the 2nd Practice Midterm

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

Number Theory/Cryptography (part 1 of CSC 282)

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

Final Exam, Math 6105

MATH 13150: Freshman Seminar Unit 15

LECTURE 3: CONGRUENCES. 1. Basic properties of congruences We begin by introducing some definitions and elementary properties.

SOLUTIONS TO PROBLEM SET 5. Section 9.1

Math 127: Equivalence Relations

Number Theory. Konkreetne Matemaatika

Solutions to Exercises Chapter 6: Latin squares and SDRs

Introduction To Modular Arithmetic

Rational Points On Elliptic Curves - Solutions. (i) Throughout, we ve been looking at elliptic curves in the general form. y 2 = x 3 + Ax + B

Math 205 Test 2 Key. 1. Do NOT write your answers on these sheets. Nothing written on the test papers will be graded

Math 1111 Math Exam Study Guide

Fermat s little theorem. RSA.

Latin Squares for Elementary and Middle Grades

SESAME Modular Arithmetic. MurphyKate Montee. March 2018 IN,Z, We think numbers should satisfy certain rules, which we call axioms:

Introduction to Modular Arithmetic

Cryptography Math 1580 Silverman First Hour Exam Mon Oct 2, 2017

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

Number Theory: Modulus Math

Math 412: Number Theory Lecture 6: congruence system and

Grade 6 Math Circles March 8-9, Modular Arithmetic

Modular Arithmetic: refresher.

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

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

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

ALGEBRA: Chapter I: QUESTION BANK

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

Classwork Example 1: Exploring Subtraction with the Integer Game

#A3 INTEGERS 17 (2017) A NEW CONSTRAINT ON PERFECT CUBOIDS. Thomas A. Plick

Sheet 1: Introduction to prime numbers.

Primitive Roots. Chapter Orders and Primitive Roots

Discrete Math Class 4 ( )

Square & Square Roots

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

PRMO Official Test / Solutions

Mathematics Explorers Club Fall 2012 Number Theory and Cryptography

Three Pile Nim with Move Blocking. Arthur Holshouser. Harold Reiter.

Math 1111 Math Exam Study Guide

UNIVERSITY OF NORTHERN COLORADO MATHEMATICS CONTEST

Solutions for the Practice Questions

1 Introduction. 2 An Easy Start. KenKen. Charlotte Teachers Institute, 2015

Solutions for the Practice Final

MATH 135 Algebra, Solutions to Assignment 7

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

LUCAS-SIERPIŃSKI AND LUCAS-RIESEL NUMBERS

Data security (Cryptography) exercise book

Three of these grids share a property that the other three do not. Can you find such a property? + mod

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

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.

NUMBER THEORY AMIN WITNO

MATH CIRCLE, 10/13/2018

How to Become a Mathemagician: Mental Calculations and Math Magic

Diophantine Equations and Modulo 11.

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

Implementation / Programming: Random Number Generation

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

Launchpad Maths. Arithmetic II

Course Syllabus - Online Prealgebra

Algorithmic Number Theory and Cryptography (CS 303)

CHAPTER 2. Modular Arithmetic

Discrete Square Root. Çetin Kaya Koç Winter / 11

Class 8 Cubes and Cube Root

Shuffling with ordered cards

An interesting class of problems of a computational nature ask for the standard residue of a power of a number, e.g.,

The Problem. Tom Davis December 19, 2016

Congruence properties of the binary partition function

Lesson 21: If-Then Moves with Integer Number Cards

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

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

MATH 351 Fall 2009 Homework 1 Due: Wednesday, September 30

17. Symmetries. Thus, the example above corresponds to the matrix: We shall now look at how permutations relate to trees.

Number Theory. Applications of Congruences. Francis Joseph Campena Mathematics Department De La Salle University-Manila

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

The Chinese Remainder Theorem

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

Transcription:

Modular arithmetic Math 220 Fix an integer m 2, called the modulus. For any other integer a, we can use the division algorithm to write a = qm + r. The reduction of a modulo m is the remainder r resulting from this division; we write a mod m = r or a r (mod m). If a mod m = r and b mod m = r, we say that a is congruent to b modulo m; we write a mod m = b mod m or a b (mod m). Another way of saying this is that a b (mod m) if and only if b a is divisible by m. For each remainder 0 r < m, the set of elements with remainder r is denoted [r] = { a Z : a r (mod m) }. Example. Take m =. There are three possible remainders after division by, namely r = 0, 1, 2. We have [0] = { a Z : a 0 (mod 5) } = {..., 10, 5, 0, 5, 10,...} [1] = { a Z : a 1 (mod 5) } = {...,, 4, 1, 6,,...} [2] = { a Z : a 2 (mod 5) } = {..., 8,, 2, 7, 12,...} [] = { a Z : a (mod 5) } = {..., 7, 2,, 8, 1,...} [4] = { a Z : a 4 (mod 5) } = {..., 6, 1, 4,, 14,...}. For example, 7 1 (mod 5) because they have the same remainder, or equivalently, because 1 ( 7) = 20 is divisible by 5. Arithmetic modulo m. For any integers a, b, we can either perform arithmetic operations first and then reduce modulo m or we can reduce modulo m first and then perform arithmetic operations. We want to verify that we get the same result either way. To do this, we use the division algorithm to write so that a r and b s. Addition yields a = qm + r and b = Qm + s, a + b = (qm + r) + (Qm + s) = (q + Q)m + (r + s), so a + b r + s (mod m). Multiplication yields ab = (qm + r)(qm + s) = (qqm + qs + Qr)m + rs, so ab rs (mod m). As an example, consider the modulus m = 1 and the integers a = 1 and b = 21. We can add them together and reduce modulo 1 to get 1 + 21 = 40 1 (mod 1). Or we can reduce first, then add them together, and then reduce again to get 1 + 21 6 + 8 = 14 1 (mod 1). We can also multiply them and reduce modulo 1 to get 1 21 = (mod 1). Or we can reduce first, then multiply, then reduce again to get 1 21 6 8 48 (mod 1). The important thing is that we get the same remainder through either process.

Solving equations modulo m. 1. Suppose we want to find solutions x to First, we subtract to get 7x + 4 (mod ). 7x 4 5 6 (mod ), so we are trying to solve 7x 6 (mod ). In regular arithmetic, we would divide by 7, but modular division does not always make sense. Instead, by trial and error we can compute all possible 7x modulo. x 0 1 2 4 5 6 7 8 10 7x 0 7 10 6 2 5 1 8 4 Therefore, the only solution to 7x 6 modulo is x 4. 2. To solve the same equation modulo 14, we first subtract, just as before. 7x 4 5 (mod 14), so we want to solve 7x (mod 14). By trial and error again, we compute all possible 7x modulo 14. x 0 1 2 4 5 6 7 8 10 12 1 7x 0 7 0 7 0 7 0 7 0 7 0 7 0 7 This time, there is no solution to 7x (mod 14).. We will find the solutions to x 2x 2 (mod ). Although there are more efficient methods, we proceed again by trial and error, computing x 2, 2x 2, and x modulo. x 0 1 2 4 5 6 7 8 x 2 0 1 4 0 7 7 0 4 1 2x 2 0 2 8 0 5 5 0 8 2 x 0 1 8 0 1 8 0 1 8 Therefore, the solutions to x 2x 2 (mod ) are x 0, 2,, 6. (Notice how there are 4 solutions to a polynomial equation with degree.) Application. One nice application of modular arithmetic is to know when an integer is divisible by,, or. A decimal expansion n = a r... a 2 a 1 a 0 means that n = a 0 + a 1 (10) + a 2 (10 2 ) +... a r (10 r ). Since 10 1 (mod ), we deduce that 10 k 1 k 1 (mod ) for all positive powers k. If we reduce the expression of the decimal expansion modulo, we get n a 0 + a 1 + a 2 +... + a r (mod ). In other words, modulo, n is congruent to the sum of its digits. Since 10 1 (mod ), the same thing is true, namely that n is congruent to the sum of its digits modulo. Since 10 1 (mod ), we know that 10 k ( 1) k 1 (mod ). Therefore, n a 0 a 1 + a 2... + ( 1) r (mod ). In other words, modulo, n is congruent to the alternating sum of its digits. To summarize, an integer n is divisible by or if and only if the sum of its digits is divisible by or. An integer n is divisible by if and only if the alternating sum of its digits is divisible by. For example, for n = 177, the sum of the digits is + 1 + + 7 + 7 = 27, which is divisible by both and. Therefore, n is divisible by. The alternating sum of the digits is 1 + 7 + 7 =. Since this is divisible by, the original number n is also divisible by.

Exercises 1. Find all solutions modulo 14 to the following equations. (a) 5x 4 (mod 14) (b) 6x 5 (mod 14) (c) 6x 6 (mod 14) 2. For each a {0, 1, 2,, 4, 5, 6, 7}, find the solutions modulo 8 to x 2 a (mod 8).. Show that n 7 n is always divisible by 7. (Hint: for each remainder a modulo 7, show that a 7 a 0 (mod 7).) 4. In the integers, we often use two properties: - if kx = ky, then k = 0 or x = y. - if xy = 0, then x = 0 or y = 0. Find some counter-examples to these properties when the arithmetic is done modulo 20. In other words, find some examples of k, x, y {1, 2,..., 18, 1} such that kx ky (mod 20), but x y (mod 20). Also find some examples of x, y 0 such that xy 0 (mod 20). 5. Determine how many times,, and go into the following integers. (a) 21,44,787 (b),16,800 (c),6,6 (d) 4,24,551 6. Fill out the following multiplication table modulo 15. In other words, if the column is a and the row is b, the entry should be ab (mod 15). 1 2 4 5 6 7 8 10 12 1 14 1 2 4 5 6 7 8 10 12 1 14

Answers 1. (a) The only solution is x 12 (mod 14). x 0 1 2 4 5 6 7 8 10 12 1 5x 0 5 10 1 6 2 7 12 8 1 4 (b) There are no solutions. x 0 1 2 4 5 6 7 8 10 12 1 6x 0 6 12 4 10 2 8 0 6 12 4 10 2 8 (c) The solutions are x 1, 8 (mod 14). 2. x 2 0 has two solutions, x 0, 4 (mod 8). x 2 1 has four solutions, x 1,, 5, 7 (mod 8). x 2 4 has two solutions, x 2, 6 (mod 8). And x 2 a has zero solutions for a = 2,, 5, 6, 7. x 0 1 2 4 5 6 7 x 2 0 1 4 1 0 1 4 1. n 7 n is divisible by 7 if and only if n 7 n 0 (mod 7), i.e., if and only if n 7 n (mod 7). There are 7 possible remainders modulo 7 for n. For each of these, we compute n 7 modulo 7. n 0 1 2 4 5 6 n 2 0 1 4 2 2 4 1 n = n 2 n 0 1 1 6 1 6 6 n 4 = n 2 n 2 0 1 2 4 4 2 1 n 7 = n 4 n 0 1 2 4 5 6 The first row and the last row are the same, so n 7 n (mod 7) for all integers n, proving that n 7 n is always divisible by 7. 4. For example, if k = 8, we have that and Also, we have that 8 8 8 8 1 8 18 (mod 20) 8 4 8 8 14 8 1 (mod 20). 8 5 8 10 8 15 0 (mod 20). 21,44,787 5. (a) The sum of the digits is 6, which is divisible by : = 2, 81, 64. The 2,81,64 sum of the new digits is 27, which is divisible by : = 264, 627. The sum 264,627 of the new digits is 27, which is divisible by : = 2, 40. The sum of the 2,40 new digits is 18, which is divisible by : =, 267. The sum of the new digits,267 is 18, which is divisible by : = 6. The sum of the new digits is 12, which 6 is divisible by : = 121. Therefore, 21, 44, 787 is divisible by 5 and divisible by. It is also divisible by 2 = 121. (b) The alternating sum of the digits is 0 0 + 8 6 + 1 + = 0, which is,16,800 divisible by : =, 628, 800. The alternating sum of the new digits is 0 0 + 8 8 + 2 6 + = 1, which is not divisible by. The sum of the new,628,800 digits is 27, which is divisible by : = 40, 200. The sum of the new digits 40,200 is, which is divisible by : = 44, 800. The sum of the new digits is 16, which is not divisible by or. So,, 16, 800 is divisible by and 2. 66 (c) The sum of the digits is 42, which is divisible by : = 22. The alternating sum of the digits is 0, which is divisible by : 22 = 101020. The

alternating sum of the new digits is 7, which is not divisible by. So,, 6, 6 is divisible by and by. 4,24,551 (d) The sum of the digits is 27, which is divisible by : = 4, 804, 8. The sum of the new digits is 6, which is divisible by : 4,804,8 = 5, 871. The sum of 5,871 the new digits is 27, which is divisible by : = 5, 1. The sum of the new 5,1 digits is 27, which is divisible by : = 6, 51. The sum of the new digits is 6,51 21, which is divisible by : = 2, 17. The alternating sum of the new digits is 7 + 1 2 =, which is not divisible by. Therefore, 4, 24, 551 is divisible by 4,, and not divisible by. 6. 1 2 4 5 6 7 8 10 12 1 14 1 1 2 4 5 6 7 8 10 12 1 14 2 2 4 6 8 10 12 14 1 5 7 1 6 12 0 6 12 0 6 12 4 4 8 12 1 5 1 2 6 10 14 7 5 5 10 0 5 10 0 5 10 0 5 10 0 5 10 6 6 12 0 6 12 0 6 12 7 7 14 6 1 5 12 4 10 2 1 8 8 8 1 2 10 4 12 5 1 6 14 7 12 6 0 12 6 0 12 6 10 10 5 0 10 5 0 10 5 0 10 5 0 10 5 7 14 10 6 2 1 5 1 12 8 4 12 12 6 0 12 6 0 12 6 1 1 7 5 1 14 12 10 8 6 4 2 14 14 1 12 10 8 7 6 5 4 2 1