# Difference between revisions of "Fermat's Little Theorem"

(→Proof 3 (Combinatorics)) |
(→Proof 3 (Combinatorics)) |
||

(25 intermediate revisions by 19 users not shown) | |||

Line 8: | Line 8: | ||

A frequently used corollary of Fermat's Little Theorem is <math> a^p \equiv a \pmod {p}</math>. As you can see, it is derived by multipling both sides of the theorem by <math>a</math>. The restated form is nice because we no longer need to restrict ourselves to integers <math>{a}</math> not divisible by <math>{p}</math>. | A frequently used corollary of Fermat's Little Theorem is <math> a^p \equiv a \pmod {p}</math>. As you can see, it is derived by multipling both sides of the theorem by <math>a</math>. The restated form is nice because we no longer need to restrict ourselves to integers <math>{a}</math> not divisible by <math>{p}</math>. | ||

− | This theorem is a special case of [[Euler's Totient Theorem]], which states that if <math>a</math> and <math>n</math> are integers, then <math>a^{\varphi(n)} \equiv 1 \pmod{ | + | This theorem is a special case of [[Euler's Totient Theorem]], which states that if <math>a</math> and <math>n</math> are integers, then <math>a^{\varphi(n)} \equiv 1 \pmod{n}</math>, where <math>\varphi(n)</math> denotes [[Euler's totient function]]. In particular, <math>\varphi(p) = p-1</math> for prime numbers <math>p</math>. In turn, this is a special case of [[Lagrange's Theorem]]. |

− | In contest problems, Fermat's Little Theorem is often used in conjunction with the [[Chinese Remainder Theorem]] to simplify tedious | + | In contest problems, Fermat's Little Theorem is often used in conjunction with the [[Chinese Remainder Theorem]] to simplify tedious calculations. |

== Proof == | == Proof == | ||

Line 31: | Line 31: | ||

<center><cmath>S \equiv \{1a, 2a, \cdots, (p-1)a\} \pmod{p}.</cmath></center><br> | <center><cmath>S \equiv \{1a, 2a, \cdots, (p-1)a\} \pmod{p}.</cmath></center><br> | ||

− | Clearly none of the <math>ia</math> for <math>1 \le i \le p-1</math> are divisible by <math>p</math>, so it suffices to show that all of the elements in <math>a \cdot S</math> are distinct. Suppose that <math>ai \equiv aj \pmod{p} | + | Clearly none of the <math>ia</math> for <math>1 \le i \le p-1</math> are divisible by <math>p</math>, so it suffices to show that all of the elements in <math>a \cdot S</math> are distinct. Suppose that <math>ai \equiv aj \pmod{p}</math>. Since <math>\text{gcd}\, (a,p) = 1</math>, by the cancellation rule, that reduces to <math>i \equiv j \pmod{p},</math> which means <math>i = j</math> as <math>1 \leq i, j \leq p-1.</math> |

Thus, <math>\mod{p}</math>, we have that the product of the elements of <math>S</math> is | Thus, <math>\mod{p}</math>, we have that the product of the elements of <math>S</math> is | ||

Line 55: | Line 55: | ||

pen BEADS1[] = {red,red,red},BEADS2[] = {blue,blue,blue},BEADS3[] = {red,red,blue},BEADS4[] = {blue,red,red},BEADS5[] = {red,blue,red},BEADS6[] = {blue,blue,red},BEADS7[] = {red,blue,blue},BEADS8[] = {blue,red,blue}; | pen BEADS1[] = {red,red,red},BEADS2[] = {blue,blue,blue},BEADS3[] = {red,red,blue},BEADS4[] = {blue,red,red},BEADS5[] = {red,blue,red},BEADS6[] = {blue,blue,red},BEADS7[] = {red,blue,blue},BEADS8[] = {blue,red,blue}; | ||

necklace((-1.5,row1),BEADS1);necklace((1.5,row1),BEADS2);necklace((-2.5,row2),BEADS3);necklace((0,row2),BEADS4);necklace((2.5,row2),BEADS5);necklace((-2.5,row3),BEADS6);necklace((0,row3),BEADS7);necklace((2.5,row3),BEADS8); | necklace((-1.5,row1),BEADS1);necklace((1.5,row1),BEADS2);necklace((-2.5,row2),BEADS3);necklace((0,row2),BEADS4);necklace((2.5,row2),BEADS5);necklace((-2.5,row3),BEADS6);necklace((0,row3),BEADS7);necklace((2.5,row3),BEADS8); | ||

− | </asy><br> An illustration of the case <math> | + | </asy><br> An illustration of the case <math>p=3,a=2</math>.<br></center> |

Consider a necklace with <math>p</math> beads, each bead of which can be colored in <math>a</math> different ways. There are <math>a^p</math> ways to pick the colors of the beads. <math>a</math> of these are necklaces that consists of beads of the same color. Of the remaining necklaces, for each necklace, there are exactly <math>p-1</math> more necklaces that are rotationally equivalent to this necklace. It follows that <math>a^p-a</math> must be divisible by <math>p</math>. Written in another way, <math>a^p \equiv a \pmod{p}</math>. | Consider a necklace with <math>p</math> beads, each bead of which can be colored in <math>a</math> different ways. There are <math>a^p</math> ways to pick the colors of the beads. <math>a</math> of these are necklaces that consists of beads of the same color. Of the remaining necklaces, for each necklace, there are exactly <math>p-1</math> more necklaces that are rotationally equivalent to this necklace. It follows that <math>a^p-a</math> must be divisible by <math>p</math>. Written in another way, <math>a^p \equiv a \pmod{p}</math>. | ||

+ | |||

+ | [https://www.khanacademy.org/computing/computer-science/cryptography/random-algorithms-probability/v/fermat-s-little-theorem-visualization Video explanation] | ||

=== Proof 4 (Geometry) === | === Proof 4 (Geometry) === | ||

Line 95: | Line 97: | ||

<cmath>P(x_1, x_2, \ldots, x_n) \mapsto P(x_2, x_3, \ldots, x_n, x_1)</cmath><br> | <cmath>P(x_1, x_2, \ldots, x_n) \mapsto P(x_2, x_3, \ldots, x_n, x_1)</cmath><br> | ||

− | maps one unit hypercube to a distinct hypercube. Much like the combinatorial proof, this splits the non-main diagonal unit hypercubes into groups of size <math>p</math>, from which it follows that <math>a^p \equiv a \pmod{p}</math>. Thus, we have another way to visualize the above combinatorial proof, by imagining the described transformation to be, in a sense, a rotation about the main diagonal of the hypercube. | + | maps one unit hypercube to a distinct hypercube. Much like the combinatorial proof, this splits the non-main diagonal unit hypercubes into groups of size <math>p</math>, from which it follows that <math>a^p \equiv a \pmod{p}</math>. Thus, we have another way to visualize the above combinatorial proof, by imagining the described transformation to be, in a sense, a rotation about the main diagonal of the hypercube. |

== Problems == | == Problems == | ||

Line 108: | Line 110: | ||

* One of Euler's conjectures was disproved in the 1960s by three American mathematicians when they showed there was a positive integer such that <math>133^5+110^5+84^5+27^5=n^5</math>. Find the value of <math>{n}</math>. ([[1989 AIME Problems/Problem 9|1989 AIME, #9]])<br><br> | * One of Euler's conjectures was disproved in the 1960s by three American mathematicians when they showed there was a positive integer such that <math>133^5+110^5+84^5+27^5=n^5</math>. Find the value of <math>{n}</math>. ([[1989 AIME Problems/Problem 9|1989 AIME, #9]])<br><br> | ||

− | *If <math>f(x) = x^{x^{x^x}}</math>, find the last two digits of <math>f(17) + f(18) + f(19) + f(20)</math>. ([ | + | *If <math>f(x) = x^{x^{x^x}}</math>, find the last two digits of <math>f(17) + f(18) + f(19) + f(20)</math>. ([https://pumac.princeton.edu/info/archives/pumac-2008/ 2008 PUMaC, NT A#5]) |

=== Advanced === | === Advanced === | ||

− | * | + | *Is it true that if <math>p</math> is a prime number, and <math>k</math> is an integer <math>2 \le k \le p</math>, then the sum of the products of each <math>k</math>-element subset of <math>\{1, 2, \ldots, p\}</math> will be divisible by <math>p</math>? <br><br> |

== Hints/Solutions == | == Hints/Solutions == | ||

Line 131: | Line 133: | ||

Advanced: | Advanced: | ||

* Hint: try to establish the identity <math>x^{p} - x \equiv x(x-1)(x-2) \cdots (x-(p-1)) \pmod{p}</math>, and then apply [[Vieta's formulas]]. | * Hint: try to establish the identity <math>x^{p} - x \equiv x(x-1)(x-2) \cdots (x-(p-1)) \pmod{p}</math>, and then apply [[Vieta's formulas]]. | ||

+ | |||

+ | ==Extensions== | ||

+ | |||

+ | If <math>{a}</math> is an [[integer]], <math>{p}</math> is a [[prime number]] and <math>{a}</math> is not [[divisibility|divisible]] by <math>{p}</math>, then <math>a^{(p-1)k}\equiv 1 \pmod {p}</math>. | ||

+ | |||

+ | The above follows from the exponent rule <math>(a^b)^c=a^{bc}</math> | ||

+ | |||

+ | An extension of the Collary given above is that : | ||

+ | <cmath>(a^p)^w \equiv a^w \pmod {p}</cmath> | ||

+ | |||

+ | Immediately by normal exponent rules, it follows that if: <cmath>z=(d_1d_2\ldots d_f)_p</cmath> Then, <cmath>a^z\equiv a^{d_1+d_2+\cdots +d_f}\pmod p</cmath> Which means, by repeating the process, we have that we can reduce the exponent to its digital root base <math>p</math> . | ||

+ | |||

+ | |||

+ | |||

== See also == | == See also == |

## Latest revision as of 02:02, 15 October 2020

**Fermat's Little Theorem** is highly useful in number theory for simplifying the computation of exponents in modular arithmetic (which students should study more at the introductory level if they have a hard time following the rest of this article). This theorem is credited to Pierre de Fermat.

## Contents

## Statement

If is an integer, is a prime number and is not divisible by , then .

A frequently used corollary of Fermat's Little Theorem is . As you can see, it is derived by multipling both sides of the theorem by . The restated form is nice because we no longer need to restrict ourselves to integers not divisible by .

This theorem is a special case of Euler's Totient Theorem, which states that if and are integers, then , where denotes Euler's totient function. In particular, for prime numbers . In turn, this is a special case of Lagrange's Theorem.

In contest problems, Fermat's Little Theorem is often used in conjunction with the Chinese Remainder Theorem to simplify tedious calculations.

## Proof

We offer several proofs using different techniques to prove the statement . If , then we can cancel a factor of from both sides and retrieve the first version of the theorem.

### Proof 1 (Induction)

The most straightforward way to prove this theorem is by by applying the induction principle. We fix as a prime number. The base case, , is obviously true. Suppose the statement is true. Then, by the binomial theorem,

Note that divides into any binomial coefficient of the form for . This follows by the definition of the binomial coefficient as ; since is prime, then divides the numerator, but not the denominator.

Taken , all of the middle terms disappear, and we end up with . Since we also know that , then , as desired.

### Proof 2 (Inverses)

Let . Then, we claim that the set , consisting of the product of the elements of with , taken modulo , is simply a permutation of . In other words,

Clearly none of the for are divisible by , so it suffices to show that all of the elements in are distinct. Suppose that . Since , by the cancellation rule, that reduces to which means as

Thus, , we have that the product of the elements of is

Cancelling the factors from both sides, we are left with the statement .

A similar version can be used to prove Euler's Totient Theorem, if we let .

### Proof 3 (Combinatorics)

An illustration of the case .

Consider a necklace with beads, each bead of which can be colored in different ways. There are ways to pick the colors of the beads. of these are necklaces that consists of beads of the same color. Of the remaining necklaces, for each necklace, there are exactly more necklaces that are rotationally equivalent to this necklace. It follows that must be divisible by . Written in another way, .

### Proof 4 (Geometry)

We imbed a hypercube of side length in (the -th dimensional Euclidean space), such that the vertices of the hypercube are at . A hypercube is essentially a cube, generalized to higher dimensions. This hypercube consists of separate unit hypercubes, with centers consisting of the points

where each is an integer from to . Besides the centers of the unit hypercubes in the main diagonal (from to ), the transformation carrying

maps one unit hypercube to a distinct hypercube. Much like the combinatorial proof, this splits the non-main diagonal unit hypercubes into groups of size , from which it follows that . Thus, we have another way to visualize the above combinatorial proof, by imagining the described transformation to be, in a sense, a rotation about the main diagonal of the hypercube.

## Problems

### Introductory

- Compute some examples, for example find , and , and check your answers by calculator where possible.

- Let . What is the units digit of ? (2008 AMC 12A Problems/Problem 15)

- Find mod . (Discussion).

### Intermediate

- One of Euler's conjectures was disproved in the 1960s by three American mathematicians when they showed there was a positive integer such that . Find the value of . (1989 AIME, #9)

- If , find the last two digits of . (2008 PUMaC, NT A#5)

### Advanced

- Is it true that if is a prime number, and is an integer , then the sum of the products of each -element subset of will be divisible by ?

## Hints/Solutions

Introductory:

- Hint: For the first example, we have by FLT (Fermat's Little Theorem). It follows that .

Intermediate:

- Solution (1989 AIME, 9) To solve this problem, it would be nice to know some information about the remainders can have after division by certain numbers. By Fermat's Little Theorem, we know is congruent to modulo 5. Hence,

- Continuing, we examine the equation modulo 3,

- Thus, is divisible by three and leaves a remainder of four when divided by 5. It's obvious that , so the only possibilities are or . It quickly becomes apparent that 174 is much too large, so must be 144.

Advanced:

- Hint: try to establish the identity , and then apply Vieta's formulas.

## Extensions

If is an integer, is a prime number and is not divisible by , then .

The above follows from the exponent rule

An extension of the Collary given above is that :

Immediately by normal exponent rules, it follows that if: Then, Which means, by repeating the process, we have that we can reduce the exponent to its digital root base .