MAT Modular arithmetic and number theory. Modular arithmetic

Similar documents
Math 127: Equivalence Relations

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

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.

Applications of Fermat s Little Theorem and Congruences

1.6 Congruence Modulo m

Modular Arithmetic. Kieran Cooney - February 18, 2016

Introduction to Modular Arithmetic

Wilson s Theorem and Fermat s Theorem

Primitive Roots. Chapter Orders and Primitive Roots

Algorithmic Number Theory and Cryptography (CS 303)

Number Theory. Konkreetne Matemaatika

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

To be able to determine the quadratic character of an arbitrary number mod p (p an odd prime), we. The first (and most delicate) case concerns 2

L29&30 - RSA Cryptography

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

NUMBER THEORY AMIN WITNO

Modular arithmetic Math 2320

Public Key Encryption

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

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

Algorithmic Number Theory and Cryptography (CS 303)

Modular Arithmetic. claserken. July 2016

CHAPTER 2. Modular Arithmetic

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

SOLUTIONS TO PROBLEM SET 5. Section 9.1

6.2 Modular Arithmetic

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

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

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

Data security (Cryptography) exercise book

Fermat s little theorem. RSA.

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

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

Carmen s Core Concepts (Math 135)

An elementary study of Goldbach Conjecture

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

The Chinese Remainder Theorem

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

Solutions for the Practice Final

ON THE EQUATION a x x (mod b) Jam Germain

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

Modular Arithmetic: refresher.

Distribution of Primes

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

Practice Midterm 2 Solutions

Modular Arithmetic and Doomsday

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

Sheet 1: Introduction to prime numbers.

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

Number Theory/Cryptography (part 1 of CSC 282)

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

MA/CSSE 473 Day 9. The algorithm (modified) N 1

Mathematics Explorers Club Fall 2012 Number Theory and Cryptography

Goldbach Conjecture (7 th june 1742)

x 8 (mod 15) x 8 3 (mod 5) eli 2 2y 6 (mod 10) y 3 (mod 5) 6x 9 (mod 11) y 3 (mod 11) So y = 3z + 3u + 3w (mod 990) z = (990/9) (990/9) 1

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

Solutions for the Practice Questions

SOLUTIONS FOR PROBLEM SET 4

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

MATH 13150: Freshman Seminar Unit 15

NIM Games: Handout 1

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.

Math 319 Problem Set #7 Solution 18 April 2002

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

MODULAR ARITHMETIC II: CONGRUENCES AND DIVISION

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

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

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

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

Congruence properties of the binary partition function

DUBLIN CITY UNIVERSITY

Cryptography. 2. decoding is extremely difficult (for protection against eavesdroppers);

MST125. Essential mathematics 2. Number theory

Discrete Math Class 4 ( )

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

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

Number Theory and Security in the Digital Age

Discrete Mathematics & Mathematical Reasoning Multiplicative Inverses and Some Cryptography

ALGEBRA: Chapter I: QUESTION BANK

A Quick Introduction to Modular Arithmetic

THE NUMBER OF PERMUTATIONS WHICH FORM ARITHMETIC PROGRESSIONS MODULO m

UNIVERSITY OF MANITOBA DATE: December 7, FINAL EXAMINATION TITLE PAGE TIME: 3 hours EXAMINER: M. Davidson

Determinants, Part 1

The Sign of a Permutation Matt Baker

Groups, Modular Arithmetic and Geometry

Goldbach conjecture (1742, june, the 7 th )

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

The number theory behind cryptography

Final exam. Question Points Score. Total: 150

5 Symmetric and alternating groups

Arithmetic of Remainders (Congruences)

Number-Theoretic Algorithms

Foundations of Cryptography

Two congruences involving 4-cores

Solutions for the 2nd Practice Midterm

Application: Public Key Cryptography. Public Key Cryptography

1 Introduction to Cryptology

LECTURE 7: POLYNOMIAL CONGRUENCES TO PRIME POWER MODULI

Axiom A-1: To every angle there corresponds a unique, real number, 0 < < 180.

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

Transcription:

Modular arithmetic 1 Modular arithmetic may seem like a new and strange concept at first The aim of these notes is to describe it in several different ways, in the hope that you will find at least one of them easy to understand We also give some examples to show that it is not such a new concept after all And finally, we construct some groups and use this machinery to derive some results in number theory Modular arithmetic could also be useful because it gives a concrete example of what a coset is 2 Arithmetic mod 2 Imagine writing two columns of integers as follows: 4 5 2 3 0 1 2 1 4 3 6 5 Any integer z will eventually appear in one (and only one) of the columns; so we have a partition of the integers Of course, this is just the familiar partition into odds and evens We can write any integer on the left as 2k, for some integer k; while any integer on the right can be written as 2k + 1 Now imagine taking two numbers from the left column (two even numbers, say 8 and 14); if we add them, we get another even number (22); and we can prove that this holds in general if our two numbers are 2x and 2y, then their sum is 2x + 2y = 2(x + y) On the other hand, suppose we add an odd number, 2m + 1, to an even one, 2n We get 2m + 1 + 2n = 2(m + n) + 1, which is odd If we multiply two odd numbers, say 2x + 1 and 2y + 1, we get (2x + 1)(2y + 1) = 4xy + 2x + 2y + 1 = 2(2xy + x + y) + 1, which is again odd 1

We can summarise this as even + even = even, odd+even = odd, odd odd = odd, and in general we have the familiar rules: even + even = even, even + odd = odd, odd + odd = even even even = even, even odd = even, odd odd = odd This is arithmetic modulo 2, where we look not at the integer itself, but rather at which equivalence class (odd or even) it falls into Two integers x and y are equivalent up to a multiple of 2 or congruent (mod 2) if they are in the same column: starting from x and repeatedly adding (or subtracting) 2, we eventually get to y Stated another way, x y is a multiple of two, and either both are odd, or both are even they have the same parity If x y is not a multiple of two, then they have different parity There is yet another way of looking at arithmetic mod 2 Since every integer z has the same parity as either 0 or 1, we can restrict ourselves to just {0, 1}: z 0 (mod 2) iff z = 0 + 2k, for some integer k; z 1 (mod 2) iff z = 1 + 2k, for some integer k That is, we divide z by 2, and work with the remainder (which is either 0 or 1) Addition of a and b (mod 2), denoted + 2, just means look at the parity of a+b, or add a and b, divide by 2, and look at the remainder Of course 2, ie multiplication mod 2, is similar 3 Arithmetic mod n We can generalise all this, replacing 2 by some fixed integer n We are now partitioning the integers into n columns: kn + 0 kn + 1 kn + 2 kn + (n 2) kn + (n 1) 2n + 0 2n + 1 2n + 2 2n + (n 2) 2n + (n 1) n + 0 n + 1 n + 2 n + (n 2) n + (n 1) 0 1 2 n 2 n 1 n + 0 n + 1 n + 2 n + (n 2) n + (n 1) 2n + 0 2n + 1 2n + 2 2n + (n 2) 2n + (n 1) In general, we say that z and z + kn are equivalent up to a multiple of n, or just congruent modulo n (where z and k are integers) 2

4 Defn Let x and y be integers We say that x and y are congruent modulo n iff x y = kn for some k Z We denote this by x y (mod n) or x = y (mod n) 5 Congruence mod n is easily seen to be an equivalence relation, and it partitions the integers into n equivalence classes (the n columns that we saw above) [0] n := {0 + kn : k Z} [1] n := {1 + kn : k Z} [n 1] n := {n 1 + kn : k Z} When there is no risk of confusion, we write [x] instead of [x] n 6 We can define binary operations on these equivalence classes in a natural way: [x] n + n [y] n := [x + y] n and [x] n n [y] n := [xy] n For example, working modulo 10 we have: [4] 10 + 10 [9] 10 = [13] 10 = [3] 10 Similarly [4] 10 10 [9] 10 = [36] 10 = [6] 10 An equivalence class has many different representations eg [4] 10 = [14] 10 = [ 276] 10, and [37] 10 = [267] 10 = [ 93] 10 The next result assures us that when we add these two equivalence classes, we always get the same result, ie [4 + 37] 10 = [4 + 267] 10 = [14 93] 10 = In general, if [x] = [x ] and [y] = [y ], then [x + y] = [x + y ] and [xy] = [x y ] 7 Proposition If x x (mod n) and y y (mod n), then x + y x + y (mod n) and xy x y (mod n) Proof: Suppose x = x + k x n and y = y + k y n Then x + y = (x + y ) + (k x + k y )n, so x + y x + y (mod n) We also have xy = x y + (k x k y n + k x y + k y x )n, so xy x y (mod n) 8 As we saw above, arithmetic modulo 10 simply means that we consider only the last digit of a number (when the number is positive) eg 136527 = 7 (mod 10) Another case that we are familiar with is arithmetic modulo 12, which is how we calculate time if it is 8 o clock, and I am meeting someone 7 hours 3

from now, then we will meet at 3 o clock, since 8 + 7 = 15 = 3 (mod 12) If it helps you, you can think of arithmetic mod n as if you are working with an n-hour clock Exercises 1 What is 230 + 357 (mod 10)? What is 230 356 (mod 10)? 2 I am thinking of an integer x; what is 230 x (mod 10)? 230 x (mod 2)? Can you determine 230 x (mod 3) without knowing x? How about 230 x (mod 23)? 3 What is 775 + 773 (mod 7)? What is 775 773 (mod 7)? 4 What is 2 (mod 717)? The point of exercise 3, for example, is that we don t need to add or multiply 775 and 773 Since 775 5 (mod 7) and 773 3 (mod 7), it is enough to work out 5 + 3 and 5 3 What time is it one hour before midnight? Two hours before midnight? We can write these facts as 1 11 (mod 12), 2 10 (mod 12) and, in general, 1 n 1 (mod n) and j n j (mod n) 9 Proposition Z n := {[0], [1], [2],, [n 1]} is a group under addition Proof: We first show that every integer is in one of these n classes By the Euclidean algorithm, any integer z can be written as mn + r, for some 0 r n 1 So every integer is congruent (mod n) to one of {0, 1,, n 1} Closure If [x] and [y] are two elements of Z n, then x and y are integers, so x + y is an integer, and so [x + y] is one of the classes above Associativity This follows from associativity in Z: ([x] + [y]) + [z] = [x + y] + [z] = [(x + y) + z] (by definition of + in Z n ) = [x + (y + z)] (by associativity in Z) = [x] + [y + z] = [x] + ([y] + [z]) (by definition of + in Z n ) Identity [0] is clearly an identity, since for any [x], we have [0] + [x] = [0 + x] = [x] = [x + 0] = [x] + [0] Inverses For any [x] Z n, [ x] is also in Z n, and [ x] + [x] = [ x + x] = [0] = [x + ( x)] = [x] + [ x], so every element has an inverse in Z n 4

10 The inverse of j under addition (mod n) is j What about the inverse under multiplication (mod n)? Suppose there is some i such that ij 1 (mod n); then whenever jk jm, we have ijk ijm and so k m (mod n); that is, we can use i to cancel out j, and we write i = j 1 In particular, if j has an inverse, then jk 0 (mod n) implies j 1 jk j 1 0, that is k 0 (mod n) 5 Write out the multiplication tables mod 2, mod 3 and mod 4 Do all the numbers have an inverse? 6 What is 2 1 (mod 3)? What is 2 1 (mod 9)? Does 2 1 (mod 6) exist? As you can see, 2 has an inverse modulo 3 and modulo 9, but not modulo 4 or 6 Why is this? The problem is that 2 divides 6; so for example 2 3 = 6 0 (mod 6), even though 2 0 and 3 0 If 2 had an inverse, then we could deduce that 2 1 2 3 2 1 0 (mod 6), but this gives us 3 0 (mod 6), which is clearly false Now 4 does not have an inverse mod 6, even though it does not divide 6; but it has a common factor with 6 So although we cannot factor 6 as 4 x, we can factor 2 6 as 4 3, where 4 0 and 3 0 (mod 6) The numbers that have no common factor with 6 all have an inverse, and in fact they form a group, under multiplication mod 6 11 Defn Two integers m and n are relatively prime or co-prime if they have no common prime factor 12 So for example, 3 4 5 2 11 3 is co-prime with 7 4 13 2 23, but not with 11 17 19 (since 11 is a common factor) In general, let m = p a 1 1 p as s and n = q b 1 1 qv bv be the decompositions of m and n into primes Then m and n are co-prime iff the p i s are all different from the q j s 13 Defn The multiplicative group mod n, denoted Z n, consists of all the integers m such that 0 < m < n, and m is co-prime to n 14 You can check that Z 5 = {1, 2, 3, 4}, Z 6 = {1, 5}, Z 7 = {1, 2, 3, 4, 5, 6}, Z 8 = {1, 3, 5, 7}, Z 9 = {1, 2, 4, 5, 7, 8} So, even if y > x, Z y could have less elements than Z x Note also that, if p is prime, Z p is all of {1, 2,, p 1} Strictly speaking, the elements of Z n are not numbers, but congruence classes mod n So Z 5 = {[1] 5, [2] 5, [3] 5, [4] 5 }, Z 6 = {[1] 6, [5] 6 }, etc The result below assures us that, say, since 5 is co-prime to 6, all the numbers in [5] 6 are co-prime to 6 5

15 Proposition Let m m (mod n) Then m is co-prime to n iff m is co-prime to n Proof: If m m (mod n), then m = m + kn, for some integer k We will show that if m is not co-prime to n, then neither is m So let z be a common factor of m and n, say m = za and n = zb Then m = za + kzb, so z is also a common factor of m and n Similarly, if m is not co-prime to n, then neither is m We now show that Z n is, in fact, a group The proof is similar to that of Prop 9, except for the Inverses axiom 16 Proposition Z n is a group under mod n Proof: Closure If [x] and [y] are in Z n, then n has no common factor with x or y, so it has no common factor with xy Thus [xy] is also in Z n Associativity This follows from associativity in Z: ([x] [y]) [z] = [x y] [z] = [(x y) z] (by definition of in Z n) = [x (y z)] (by associativity in Z) = [x] [y z] = [x] ([y] [z]) (by definition of in Z n) Identity 1 is co-prime to n, and [1] is an identity since, for any [x], we have [1] [x] = [1 x] = [x] = [x 1] = [x] [1] Inverses Let [x] be in Z n, and let Z n have r elements in all, say [z 1 ],, [z r ] If [x] had no inverse, then [xz i ] is not [1] for any i This means that there are at most r 1 possible values for [xz 1 ], [xz 2 ],, [xz r ], so two of them must be equal, say [xz j ] = [xz k ] for some z j < z k Then [x(z j z k )] = [xz j ] [xz k ] = [0]; that is, x(z j z k ) is a multiple of n Since x is co-prime to n, it must be that z j z k is a multiple of n Now 0 < z j < z k < n implies that 0 < z k z j < n, which is impossible 6

Number theory We can now use our results in group theory, including Lagrange s Theorem, to do a little bit of number theory These will give us simple ways of testing whether a number is prime These algorithms are, however, very slow to run even on a computer It was only in 2002 that Indian scientists discovered a prime-testing algorithm that is guaranteed to run quickly A related problem is to find the prime factors of a given number This has great practical importance, as it could be used to break many computer encryption codes There is, however, no known algorithm that factors numbers quickly, so many secrets are safe for now It is possible that in fact no fast factorisation algorithm exists 17 Definition The number of integers between 1 and n, that are co-prime to n, is denoted by φ(n), ie φ(n) := {m 1 m n, m is co-prime to n} The function φ is called Euler s totient function Note that the size of Z n is, by definition, φ(n) So, from note 14 we have φ(5) = 4, φ(6) = 2, φ(7) = 6, φ(8) = 4, φ(9) = 6 We will need the following corollary of Lagrange s Theorem: 18 Lemma Let g be an element of the group G, and let e be the identity in G Then g G = e Proof: The order of g is the least positive index k for which g k = e The k distinct powers of g form a subgroup of G, so by Lagrange s Theorem, k divides G ; that is, G = km, for some integer m Then g G = g km = (g k ) m = e m = e 19 Euler s Theorem If a is co-prime to n, then a φ(n) 1 (mod n) Proof: If a is co-prime to n, then a is an element of Z n (Strictly speaking, the congruence class of a is an element of Z n) By Prop 16, Z n is a group with identity 1, and, by definition, Z n = φ(n) So by Lemma 18, a Z n = a φ(n) 1 (mod n) 7

20 Fermat s Little Theorem If p is a prime, and a is not a multiple of p, then a p 1 1 (mod p) Proof: If p is a prime, then all positive integers less than p are co-prime to p; therefore φ(p) = p 1 The result therefore follows immediately from Euler s Theorem 21 Fermat mentioned the result in a letter October 18, 1640 to his friend and confidant Frnicle de Bessy Fermat must have proved this without using Lagrange s Theorem (c 1830) or Euler s Theorem (1736) As with the big theorem that he mentioned in another note, Fermat he did not include the proof as he was afraid that there was not enough space Fermat s Little Theorem is sometimes stated as: For any integer a and prime p, a p a (mod p) When a is a multiple of p, both sides are 0 (mod p) When a is not a multiple of p, this result follows from Thm 20 by multiplying both sides by a Conversely, Thm 20 follows from a p a (mod p) by multiplying both sides by a 1, which exists whenever a is not a multiple of p The converse of Fermat s Theorem is unfortunately not true there are numbers n which are not prime, and yet, for all a co-prime to n, a n 1 1 (mod n) Korselt did some work on these numbers in 1899, but the first example, 561, was found by Robert Daniel Carmichael in 1910, and they are now known as Carmichael numbers 22 Wilson s Theorem If p is prime, then (p 1)! 1 (mod p) Proof: If p = 2, then (2 1)! = 1, and 1 + 1 = 2 0 (mod 2) So we consider the odd primes p > 2 Since p is prime, the numbers 1, 2,, p 1 are all co-prime to p, and therefore form a group Z p under multiplication mod p In particular, every one of these numbers has an inverse Note that 1 and p 1 are their own inverses, since 1 2 = 1, and (p 1) 2 = p 2 2p + 1 1 We claim that these are the only such elements in Z p If some k is its own inverse, we have k 2 1 (k 1)(k + 1) = k 2 1 0 (mod p) This means that (k 1)(k + 1) is a multiple of p, and since p is prime, either k 1 or k + 1 is a multiple of p Thus k 1 (mod p) or 8

k 1 p 1 (mod p), as claimed In other words, for 1 < k < p 1, we have k k 1 So we can list the elements of Z p as: 1, m 1, m 1 1, m 2, m 1 2,, m s, m 1, p 1 Therefore (p 1)! = 1 2 (p 1) = 1 m 1 m 1 1 m 2 m 1 2 m s m 1 s (p 1) 1 1 1 1 ( 1) (mod p) s 23 The theorem was first discovered by Ibn al-haytham (also known as Alhazen), but it is named after John Wilson (a student of the English mathematician Edward Waring) who rediscovered it more than 700 years later Waring announced the theorem in 1770, although neither he nor Wilson could prove it Lagrange gave the first proof in 1773 There is evidence that Leibniz was also aware of the result a century earlier, but he never published it Are the following statements true? And if so, is the reasoning correct? Since 1 9 (mod 10), Wilson s Theorem tells us that 9! is of the form 10k + 9, ie its last digit is 9 Similarly, 1 999, 999 (mod 1, 000, 000), so even without working out 999, 999! we know that it is of the form 1, 000, 000k +999, 999, that is, its last six digits are 999, 999 Is the converse of Wilson s Theorem true? 9