Proofs of Fermat's little theorem

From Wikipedia, the free encyclopedia
Jump to navigation Jump to search

Template:Short description This article collects together a variety of proofs of Fermat's little theorem, which states that

apa(modp)

for every prime number p and every integer a (see modular arithmetic).

Simplifications

Some of the proofs of Fermat's little theorem given below depend on two simplifications.

The first is that we may assume that Template:Mvar is in the range 0 ≤ ap − 1Script error: No such module "Check for unknown parameters".. This is a simple consequence of the laws of modular arithmetic; we are simply saying that we may first reduce Template:Mvar modulo Template:Mvar. This is consistent with reducing ap modulo Template:Mvar, as one can check.

Secondly, it suffices to prove that

ap11(modp)

for Template:Mvar in the range 1 ≤ ap − 1Script error: No such module "Check for unknown parameters".. Indeed, if the previous assertion holds for such Template:Mvar, multiplying both sides by aScript error: No such module "Check for unknown parameters". yields the original form of the theorem,

apa(modp)

On the other hand, if a = 0Script error: No such module "Check for unknown parameters"., the theorem holds trivially.

Combinatorial proofs

Proof by counting necklaces

This is perhaps the simplest known proof, requiring the least mathematical background. It is an attractive example of a combinatorial proof (a proof that involves counting a collection of objects in two different ways).

The proof given here is an adaptation of Golomb's proof.[1]

To keep things simple, let us assume that Template:Mvar is a positive integer. Consider all the possible strings of pScript error: No such module "Check for unknown parameters". symbols, using an alphabet with Template:Mvar different symbols. The total number of such strings is apScript error: No such module "Check for unknown parameters". since there are Template:Mvar possibilities for each of Template:Mvar positions (see rule of product).

For example, if p = 5Script error: No such module "Check for unknown parameters". and a = 2Script error: No such module "Check for unknown parameters"., then we can use an alphabet with two symbols (say Template:Mvar and Template:Mvar), and there are 25 = 32Script error: No such module "Check for unknown parameters". strings of length 5:

AAAAAScript error: No such module "Check for unknown parameters"., AAAABScript error: No such module "Check for unknown parameters"., AAABAScript error: No such module "Check for unknown parameters"., AAABBScript error: No such module "Check for unknown parameters"., AABAAScript error: No such module "Check for unknown parameters"., AABABScript error: No such module "Check for unknown parameters"., AABBAScript error: No such module "Check for unknown parameters"., AABBBScript error: No such module "Check for unknown parameters".,
ABAAAScript error: No such module "Check for unknown parameters"., ABAABScript error: No such module "Check for unknown parameters"., ABABAScript error: No such module "Check for unknown parameters"., ABABBScript error: No such module "Check for unknown parameters"., ABBAAScript error: No such module "Check for unknown parameters"., ABBABScript error: No such module "Check for unknown parameters"., ABBBAScript error: No such module "Check for unknown parameters"., ABBBBScript error: No such module "Check for unknown parameters".,
BAAAAScript error: No such module "Check for unknown parameters"., BAAABScript error: No such module "Check for unknown parameters"., BAABAScript error: No such module "Check for unknown parameters"., BAABBScript error: No such module "Check for unknown parameters"., BABAAScript error: No such module "Check for unknown parameters"., BABABScript error: No such module "Check for unknown parameters"., BABBAScript error: No such module "Check for unknown parameters"., BABBBScript error: No such module "Check for unknown parameters".,
BBAAAScript error: No such module "Check for unknown parameters"., BBAABScript error: No such module "Check for unknown parameters"., BBABAScript error: No such module "Check for unknown parameters"., BBABBScript error: No such module "Check for unknown parameters"., BBBAAScript error: No such module "Check for unknown parameters"., BBBABScript error: No such module "Check for unknown parameters"., BBBBAScript error: No such module "Check for unknown parameters"., BBBBBScript error: No such module "Check for unknown parameters"..

We will argue below that if we remove the strings consisting of a single symbol from the list (in our example, AAAAAScript error: No such module "Check for unknown parameters". and BBBBBScript error: No such module "Check for unknown parameters".), the remaining apaScript error: No such module "Check for unknown parameters". strings can be arranged into groups, each group containing exactly Template:Mvar strings. It follows that apaScript error: No such module "Check for unknown parameters". is divisible by Template:Mvar.

Necklaces

File:Proofs-of-Fermats-Little-Theorem-bracelet1.svg
Necklace representing seven different strings (ABCBAACScript error: No such module "Check for unknown parameters"., BCBAACAScript error: No such module "Check for unknown parameters"., CBAACABScript error: No such module "Check for unknown parameters"., BAACABCScript error: No such module "Check for unknown parameters"., AACABCBScript error: No such module "Check for unknown parameters"., ACABCBAScript error: No such module "Check for unknown parameters"., CABCBAAScript error: No such module "Check for unknown parameters".)
File:Proofs-of-Fermats-Little-Theorem-bracelet2.svg
Necklace representing only one string (AAAAAAAScript error: No such module "Check for unknown parameters".)

Let us think of each such string as representing a necklace. That is, we connect the two ends of the string together and regard two strings as the same necklace if we can rotate one string to obtain the second string; in this case we will say that the two strings are friends. In our example, the following strings are all friends:

AAAABScript error: No such module "Check for unknown parameters"., AAABAScript error: No such module "Check for unknown parameters"., AABAAScript error: No such module "Check for unknown parameters"., ABAAAScript error: No such module "Check for unknown parameters"., BAAAAScript error: No such module "Check for unknown parameters"..

In full, each line of the following list corresponds to a single necklace, and the entire list comprises all 32 strings.

AAAABScript error: No such module "Check for unknown parameters"., AAABAScript error: No such module "Check for unknown parameters"., AABAAScript error: No such module "Check for unknown parameters"., ABAAAScript error: No such module "Check for unknown parameters"., BAAAAScript error: No such module "Check for unknown parameters".,
AAABBScript error: No such module "Check for unknown parameters"., AABBAScript error: No such module "Check for unknown parameters"., ABBAAScript error: No such module "Check for unknown parameters"., BBAAAScript error: No such module "Check for unknown parameters"., BAAABScript error: No such module "Check for unknown parameters".,
AABABScript error: No such module "Check for unknown parameters"., ABABAScript error: No such module "Check for unknown parameters"., BABAAScript error: No such module "Check for unknown parameters"., ABAABScript error: No such module "Check for unknown parameters"., BAABAScript error: No such module "Check for unknown parameters".,
AABBBScript error: No such module "Check for unknown parameters"., ABBBAScript error: No such module "Check for unknown parameters"., BBBAAScript error: No such module "Check for unknown parameters"., BBAABScript error: No such module "Check for unknown parameters"., BAABBScript error: No such module "Check for unknown parameters".,
ABABBScript error: No such module "Check for unknown parameters"., BABBAScript error: No such module "Check for unknown parameters"., ABBABScript error: No such module "Check for unknown parameters"., BBABAScript error: No such module "Check for unknown parameters"., BABABScript error: No such module "Check for unknown parameters".,
ABBBBScript error: No such module "Check for unknown parameters"., BBBBAScript error: No such module "Check for unknown parameters"., BBBABScript error: No such module "Check for unknown parameters"., BBABBScript error: No such module "Check for unknown parameters"., BABBBScript error: No such module "Check for unknown parameters".,
AAAAAScript error: No such module "Check for unknown parameters".,
BBBBBScript error: No such module "Check for unknown parameters"..

Notice that in the above list, each necklace with more than one symbol is represented by 5 different strings, and the number of necklaces represented by just one string is 2, i.e. is the number of distinct symbols. Thus the list shows very clearly why 32 − 2Script error: No such module "Check for unknown parameters". is divisible by 5Script error: No such module "Check for unknown parameters"..

One can use the following rule to work out how many friends a given string SScript error: No such module "Check for unknown parameters". has:

If SScript error: No such module "Check for unknown parameters". is built up of several copies of the string TScript error: No such module "Check for unknown parameters"., and TScript error: No such module "Check for unknown parameters". cannot itself be broken down further into repeating strings, then the number of friends of SScript error: No such module "Check for unknown parameters". (including SScript error: No such module "Check for unknown parameters". itself) is equal to the length of TScript error: No such module "Check for unknown parameters"..

For example, suppose we start with the string S = ABBABBABBABBScript error: No such module "Check for unknown parameters"., which is built up of several copies of the shorter string T = ABBScript error: No such module "Check for unknown parameters".. If we rotate it one symbol at a time, we obtain the following 3 strings:

ABBABBABBABBScript error: No such module "Check for unknown parameters".,
BBABBABBABBAScript error: No such module "Check for unknown parameters".,
BABBABBABBABScript error: No such module "Check for unknown parameters"..

There aren't any others because Template:Mvar is exactly 3 symbols long and cannot be broken down into further repeating strings.

Completing the proof

Using the above rule, we can complete the proof of Fermat's little theorem quite easily, as follows. Our starting pool of a pScript error: No such module "Check for unknown parameters". strings may be split into two categories:

The second category contains a paScript error: No such module "Check for unknown parameters". strings, and they may be arranged into groups of Template:Mvar strings, one group for each necklace. Therefore, a paScript error: No such module "Check for unknown parameters". must be divisible by Template:Mvar, as promised.

Proof using dynamical systems

This proof uses some basic concepts from dynamical systems.[2]

We start by considering a family of functions Tn(x), where n ≥ 2 is an integer, mapping the interval [0, 1] to itself by the formula

Tn(x)={{nx}0x<1,1x=1,

where {y} denotes the fractional part of y. For example, the function T3(x) is illustrated below:

An example of a Tn function
An example of a Tn function

A number x0 is said to be a fixed point of a function f(x) if f(x0) = x0; in other words, if f leaves x0 fixed. The fixed points of a function can be easily found graphically: they are simply the x coordinates of the points where the graph of f(x) intersects the graph of the line y = x. For example, the fixed points of the function T3(x) are 0, 1/2, and 1; they are marked by black circles on the following diagram:

Fixed points of a Tn function
Fixed points of a Tn function

We will require the following two lemmas.

Lemma 1. For any n ≥ 2, the function Tn(x) has exactly n fixed points.

Proof. There are 3 fixed points in the illustration above, and the same sort of geometrical argument applies for any n ≥ 2.

Lemma 2. For any positive integers n and m, and any 0 ≤ x ≤ 1,

Tm(Tn(x))=Tmn(x).

In other words, Tmn(x) is the composition of Tn(x) and Tm(x).

Proof. The proof of this lemma is not difficult, but we need to be slightly careful with the endpoint x = 1. For this point the lemma is clearly true, since

Tm(Tn(1))=Tm(1)=1=Tmn(1).

So let us assume that 0 ≤ x < 1. In this case,

Tn(x)={nx}<1,

so Tm(Tn(x)) is given by

Tm(Tn(x))={m{nx}}.

Therefore, what we really need to show is that

{m{nx}}={mnx}.

To do this we observe that {nx} = nxk, where k is the integer part of nx; then

{m{nx}}={mnxmk}={mnx},

since mk is an integer.

Now let us properly begin the proof of Fermat's little theorem, by studying the function Tap(x). We will assume that a ≥ 2. From Lemma 1, we know that it has ap fixed points. By Lemma 2 we know that

Tap(x)=Ta(Ta(Ta(x)))p times,

so any fixed point of Ta(x) is automatically a fixed point of Tap(x).

We are interested in the fixed points of Tap(x) that are not fixed points of Ta(x). Let us call the set of such points S. There are apa points in S, because by Lemma 1 again, Ta(x) has exactly a fixed points. The following diagram illustrates the situation for a = 3 and p = 2. The black circles are the points of S, of which there are 32 − 3 = 6.

Fixed points in the set S
Fixed points in the set S

The main idea of the proof is now to split the set S up into its orbits under Ta. What this means is that we pick a point x0 in S, and repeatedly apply Ta(x) to it, to obtain the sequence of points

x0,Ta(x0),Ta(Ta(x0)),Ta(Ta(Ta(x0))),.

This sequence is called the orbit of x0 under Ta. By Lemma 2, this sequence can be rewritten as

x0,Ta(x0),Ta2(x0),Ta3(x0),.

Since we are assuming that x0 is a fixed point of Ta p(x), after p steps we hit Tap(x0) = x0, and from that point onwards the sequence repeats itself.

However, the sequence cannot begin repeating itself any earlier than that. If it did, the length of the repeating section would have to be a divisor of p, so it would have to be 1 (since p is prime). But this contradicts our assumption that x0 is not a fixed point of Ta.

In other words, the orbit contains exactly p distinct points. This holds for every orbit of S. Therefore, the set S, which contains ap − a points, can be broken up into orbits, each containing p points, so ap − a is divisible by p.

(This proof is essentially the same as the necklace-counting proof given above, simply viewed through a different lens: one may think of the interval [0, 1] as given by sequences of digits in base a (our distinction between 0 and 1 corresponding to the familiar distinction between representing integers as ending in ".0000..." and ".9999..."). Tan amounts to shifting such a sequence by n many digits. The fixed points of this will be sequences that are cyclic with period dividing n. In particular, the fixed points of Tap can be thought of as the necklaces of length p, with Tan corresponding to rotation of such necklaces by n spots.

This proof could also be presented without distinguishing between 0 and 1, simply using the half-open interval [0, 1); then Tn would only have n − 1 fixed points, but TapTa would still work out to apa, as needed.)

Multinomial proofs

Proofs using the binomial theorem

Proof 1

This proof, due to Euler,[3] uses induction to prove the theorem for all integers a ≥ 0Script error: No such module "Check for unknown parameters"..

The base step, that 0p ≡ 0 (mod p)Script error: No such module "Check for unknown parameters"., is trivial. Next, we must show that if the theorem is true for a = kScript error: No such module "Check for unknown parameters"., then it is also true for a = k + 1Script error: No such module "Check for unknown parameters".. For this inductive step, we need the following lemma.

Lemma. For any integers xScript error: No such module "Check for unknown parameters". and yScript error: No such module "Check for unknown parameters". and for any prime pScript error: No such module "Check for unknown parameters"., (x + y)p ≡ xp + yp (mod p)Script error: No such module "Check for unknown parameters"..

The lemma is a case of the freshman's dream. Leaving the proof for later on, we proceed with the induction.

Proof. Assume kpk (mod p), and consider (k+1)p. By the lemma we have

(k+1)pkp+1p(modp).

Using the induction hypothesis, we have that kpk (mod p); and, trivially, 1p = 1. Thus

(k+1)pk+1(modp),

which is the statement of the theorem for a = k+1. ∎

In order to prove the lemma, we must introduce the binomial theorem, which states that for any positive integer n,

(x+y)n=i=0n(ni)xniyi,

where the coefficients are the binomial coefficients,

(ni)=n!i!(ni)!,

described in terms of the factorial function, n! = 1×2×3×⋯×n.

Proof of Lemma. We consider the binomial coefficient when the exponent is a prime p:

(pi)=p!i!(pi)!

The binomial coefficients are all integers. The numerator contains a factor p by the definition of factorial. When 0 < i < p, neither of the terms in the denominator includes a factor of p (relying on the primality of p), leaving the coefficient itself to possess a prime factor of p from the numerator, implying that

(pi)0(modp),0<i<p.

Modulo p, this eliminates all but the first and last terms of the sum on the right-hand side of the binomial theorem for prime p. ∎

The primality of p is essential to the lemma; otherwise, we have examples like

(42)=6,

which is not divisible by 4.

Proof 2

Using the Lemma, we have:

kp((k1)+1)p(k1)p+1((k2)+1)p+1(k2)p+2k(modp).

Proof using the multinomial expansion

The proof, which was first discovered by Leibniz (who did not publish it)[4] and later rediscovered by Euler,[3] is a very simple application of the multinomial theorem, which states

(x1+x2++xm)n=k1,k2,,kmk1+k2++km=n(nk1,k2,,km)x1k1x2k2xmkm

where

(nk1,k2,,km)=n!k1!k2!km!

and the summation is taken over all sequences of nonnegative integer indices k1, k2, ..., kmScript error: No such module "Check for unknown parameters". such the sum of all kiScript error: No such module "Check for unknown parameters". is nScript error: No such module "Check for unknown parameters"..

Thus if we express aScript error: No such module "Check for unknown parameters". as a sum of 1s (ones), we obtain

ap=(1+1+...+1)p=k1,k2,,kak1+k2++ka=p(pk1,k2,,ka)

Clearly, if pScript error: No such module "Check for unknown parameters". is prime, and if kjScript error: No such module "Check for unknown parameters". is not equal to pScript error: No such module "Check for unknown parameters". for any jScript error: No such module "Check for unknown parameters"., we have

(pk1,k2,,ka)0(modp),

and if kjScript error: No such module "Check for unknown parameters". is equal to pScript error: No such module "Check for unknown parameters". for some jScript error: No such module "Check for unknown parameters". then

(pk1,k2,,ka)=1.

Since there are exactly aScript error: No such module "Check for unknown parameters". elements such that kj = pScript error: No such module "Check for unknown parameters". for some jScript error: No such module "Check for unknown parameters"., the theorem follows.

(This proof is essentially a coarser-grained variant of the necklace-counting proof given earlier; the multinomial coefficients count the number of ways a string can be permuted into arbitrary anagrams, while the necklace argument counts the number of ways a string can be rotated into cyclic anagrams. That is to say, that the nontrivial multinomial coefficients here are divisible by pScript error: No such module "Check for unknown parameters". can be seen as a consequence of the fact that each nontrivial necklace of length pScript error: No such module "Check for unknown parameters". can be unwrapped into a string in pScript error: No such module "Check for unknown parameters". many ways.

This multinomial expansion is also, of course, what essentially underlies the binomial theorem-based proof above)

Proof using power product expansions

An additive-combinatorial proof based on formal power product expansions was given by Giedrius Alkauskas.[5] This proof uses neither the Euclidean algorithm nor the binomial theorem, but rather it employs formal power series with rational coefficients.

Proof as a particular case of Euler's theorem

This proof,[3][6] discovered by James Ivory[7] and rediscovered by Dirichlet,[8] requires some background in modular arithmetic.

Let us assume that aScript error: No such module "Check for unknown parameters". is positive and not divisible by pScript error: No such module "Check for unknown parameters"..

The idea is that if we write down the sequence of numbers Template:NumBlk and reduce each one modulo pScript error: No such module "Check for unknown parameters"., the resulting sequence turns out to be a rearrangement of Template:NumBlk Therefore, if we multiply together the numbers in each sequence, the results must be identical modulo pScript error: No such module "Check for unknown parameters".:

a×2a×3a××(p1)a1×2×3××(p1)(modp).

Collecting together the aScript error: No such module "Check for unknown parameters". terms yields

ap1(p1)!(p1)!(modp).

Finally, we may “cancel out” the numbers 1, 2, ..., p − 1Script error: No such module "Check for unknown parameters". from both sides of this equation, obtaining

ap11(modp).

There are two steps in the above proof that we need to justify:

  • Why the elements of the sequence (A), reduced modulo Template:Mvar, are a rearrangement of (B), and
  • Why it is valid to “cancel” in the setting of modular arithmetic.

We will prove these things below; let us first see an example of this proof in action.

An example

If a = 3Script error: No such module "Check for unknown parameters". and p = 7Script error: No such module "Check for unknown parameters"., then the sequence in question is

3,6,9,12,15,18;

reducing modulo 7 gives

3,6,2,5,1,4,

which is just a rearrangement of

1,2,3,4,5,6.

Multiplying them together gives

3×6×9×12×15×183×6×2×5×1×41×2×3×4×5×6(mod7);

that is,

36(1×2×3×4×5×6)(1×2×3×4×5×6)(mod7).

Canceling out 1 × 2 × 3 × 4 × 5 × 6 yields

361(mod7),

which is Fermat's little theorem for the case a = 3Script error: No such module "Check for unknown parameters". and p = 7Script error: No such module "Check for unknown parameters"..

The cancellation law

Let us first explain why it is valid, in certain situations, to “cancel”. The exact statement is as follows. If uScript error: No such module "Check for unknown parameters"., xScript error: No such module "Check for unknown parameters"., and yScript error: No such module "Check for unknown parameters". are integers, and uScript error: No such module "Check for unknown parameters". is not divisible by a prime number pScript error: No such module "Check for unknown parameters"., and if Template:NumBlk then we may “cancel” uScript error: No such module "Check for unknown parameters". to obtain Template:NumBlk Our use of this cancellation law in the above proof of Fermat's little theorem was valid because the numbers 1, 2, ..., p − 1Script error: No such module "Check for unknown parameters". are certainly not divisible by pScript error: No such module "Check for unknown parameters". (indeed they are smaller than pScript error: No such module "Check for unknown parameters".).

We can prove the cancellation law easily using Euclid's lemma, which generally states that if a prime pScript error: No such module "Check for unknown parameters". divides a product abScript error: No such module "Check for unknown parameters". (where aScript error: No such module "Check for unknown parameters". and bScript error: No such module "Check for unknown parameters". are integers), then pScript error: No such module "Check for unknown parameters". must divide aScript error: No such module "Check for unknown parameters". or bScript error: No such module "Check for unknown parameters".. Indeed, the assertion (C) simply means that pScript error: No such module "Check for unknown parameters". divides uxuy = u(xy)Script error: No such module "Check for unknown parameters".. Since pScript error: No such module "Check for unknown parameters". is a prime which does not divide uScript error: No such module "Check for unknown parameters"., Euclid's lemma tells us that it must divide x − yScript error: No such module "Check for unknown parameters". instead; that is, (D) holds.

Note that the conditions under which the cancellation law holds are quite strict, and this explains why Fermat's little theorem demands that Template:Mvar is a prime. For example, 2×2 ≡ 2×5 (mod 6)Script error: No such module "Check for unknown parameters"., but it is not true that 2 ≡ 5 (mod 6)Script error: No such module "Check for unknown parameters".. However, the following generalization of the cancellation law holds: if Template:Mvar, Template:Mvar, Template:Mvar, and Template:Mvar are integers, if Template:Mvar and Template:Mvar are relatively prime, and if

uxuy(modz),

then we may “cancel” Template:Mvar to obtain

xy(modz).

This follows from a generalization of Euclid's lemma.

The rearrangement property

Finally, we must explain why the sequence

a,2a,3a,,(p1)a,

when reduced modulo p, becomes a rearrangement of the sequence

1,2,3,,p1.

To start with, none of the terms aScript error: No such module "Check for unknown parameters"., 2aScript error: No such module "Check for unknown parameters"., ..., (p − 1)aScript error: No such module "Check for unknown parameters". can be congruent to zero modulo pScript error: No such module "Check for unknown parameters"., since if kScript error: No such module "Check for unknown parameters". is one of the numbers 1, 2, ..., p − 1Script error: No such module "Check for unknown parameters"., then kScript error: No such module "Check for unknown parameters". is relatively prime with pScript error: No such module "Check for unknown parameters"., and so is aScript error: No such module "Check for unknown parameters"., so Euclid's lemma tells us that kaScript error: No such module "Check for unknown parameters". shares no factor with pScript error: No such module "Check for unknown parameters".. Therefore, at least we know that the numbers aScript error: No such module "Check for unknown parameters"., 2aScript error: No such module "Check for unknown parameters"., ..., (p − 1)aScript error: No such module "Check for unknown parameters"., when reduced modulo pScript error: No such module "Check for unknown parameters"., must be found among the numbers 1, 2, 3, ..., p − 1Script error: No such module "Check for unknown parameters"..

Furthermore, the numbers aScript error: No such module "Check for unknown parameters"., 2aScript error: No such module "Check for unknown parameters"., ..., (p − 1)aScript error: No such module "Check for unknown parameters". must all be distinct after reducing them modulo pScript error: No such module "Check for unknown parameters"., because if

kama(modp),

where kScript error: No such module "Check for unknown parameters". and mScript error: No such module "Check for unknown parameters". are one of 1, 2, ..., p − 1Script error: No such module "Check for unknown parameters"., then the cancellation law tells us that

km(modp).

Since both kScript error: No such module "Check for unknown parameters". and mScript error: No such module "Check for unknown parameters". are between 1Script error: No such module "Check for unknown parameters". and p − 1Script error: No such module "Check for unknown parameters"., they must be equal. Therefore, the terms aScript error: No such module "Check for unknown parameters"., 2aScript error: No such module "Check for unknown parameters"., ..., (p − 1)aScript error: No such module "Check for unknown parameters". when reduced modulo pScript error: No such module "Check for unknown parameters". must be distinct. To summarise: when we reduce the p − 1Script error: No such module "Check for unknown parameters". numbers aScript error: No such module "Check for unknown parameters"., 2aScript error: No such module "Check for unknown parameters"., ..., (p − 1)aScript error: No such module "Check for unknown parameters". modulo pScript error: No such module "Check for unknown parameters"., we obtain distinct members of the sequence 1Script error: No such module "Check for unknown parameters".2Script error: No such module "Check for unknown parameters"., ..., p − 1Script error: No such module "Check for unknown parameters".. Since there are exactly p − 1Script error: No such module "Check for unknown parameters". of these, the only possibility is that the former are a rearrangement of the latter.

Applications to Euler's theorem

This method can also be used to prove Euler's theorem, with a slight alteration in that the numbers from 1Script error: No such module "Check for unknown parameters". to p − 1Script error: No such module "Check for unknown parameters". are substituted by the numbers less than and coprime with some number Template:Mvar (not necessarily prime). Both the rearrangement property and the cancellation law (under the generalized form mentioned above) are still satisfied and can be utilized.

For example, if m = 10Script error: No such module "Check for unknown parameters"., then the numbers less than mScript error: No such module "Check for unknown parameters". and coprime with mScript error: No such module "Check for unknown parameters". are 1Script error: No such module "Check for unknown parameters"., 3Script error: No such module "Check for unknown parameters"., 7Script error: No such module "Check for unknown parameters"., and 9Script error: No such module "Check for unknown parameters".. Thus we have:

a×3a×7a×9a1×3×7×9(mod10).

Therefore,

aφ(10)1(mod10).

Proof as a corollary of Euler's criterion

Script error: No such module "Labelled list hatnote".

Proofs using group theory

Standard proof

This proof[9] requires the most basic elements of group theory.

The idea is to recognise that the set G = {1, 2, ..., p − 1Script error: No such module "Check for unknown parameters".}, with the operation of multiplication (taken modulo pScript error: No such module "Check for unknown parameters".), forms a group. The only group axiom that requires some effort to verify is that each element of GScript error: No such module "Check for unknown parameters". is invertible. Taking this on faith for the moment, let us assume that aScript error: No such module "Check for unknown parameters". is in the range 1 ≤ ap − 1Script error: No such module "Check for unknown parameters"., that is, aScript error: No such module "Check for unknown parameters". is an element of GScript error: No such module "Check for unknown parameters".. Let kScript error: No such module "Check for unknown parameters". be the order of aScript error: No such module "Check for unknown parameters"., that is, kScript error: No such module "Check for unknown parameters". is the smallest positive integer such that ak ≡ 1 (mod p)Script error: No such module "Check for unknown parameters".. Then the numbers 1, a, a2, ..., ak −1Script error: No such module "Check for unknown parameters". reduced modulo pScript error: No such module "Check for unknown parameters". form a subgroup of GScript error: No such module "Check for unknown parameters". whose order is kScript error: No such module "Check for unknown parameters". and therefore, by Lagrange's theorem, kScript error: No such module "Check for unknown parameters". divides the order of GScript error: No such module "Check for unknown parameters"., which is p − 1Script error: No such module "Check for unknown parameters".. So p − 1 = kmScript error: No such module "Check for unknown parameters". for some positive integer mScript error: No such module "Check for unknown parameters". and then

ap1akm(ak)m1m1(modp).

To prove that every element bScript error: No such module "Check for unknown parameters". of GScript error: No such module "Check for unknown parameters". is invertible, we may proceed as follows. First, bScript error: No such module "Check for unknown parameters". is coprime to pScript error: No such module "Check for unknown parameters".. Thus Bézout's identity assures us that there are integers xScript error: No such module "Check for unknown parameters". and yScript error: No such module "Check for unknown parameters". such that bx + py = 1Script error: No such module "Check for unknown parameters".. Reading this equality modulo pScript error: No such module "Check for unknown parameters"., we see that xScript error: No such module "Check for unknown parameters". is an inverse for bScript error: No such module "Check for unknown parameters"., since bx ≡ 1 (mod p)Script error: No such module "Check for unknown parameters".. Therefore, every element of GScript error: No such module "Check for unknown parameters". is invertible. So, as remarked earlier, GScript error: No such module "Check for unknown parameters". is a group.

For example, when p = 11Script error: No such module "Check for unknown parameters"., the inverses of each element are given as follows:

aScript error: No such module "Check for unknown parameters". 1 2 3 4 5 6 7 8 9 10
a −1Script error: No such module "Check for unknown parameters". 1 6 4 3 9 2 8 7 5 10

Euler's proof

If we take the previous proof and, instead of using Lagrange's theorem, we try to prove it in this specific situation, then we get Euler's third proof, which is the one that he found more natural.[10][11] Let AScript error: No such module "Check for unknown parameters". be the set whose elements are the numbers 1, a, a2, ..., ak − 1Script error: No such module "Check for unknown parameters". reduced modulo pScript error: No such module "Check for unknown parameters".. If A = GScript error: No such module "Check for unknown parameters"., then k = p − 1Script error: No such module "Check for unknown parameters". and therefore kScript error: No such module "Check for unknown parameters". divides p −1Script error: No such module "Check for unknown parameters".. Otherwise, there is some b1 ∈ G\AScript error: No such module "Check for unknown parameters"..

Let A1Script error: No such module "Check for unknown parameters". be the set whose elements are the numbers b1, ab1, a2b1, ..., ak − 1b1Script error: No such module "Check for unknown parameters". reduced modulo pScript error: No such module "Check for unknown parameters".. Then A1Script error: No such module "Check for unknown parameters". has kScript error: No such module "Check for unknown parameters". distinct elements because otherwise there would be two distinct numbers m, n ∈ {0, 1, ..., k − 1Script error: No such module "Check for unknown parameters".} such that amb1anb1 (mod p)Script error: No such module "Check for unknown parameters"., which is impossible, since it would follow that aman (mod p)Script error: No such module "Check for unknown parameters".. On the other hand, no element of A1Script error: No such module "Check for unknown parameters". can be an element of AScript error: No such module "Check for unknown parameters"., because otherwise there would be numbers m, n ∈ {0, 1, ..., k − 1Script error: No such module "Check for unknown parameters".} such that amb1an (mod p)Script error: No such module "Check for unknown parameters"., and then b1anakman + km (mod p)Script error: No such module "Check for unknown parameters"., which is impossible, since b1AScript error: No such module "Check for unknown parameters"..

So, the set AA1Script error: No such module "Check for unknown parameters". has 2kScript error: No such module "Check for unknown parameters". elements. If it turns out to be equal to G, then 2k = p −1Script error: No such module "Check for unknown parameters". and therefore kScript error: No such module "Check for unknown parameters". divides p −1Script error: No such module "Check for unknown parameters".. Otherwise, there is some b2 ∈ G\(AA1)Script error: No such module "Check for unknown parameters". and we can start all over again, defining A2Script error: No such module "Check for unknown parameters". as the set whose elements are the numbers b2, ab2, a2b2, ..., ak − 1b2Script error: No such module "Check for unknown parameters". reduced modulo pScript error: No such module "Check for unknown parameters".. Since GScript error: No such module "Check for unknown parameters". is finite, this process must stop at some point and this proves that kScript error: No such module "Check for unknown parameters". divides p − 1Script error: No such module "Check for unknown parameters"..

For instance, if a = 5Script error: No such module "Check for unknown parameters". and p = 13Script error: No such module "Check for unknown parameters"., then, since

  • 52 = 25 ≡ 12 (mod 13)Script error: No such module "Check for unknown parameters".,
  • 53 = 125 ≡ 8 (mod 13)Script error: No such module "Check for unknown parameters".,
  • 54 = 625 ≡ 1 (mod 13)Script error: No such module "Check for unknown parameters".,

we have k = 4Script error: No such module "Check for unknown parameters". and A = {1, 5, 8, 12Script error: No such module "Check for unknown parameters".}. Clearly, A ≠ G = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12Script error: No such module "Check for unknown parameters".}. Let b1Script error: No such module "Check for unknown parameters". be an element of G\AScript error: No such module "Check for unknown parameters".; for instance, take b1 = 2Script error: No such module "Check for unknown parameters".. Then, since

  • 2×1 = 2Script error: No such module "Check for unknown parameters".,
  • 2×5 = 10Script error: No such module "Check for unknown parameters".,
  • 2×8 = 16 ≡ 3 (mod 13)Script error: No such module "Check for unknown parameters".,
  • 2×12 = 24 ≡ 11 (mod 13)Script error: No such module "Check for unknown parameters".,

we have A1 = {2, 3, 10, 11Script error: No such module "Check for unknown parameters".}. Clearly, AA1GScript error: No such module "Check for unknown parameters".. Let b2Script error: No such module "Check for unknown parameters". be an element of G\(AA1)Script error: No such module "Check for unknown parameters".; for instance, take b2 = 4Script error: No such module "Check for unknown parameters".. Then, since

  • 4×1 = 4Script error: No such module "Check for unknown parameters".,
  • 4×5 = 20 ≡ 7 (mod 13)Script error: No such module "Check for unknown parameters".,
  • 4×8 = 32 ≡ 6 (mod 13)Script error: No such module "Check for unknown parameters".,
  • 4×12 = 48 ≡ 9 (mod 13)Script error: No such module "Check for unknown parameters".,

we have A2 = {4, 6, 7, 9Script error: No such module "Check for unknown parameters".}. And now G = AA1A2Script error: No such module "Check for unknown parameters"..

Note that the sets AScript error: No such module "Check for unknown parameters"., A1Script error: No such module "Check for unknown parameters"., and so on are in fact the cosets of AScript error: No such module "Check for unknown parameters". in GScript error: No such module "Check for unknown parameters"..

Notes

  1. Script error: No such module "citation/CS1".
  2. Script error: No such module "citation/CS1".
  3. a b c Script error: No such module "citation/CS1".
  4. Script error: No such module "citation/CS1".
  5. Script error: No such module "citation/CS1".
  6. Script error: No such module "citation/CS1".
  7. Script error: No such module "citation/CS1".
  8. Script error: No such module "citation/CS1".
  9. Script error: No such module "citation/CS1".
  10. Script error: No such module "citation/CS1".
  11. Script error: No such module "citation/CS1".