Fermat's Little Theorem

Similar documents
CS 5319 Advanced Discrete Structure. Lecture 9: Introduction to Number Theory II

Wilson s Theorem and Fermat s Little Theorem

Fall 2017 Test II review problems

7. Prime Numbers Part VI of PJE

Number Theory Homework.

MAT246H1S - Concepts In Abstract Mathematics. Solutions to Term Test 1 - February 1, 2018

CSE 20 DISCRETE MATH. Fall

PUTNAM TRAINING NUMBER THEORY. Exercises 1. Show that the sum of two consecutive primes is never twice a prime.

1 Overview and revision

An integer p is prime if p > 1 and p has exactly two positive divisors, 1 and p.

CSC 344 Algorithms and Complexity. Proof by Mathematical Induction

a 2 = ab a 2 b 2 = ab b 2 (a + b)(a b) = b(a b) a + b = b

All variables a, b, n, etc are integers unless otherwise stated. Each part of a problem is worth 5 points.

CSE 20 DISCRETE MATH. Winter

Sums of Squares. Bianca Homberg and Minna Liu

Math 261 Spring 2014 Final Exam May 5, 2014

MATH 433 Applied Algebra Lecture 4: Modular arithmetic (continued). Linear congruences.

9 Modular Exponentiation and Square-Roots

Notes on Systems of Linear Congruences

Math 109 HW 9 Solutions

ALGEBRA. 1. Some elementary number theory 1.1. Primes and divisibility. We denote the collection of integers

CIS 6930/4930 Computer and Network Security. Topic 5.1 Basic Number Theory -- Foundation of Public Key Cryptography

2.3 In modular arithmetic, all arithmetic operations are performed modulo some integer.

Basic Proof Examples

2x 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?

Primes and Modular Arithmetic! CSCI 2824, Fall 2014!!

Number Theory A focused introduction

MATH 501 Discrete Mathematics. Lecture 6: Number theory. German University Cairo, Department of Media Engineering and Technology.

Solutions to Practice Final

Modular Arithmetic Instructor: Marizza Bailey Name:

Definition 6.1 (p.277) A positive integer n is prime when n > 1 and the only positive divisors are 1 and n. Alternatively

Number 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:

CSE 20 DISCRETE MATH. Winter

2x 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?

Lecture Notes. Advanced Discrete Structures COT S

CHAPTER 6. Prime Numbers. Definition and Fundamental Results

Today. Polynomials. Secret Sharing.

MATH 115, SUMMER 2012 LECTURE 12

Number Theory, Algebra and Analysis. William Yslas Vélez Department of Mathematics University of Arizona

Wednesday, February 21. Today we will begin Course Notes Chapter 5 (Number Theory).

* 8 Groups, with Appendix containing Rings and Fields.

Number theory (Chapter 4)

Course 2BA1: Trinity 2006 Section 9: Introduction to Number Theory and Cryptography

Mathematics 228(Q1), Assignment 2 Solutions

MATH 2200 Final Review

Instructor: Bobby Kleinberg Lecture Notes, 25 April The Miller-Rabin Randomized Primality Test

Course MA2C02, Hilary Term 2013 Section 9: Introduction to Number Theory and Cryptography

Math 110 HW 3 solutions

1. Algebra 1.7. Prime numbers

THE DIVISION THEOREM IN Z AND R[T ]

MATH 361: NUMBER THEORY FOURTH LECTURE

CMSC Discrete Mathematics SOLUTIONS TO FIRST MIDTERM EXAM October 18, 2005 posted Nov 2, 2005

DIVISIBILITY OF BINOMIAL COEFFICIENTS AT p = 2

7.2 Applications of Euler s and Fermat s Theorem.

Congruences. September 16, 2006

Solutions to Assignment 1

64 P. ERDOS AND E. G. STRAUS It is possible that (1.1) has only a finite number of solutions for fixed t and variable k > 2, but we cannot prove this

= 1 2x. x 2 a ) 0 (mod p n ), (x 2 + 2a + a2. x a ) 2

Part V. Chapter 19. Congruence of integers

Know the Well-ordering principle: Any set of positive integers which has at least one element contains a smallest element.

CS280, Spring 2004: Prelim Solutions

COMP239: Mathematics for Computer Science II. Prof. Chadi Assi EV7.635

Ma/CS 6a Class 2: Congruences

1. (16 points) Circle T if the corresponding statement is True or F if it is False.

Elementary Properties of the Integers

3 The fundamentals: Algorithms, the integers, and matrices

Name (please print) Mathematics Final Examination December 14, 2005 I. (4)

3.4. ZEROS OF POLYNOMIAL FUNCTIONS

Carmen s Core Concepts (Math 135)

Chapter 1 : The language of mathematics.

Lecture 5: Arithmetic Modulo m, Primes and Greatest Common Divisors Lecturer: Lale Özkahya

Clock Arithmetic. 1. If it is 9 o clock and you get out of school in 4 hours, when do you get out of school?

The Pigeonhole Principle

OWO Lecture: Modular Arithmetic with Algorithmic Applications

Finite Fields: An introduction through exercises Jonathan Buss Spring 2014

CSE 1400 Applied Discrete Mathematics Proofs

NOTES ON SIMPLE NUMBER THEORY

Solutions Quiz 9 Nov. 8, Prove: If a, b, m are integers such that 2a + 3b 12m + 1, then a 3m + 1 or b 2m + 1.

Adam Blank Spring 2017 CSE 311. Foundations of Computing I. * All slides are a combined effort between previous instructors of the course

Applied Cryptography and Computer Security CSE 664 Spring 2018

Integers and Division

Number Theory Solutions Packet

a the relation arb is defined if and only if = 2 k, k

Chapter 3 Basic Number Theory

2 Arithmetic. 2.1 Greatest common divisors. This chapter is about properties of the integers Z = {..., 2, 1, 0, 1, 2,...}.

Part IA Numbers and Sets

I Foundations Of Divisibility And Congruence 1

Ma/CS 6a Class 2: Congruences

CS 360, Winter Morphology of Proof: An introduction to rigorous proof techniques

EULER S THEOREM KEITH CONRAD

Part IA Numbers and Sets

Discrete Mathematics and Probability Theory Summer 2015 Chung-Wei Lin Midterm 1

ax b mod m. has a solution if and only if d b. In this case, there is one solution, call it x 0, to the equation and there are d solutions x m d

4 Number Theory and Cryptography

This is a recursive algorithm. The procedure is guaranteed to terminate, since the second argument decreases each time.

1. Prove that the number cannot be represented as a 2 +3b 2 for any integers a and b. (Hint: Consider the remainder mod 3).

NORTHWESTERN UNIVERSITY Thrusday, Oct 6th, 2011 ANSWERS FALL 2011 NU PUTNAM SELECTION TEST

MATH 215 Final. M4. For all a, b in Z, a b = b a.

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

Math 511, Algebraic Systems, Fall 2017 July 20, 2017 Edition. Todd Cochrane

Transcription:

Fermat's Little Theorem CS 2800: Discrete Structures, Spring 2015 Sid Chaudhuri

Not to be confused with... Fermat's Last Theorem: x n + y n = z n has no integer solution for n > 2

Recap: Modular Arithmetic Definition: a b (mod m) if and only if m a b Consequences: a b (mod m) iff a mod m = b mod m (Congruence Same remainder) If a b (mod m) and c d (mod m), then a + c b + d (mod m) ac bd (mod m) (Congruences can sometimes be treated like equations)

Fermat's Little Theorem If p is a prime number, and a is any integer, then a p a (mod p)

Fermat's Little Theorem If p is a prime number, and a is any integer, then a p a (mod p) If a is not divisible by p, then a p 1 1 (mod p)

Fermat's Little Theorem Examples: 21 7 21 (mod 7) but 21 6 1 (mod 7) 111 12 1 (mod 13) 123,456,789 257,885,161 2 1 (mod 2 57,885,161 1)

Two proofs Combinatorial counting things Algebraic induction We'll consider only non-negative a the result for non-negative a can be extended to negative integers (try it using what we know of congruences!)

Counting necklaces Due to Solomon W. Golomb, 1956 Basic idea: a p suggests we see how to fill p buckets, where each is filled with one of a objects a objects p buckets

Strings of beads Each way of filling the buckets gives a different sequence of p objects ( beads ) a p such sequences S = 1 S = 2 S = 3

Strings of beads Now string the beads together...

Strings of beads and join the ends to form necklaces

A necklace rotated... is the same necklace Different strings can produce the same necklace when the ends are joined = =

Two types of necklaces Containing beads of a single color

Two types of necklaces Containing beads of a single color Only one possible string

Two types of necklaces Containing beads of different colors Many possible strings

Lemma If p is a prime number and N is a necklace with at least two colors, every rotation of N corresponds to a different string i.e. there are exactly p different strings that form the same necklace N

Proof of Lemma First, note that each string corresponds to a rotation of the necklace, and then... cutting it at a fixed point

Proof of Lemma No more than p strings can give the same necklace There are only p (say clockwise) rotations of the necklace (that align the beads) before we loop back to the original orientation

Proof of Lemma Now we'll show that no less than p strings give the same necklace

Proof of Lemma Now we'll show that no less than p strings give the same necklace Consider clockwise rotations by 1/p of a full circle

Proof of Lemma Now we'll show that no less than p strings give the same necklace Consider clockwise rotations by 1/p of a full circle Let k be the minimum number of such rotations before the original configuration is repeated

Proof of Lemma Now we'll show that no less than p strings give the same necklace Consider clockwise rotations by 1/p of a full circle Let k be the minimum number of such rotations before the original configuration is repeated Clearly, k p (p rotations bring us back to the start)

Proof of Lemma Now we'll show that no less than p strings give the same necklace Consider clockwise rotations by 1/p of a full circle Let k be the minimum number of such rotations before the original configuration is repeated Clearly, k p (p rotations bring us back to the start) Claim: k p

Claim: k p Proof of Claim

Proof of Claim Claim: k p Proof: Let p = qk + r, with 0 r < k (division algorithm)

Proof of Claim Claim: k p Proof: Let p = qk + r, with 0 r < k (division algorithm) q iterations, each of k rotations, restores the original configuration (by definition of k)

Proof of Claim Claim: k p Proof: Let p = qk + r, with 0 r < k (division algorithm) q iterations, each of k rotations, restores the original configuration (by definition of k) So do p rotations (full circle)

Proof of Claim Claim: k p Proof: Let p = qk + r, with 0 r < k (division algorithm) q iterations, each of k rotations, restores the original configuration (by definition of k) So do p rotations (full circle) therefore so do r rotations

Proof of Claim Claim: k p Proof: Let p = qk + r, with 0 r < k (division algorithm) q iterations, each of k rotations, restores the original configuration (by definition of k) So do p rotations (full circle) therefore so do r rotations But r < k and we said k was the minimum period!

Proof of Claim Claim: k p Proof: Let p = qk + r, with 0 r < k (division algorithm) q iterations, each of k rotations, restores the original configuration (by definition of k) So do p rotations (full circle) therefore so do r rotations But r < k and we said k was the minimum period! which is a contradiction, unless r = 0

Proof of Lemma Since k p and k p and p is prime, we must have either

Proof of Lemma Since k p and k p and p is prime, we must have either k = 1 (impossible if necklace has at least two colors)

Proof of Lemma Since k p and k p and p is prime, we must have either k = 1 (impossible if necklace has at least two colors) or k = p

Proof of Lemma Since k p and k p and p is prime, we must have either k = 1 (impossible if necklace has at least two colors) or k = p This proves the lemma

What we have so far

What we have so far Necklaces with one color

What we have so far Necklaces with one color a such strings (one for each color), therefore a such necklaces

What we have so far Necklaces with one color a such strings (one for each color), therefore a such necklaces Necklaces with multiple colors

What we have so far Necklaces with one color a such strings (one for each color), therefore a such necklaces Necklaces with multiple colors Each corresponds to p different strings

What we have so far Necklaces with one color a such strings (one for each color), therefore a such necklaces Necklaces with multiple colors Each corresponds to p different strings a p a strings of multiple colors, therefore (a p a) / p such necklaces

What we have so far Necklaces with one color a such strings (one for each color), therefore a such necklaces Necklaces with multiple colors Each corresponds to p different strings a p a strings of multiple colors, therefore (a p a) / p such necklaces p a p a (can't have half a necklace)

What we have so far Necklaces with one color a such strings (one for each color), therefore a such necklaces Necklaces with multiple colors Each corresponds to p different strings a p a strings of multiple colors, therefore (a p a) / p such necklaces p a p a (can't have half a necklace) a p a (mod p) QED!

Another proof (algebraic)

Another proof (algebraic) For a given prime p, we'll do induction on a

Another proof (algebraic) For a given prime p, we'll do induction on a Base case: Clear that 0 p 0 (mod p)

Another proof (algebraic) For a given prime p, we'll do induction on a Base case: Clear that 0 p 0 (mod p) Inductive hypothesis: a p a (mod p)

Another proof (algebraic) For a given prime p, we'll do induction on a Base case: Clear that 0 p 0 (mod p) Inductive hypothesis: a p a (mod p) Consider (a + 1) p

Another proof (algebraic) For a given prime p, we'll do induction on a Base case: Clear that 0 p 0 (mod p) Inductive hypothesis: a p a (mod p) Consider (a + 1) p By the Binomial Theorem, (a+1) p =a p + ( p 1) a p 1 + ( p 2) ap 2 + ( p 3) a p 3 +...+ ( p p 1) a+1

Another proof (algebraic) For a given prime p, we'll do induction on a Base case: Clear that 0 p 0 (mod p) Inductive hypothesis: a p a (mod p) Consider (a + 1) p By the Binomial Theorem, (a+1) p =a p + ( p 1) a p 1 + ( p 2) ap 2 + ( p 3) a p 3 +...+ ( p p 1) a+1 All RHS terms except last & perhaps first are divisible by p

Another proof (algebraic) For a given prime p, we'll do induction on a Base case: Clear that 0 p 0 (mod p) Inductive hypothesis: a p a (mod p) Consider (a + 1) p By the Binomial Theorem, Binomial coefficient ( p ) k is p!/ k!(p k)!, which is always an integer. p is prime, so it isn't canceled out by terms in the denominator (a+1) p =a p + ( p 1) a p 1 + ( p 2) ap 2 + ( p 3) a p 3 +...+ ( p p 1) a+1 All RHS terms except last & perhaps first are divisible by p

Another proof (algebraic) Therefore (a + 1) p a p + 1 (mod p)

Another proof (algebraic) Therefore (a + 1) p a p + 1 (mod p) But by the inductive hypothesis, a p a (mod p)

Another proof (algebraic) Therefore (a + 1) p a p + 1 (mod p) But by the inductive hypothesis, a p a (mod p) a p + 1 a + 1 (mod p) (properties of congruence)

Another proof (algebraic) Therefore (a + 1) p a p + 1 (mod p) But by the inductive hypothesis, a p a (mod p) a p + 1 a + 1 (mod p) (properties of congruence) Therefore (a + 1) p a + 1 (mod p)

Another proof (algebraic) Therefore (a + 1) p a p + 1 (mod p) But by the inductive hypothesis, a p a (mod p) a p + 1 a + 1 (mod p) (properties of congruence) Therefore (a + 1) p a + 1 (mod p) (congruence is transitive prove!)

Another proof (algebraic) Therefore (a + 1) p a p + 1 (mod p) But by the inductive hypothesis, a p a (mod p) a p + 1 a + 1 (mod p) (properties of congruence) Therefore (a + 1) p a + 1 (mod p) Hence proved by induction (congruence is transitive prove!)