Small Modular Solutions to Fermat’s Last Theorem

Abstract

The proof by Andrew Wiles of Fermat’s Last Theorem in 1995 resolved the existence question for non-trivial solutions in integers x,y,z to the equation x n + y n = z n for n>2 . There are none. Surprisingly, there are infinitely many solutions if the problem is recast in terms of modular arithmetic. Over a hundred years ago Issai Schur was able to show that for any n there is always a sufficiently large prime p 0 such that for all primes p p 0 the congruence x n + y n z n ( modp ) has a non-trivial solution. Schur’s argument wasnon-constructive, and there is no systematic method available at present to construct specific examples for small primes. We offer a simple method for constructing all possible solutions to a large class of congruences of this type.

Share and Cite:

Beatty, T. (2024) Small Modular Solutions to Fermat’s Last Theorem. Advances in Pure Mathematics, 14, 797-805. doi: 10.4236/apm.2024.1410044.

1. Introduction

We will call a congruence of the form x n + y n z n ( modp ) for prime p a modular Fermat equation (MFE). An MFE is non-trivial if no term is zero and we regard x n + y n z n ( modp ) and y n + x n z n ( modp ) .as the same solution. Some examples are 2 3 + 3 3 7 3 ( mod11 ) , 7 5 + 12 5 34 5 ( mod37 ) , 12 9 + 13 9 17 9 ( mod23 ) and even 3 101 + 4 101 27 101 ( mod29 ) . The reason this can occur so frequently with modular arithmetic can be understood by studying the bijectivity of the familiar function ϕ: p p given by ϕ( x,n,p )= x n modp . This is not the Frobenius endomorphism, which would send an element of p to its pth power. Since the characteristic of p is p the Frobenius mapping would certainly be bijective, but we are interested in applying arbitrary nth powers to the elements of p and still retaining bijectivity. We assume p3 . Even values of n interfere with the bijectivity of ϕ , so our discussion will be confined to odd n3 . We also note in passing that every Pythagorean triple generates a solution to an MFE with n=2 .

Since ϕ( 0,n,p )=0 , we can limit our attention to the set p * of non-zero residues modulo p. If ϕ is bijective, then ϕ( p * ) returns a permuted copy of p * as the set of nth power residues modulo p. It follows that for arbitrary x,y p * , the sum x n + y n ( modp )=ζ , where ζ is guaranteed to be another nth power residue, say ζ= z n p + . Then we have the MFE x n + y n z n ( modp ) . This matching process is essentially an application of the pigeonhole principle to the range of ϕ( x,n,p ) . For any sum of two nth powers modulo p, there is a pigeon at home with that same address among the permuted nth residues. We arbitrarily rule out x=y as not being an (esthetically) proper solution. Also it is clear that if x=z or y=z , then y or x, respectively, would be forced to be zero, violating non-triviality. Now if ϕ fails to be bijective, this guarantee is no longer assured, as ζ may not be among the nth power residues. In the sequel we offer an example where the bijectivity of ϕ fails so drastically that no MFE can be constructed, and another where it fails only moderately but still allows the construction of an MFE. Our goal is to develop a criterion for ( n,p ) pairs that guarantees ϕ( x,n,p ) is a bijection and will therefore support the formation of MFEs using the pigeonhole strategy.

2. Historical Note

In 1916 Issai Schur proved the combinatorial result known as Schur’s Lemma in Ramsey Theory [1] [2]. This asserts that given a palette of k colors with k2 , there is always an n4 such that a k-coloring of the set { 1,2,,n } would yield a monochromatic triple { i,j,k } satisfying the algebraic property i+j=k . As a corollary of this result he was able to show that Fermat’s Last Theorem is false in the context of modular arithmetic. Specifically, he established that for any n1 there is a prime p 0 such that for all p p 0 the equation x n + y n z n ( modp ) has a solution. His proof is based on a Ramsey theory type argument which is summarized in [3]. As such, it is non-constructive, but it clarifies that for any n there are only finitely many moduli p for which an MFE cannot be constructed. It is not obvious that there is a general pattern among the ( n,p ) pairs for which this is true. Our focus is on the territory where p< p 0 . Here solutions may or may not exist for specific ( n,p ) pairs. We develop a simple criterion that allows us to select those ( n,p ) pairs which guarantee that explicit solutions exist.

3. The Compatibility Criterion

A joint selection of n and p that assures the bijectivity of ϕ( x,n,p ) will be called compatible. We now turn to developing a practical criterion for identifying compatible ( n,p ) pairs. Before proving the general result we explore a motivating case with small n and p. Let n=5 and p=13 . We have purposely chosen n and p such that gcd( n,p1 )=gcd( 5,12 )=1 . Note that 2 is a primitive root of 13 and recall that the various powers of a primitive root for prime p generate the numbers 1 through p1 in some order [4]. The index I of such a number is its logarithm with respect to the primitive root as a base. For example, since 2 4 3( mod13 ) , the index I 2 ( 3 )=4 .

Example 1 We construct Table 1 as follows for the purpose of finding all solutions to x 5 + y 5 z 5 ( mod13 ) . The elements x of 13 * ={ 1,2,,12 } are listed in order in Column 1. Their respective fifth powers reduced modulo 13 are listed in Column 2. Note that the entries in Column 2 repeat all of the entries in Column 1 but in a different order. This is a consequence of the fact that ϕ( x,5,13 )= x 5 mod13 is a permutation on 13 * . In general this need not be the case for arbitrary n and p. Then Column 3 lists their respective indices relative to the primitive root 2 of 13. For example, if x=5 , we have 2 9 5( mod13 ) , so I 2 ( 5 )=9 . Finally, in Column 4 we list the respective indices of the fifth powers of x, again relative to the primitive root 2 of 13. Recall that if I 2 ( x )=k , then I 2 ( x 5 )=5k( mod12 ) , since indices are always reduced modulo ( p1 ) .

Table 1. n=5 , p=13 .

Column 1

Column 2

Column 3

Column 4

x

x5 (mod 13)

I2 (x)

I2 (x5) (mod 12)

1

1

0

0

2

6

1

5

3

9

4

8

4

10

2

10

5

5

9

9

6

2

5

1

7

11

11

7

8

8

3

3

9

3

8

4

10

4

10

2

11

7

7

11

12

12

6

6

Table 1 explains why there are many guaranteed solutions to x 5 + y 5 z 5 ( mod13 ) . To successfully use the matching strategy based on the pigeonhole principle described previously, we require that the fifth powers listed in Table 1, Column 2 be the numbers 1, 2, …, 12 in some order. Here is the chain of logic which shows this to be true in this case: The numbers 1, 2, …, 12 (Column 1) are given as distinct. Their respective indices relative to the primitive root 2 of 13 are distinct (Column 3) by the bijectivity of the index function (which is what makes the primitive root primitive). The respective indices of the fifth powers (Column 4) are calculated in turn from the entries in Column 3 by the Discrete Logarithm Rule which states that I 2 ( x 5 )=5 I 2 ( x )( mod12 ) . This rule is injective provided the gcd( 5,12 )=1 , which we confirm. Thus the entries in Column 4 are distinct. Finally, we again appeal to the bijectivity of the index function to conclude that the inverse mapping I 2 ( x 5 )( mod12 ) x 5 ( mod13 ) establishes that the entries in Column 2 are the distinct numbers 1, 2, …, 12 in some order.

Now that we have shown that the fifth powers modulo 13 are the complete set of positive least residues, we can easily build all non-trivial solutions to x 5 + y 5 z 5 ( mod13 ) . Pick two different numbers from Column 1, say 5 and 11. Find their fifth powers modulo 13 in Column 2 and add. This gives 5 + 7 = 12. By the matching strategy we are guaranteed to find the number in Column 1 corresponding to 12 in Column 2. We conclude 5 5 + 11 5 = 12 5 ( mod13 ) . There are ( 12 2 )=66 choices of two different numbers from Column 1, and each pair gives a distinct proper solution to x 5 + y 5 z 5 ( mod13 ) .

We use a generalization of this argument to find a criterion for the compatibility of the pair ( n,p ) .

Theorem 1 (Criterion for Compatible Powers and Primes) Given n3 and p an odd prime, the function ϕ( x,n,p )= x n ( modp ) permutes the set of residues { 1,2,,p1 } provided gcd( n,p1 )=1 . In particular, if x 1 and x 2 are not congruent modulo p, then neither are x 1 n and x 2 n .

Proof: Every prime has a primitive root, so let α be a primitive root of p. All indices will be calculated with respect to α. The elements x of p * ={ 1,2,,p1 } are listed in order in Table 2, Column 1. Their respective nth powers reduced modulo p are listed in Column 2. Their respective indices relative to the primitive root α are listed in Column 3. Finally, the indices relative to α of their respective nth powers are listed in Column 4, reduced modulo ( p1 ) .

Table 2. For Theorem 1.

Column 1

Column 2

Column 3

Column 4

x

xn (modp)

Iα (x)

Iα (xn) (mod(p − 1))

1

1

0

0

2

2n (modp)

Iα (2)

nIα (2)

3

3n (modp)

Iα (3)

nIα (3)

x1

x 1 n (modp)

Iα (x1) = r

Iα ( x 1 n ) = rn

x2

x 2 n (modp)

Iα (x2) = s

Iα ( x 2 n ) = sn

(p − 1)

(p − 1)n (modp)

Iα (p − 1)

nIα (p − 1)

Suppose x 1 and x 2 are distinct least residues modulo p from Column 1 but for the sake of contradiction their nth powers are congruent modulo p in Column 2. So x 1 n x 2 n ( modp ) . We know x 1 and x 2 are powers of the primitive root α , so suppose further that in Column 3 I α ( x 1 )=r and I α ( x 2 )=s . It follows in Column 4 that I α ( x 1 n )=rn and I α ( x 2 n )=sn . These two indices in Column 4 must be congruent modulo ( p1 ) . So we now have rnsn( mod( p1 ) ) which implies ( rs )n0( mod( p1 ) ) . By assumption, gcd( n,p1 )=1 , and since 1r,sp1 , it must be the case that ( rs )=0 and evidently r=s . This forces x 1 α r = α s x 2 , which contradicts the assumption that x 1 and x 2 are distinct least residues modulo p. We conclude that x 1 n and x 2 n cannot be congruent modulo p, and the function ϕ( x,n,p )= x n ( modp ) is injective on the finite set p * , and therefore bijective, as claimed. ◼

This theorem establishes a sufficient condition for the bijectivity of ϕ( x,n,p ) , which, coupled with the matching strategy described above, allows the generation of explicit MFE’s in the manner illustrated.

Corollary 1-1 There are infinitely many primes for which MFEs are constructible

Proof: There are infinitely many odd primes and for each odd prime p, we may factor p1 into a product of primes to various powers according to the Fundamental Theorem of Arithmetic. Then we may choose any odd n3 that does not share any of the primes in this product. This construction will ensure gcd( n,p1 )=1 validating application of the theorem. We conclude there are infinitely many primes for which MFEs can be formed. ◼

Of course, Schur’s Theorem says the same thing, in fact it does so more inclusively since n need not be odd. But it offers no clue for constructing an example.

Corollary 1-2: Provided n and p are compatible, MFEs of the form a n + b n c n ( modp ) with 0<a,b<c<p exist.

Proof: Given 1 n + 2 n c n we can always find c3 . Otherwise we are forced to conclude either 1 n or 2 n =0 .◼

This is purely an esthetic nod to the classical form of Pythagorean triples.

Corollary 1-3: If a n + b n c n ( modp ) , then ( a+pi ) n + ( b+pj ) n ( c+pk ) n ( modp ) for any triple ( i,j,k ) 0 3 .

Proof: Note that ( a+pi ) n = r=0 n a r ( pi ) nr a n ( modp ) and likewise for the other terms. ◼

We have thus far dealt with compatible ( n,p ) pairs that have allowed construction of MFE solutions. We now briefly explore how incompatible ( n,p ) pairs can affect the existence of solutions.

4. Failed Bijectivity of ϕ

As indicated earlier, if gcd( n,p1 )>1 the set of nth power residues modulo p can shrink markedly from the full set p * . Here is a catastrophic case where it is impossible to form any MFE’s. Let n=9 and p=13 , so gcd( 9,12 )=3 . We use the primitive root x=2 again and generate the powers and indices in Table 3.

Table 3. An unsuccessful case.

Column 1

Column 2

Column 3

Column 4

x

x9 (mod 13)

I2 (x)

I2 (x9) (mod 12)

1

1

0

0

2

5

1

9

3

1

4

0

4

12

2

6

5

5

9

9

6

5

5

9

7

8

11

3

8

8

3

3

9

1

8

0

10

12

10

6

11

8

7

3

12

12

6

6

It is readily apparent from Table 3, Column 2 above that the ninth powers of the integers 1, 2, …, 12 are not distinct modulo 13. The respective indices relative to the primitive root 2 are listed in Column 3, and the injectivity of the index function ensures that there are no repeated values. However, in Column 4 we observe a collapse of injectivity. This is caused by the fact that gcd( 9,12 )=3 . Since indices are computed modulo ( p1 )=12 in this case, and I 2 ( x 9 )9 I 2 ( x )( mod12 ) , we see the values of I 2 ( x 9 ) repeating in cycles whenever 9 I 2 ( x ) equals a multiple of 12. Table 4 makes the pattern obvious. Row 1 lists the indices of the various elements of 13 * in the order of increasing index. Row 2 lists the indices of the corresponding ninth powers.

Table 4. Cyclic indices for x9.

I 2 ( x )

1

2

3

4

5

6

7

8

9

10

11

12

I 2 ( x 9 )

9

6

3

0

9

6

3

0

9

6

3

0

It is easy to see what goes wrong. If 9 (=n) and 12 (=p − 1) were coprime there would only be one cycle terminating when I 2 ( x )=12 . The repeating cycles have length p1 gcd( n,p1 ) = 12 3 =4 in this example. It follows again from the injectivity of the index function that the corresponding ninth power residues must repeat in the same pattern as their indices. We are left with only { 1,5,8,12 } as the set of distinct ninth power residues modulo 13. By inspection it is clear that the matching strategy completely fails with only the numbers in this set available. We conclude that there is no admissible solution to an MFE ohe form x 9 + y 9 z 9 ( mod13 ) . The general result follows.

Theorem 2 (Counting Distinct nth Power Residues Modulo p) With the usual notation, the population of distinct nth power residues modulo p is p1 gcd( n,p1 ) .

Proof: Referring again to Table 2 above (used to prove Theorem 1), suppose α is a primitive root of p. Suppose further that x 1 and x 2 are two distinct least residues modulo p with x 1 = α i and x 2 = α j . We claim that if i and j differ by the integer p1 gcd( n,p1 ) =m , then x 1 n = x 2 n . Assuming i>j we can write I( α i )I( α j )=ij=m . Then I( α ni )I( α nj )=ninj=n( ij )=nm . This is certainly a multiple of ( p1 ) , and it follows that I( α ni )I( α nj )0mod( p1 ) . We conclude I( α ni )I( α nj )( mod( p1 ) ) , and since 0I( α ni ),I( α nj )<( p1 ) , we have I( α ni )=I( α nj ) , which by injectivity of the index mapping implies x 1 n = x 2 n , establishing the claim. So the nth powers repeat in cycles of length p1 gcd( n,p1 ) and obviously there can only be p1 gcd( n,p1 ) distinct nth power residues modulo p. ◼

Intuitively, we might suspect that the larger gcd( n,p1 ) is relative to p, the less likely it would be that the population of nth power residues can support construction of MFEs by the matching strategy. Here is an example where gcd( n,p1 )>1 but corresponding MFEs exist. Let n=5 and p=31 . So gcd( 5,30 )=5 . By Theorem 2 we would expect to find a fairly thin subset of six fifth power residues, and we easily determine that set to be { 1,5,6,25,26,30 } . There are several matches we can make with this reduced set, unlike the earlier case for n=9 and p=13 . For example, 1 + 5 = 6, 1 + 25 = 26, and 5 + 25 = 30. Now 31 * can be partitioned into six equivalence classes where the elements within a class have equal 5th power residues modulo 31, namely the six distinct residues above. Each equivalence class has five members so there are apparently 375 distinct MFEs that can assembled from the three previous addition formulas. This clashes with our intuition. Only a fifth of 31 * is available for piecing together fifth power MFEs, while a third of 13 * is available for assembling ninth power MFEs. The smaller fraction leads to a profusion of MFEs, yet the larger fraction leads to none. Our sufficiency condition of Theorem 1 is far from being necessary.

The constraint we have presented on the number of nth power residues for a given prime p interacts with Schur’s Theorem in an interesting way. It may happen that an incompatible ( n,p ) pair may have n= p1 2 . Then gcd( n,p1 )=n which implies there are p1 n =2 nth power residues modulo p. The only non-trivial MFEs that could be formed under these circumstances would be of the “improper” form x n + x n y n ( modp ) . Recalling Schur’s Theorem which states that there are solutions to x n + y n z n ( modp ) for any n and all primes p exceeding some threshhold p 0 , we remark that cases could be constructed where gcd( n,p1 )=n . This implies that the MFEs guaranteed by Schur’s theorem would necessarily be of the improper type.

5. Beyond MFEs

Finally, we note that the matching construction described above allows considerable extension [5] of the basic modular Fermat equation x n + y n z n ( modp ) . As long as the function ϕ( x,n,p ) is bijective, the matching strategy will work and equations like ( i=1 N1 x i n = x N n )( modp ) will have solutions. For example, 2 3 + 3 3 + 4 3 10 3 mod17 . We can also extend this by changing terms to their additive inverses relative to p and then moving them to the other side of the equation. Since 413mod17 , the previous example can be written 2 3 + 3 3 13 3 10 3 mod17 and rearranged to 2 3 + 3 3 10 3 + 13 3 mod17 . The odd parity of admissible n always permits this.

6. Summary

It has long been established by a non-constructive argument that the modular version of Fermat’s Last Theorem is false. Evidently solutions do exist for any exponent n and all sufficiently large prime moduli p p 0 , where p 0 is a threshhold implied by Schur’s Theorem. However, there does not appear at present to be an efficient and transparent method for constructing solutions for small prime moduli. We have furnished this for a large class of compatible exponent/modulus pairs. Moreover, we have outlined directions for application of the method to additional modular Fermat-like equations.

Conflicts of Interest

The author declares no conflicts of interest regarding the publication of this paper.

References

[1] Schur, I. (1916) Über die Kongruenz , Jahresbericht der Deutschen Mathematiker-Vereinigung, 114-116. (European Mathematics Digital Library)
[2] Steed, M. (2015) Some Theorems and Applications of Ramsey Theory. University of Chicago Press, Chicago.
[3] Fox, J. and Sudakov, B. (2008) Induced Ramsey-type Theorems. Advances in Mathematics, 1771-1800.
[4] Hardy, G.H. and Wright, E.M. (1979) An Introduction to the Theory of Numbers. Clarendon Press, Oxford
[5] Silverman, J.H. (2001) A Friendly Introduction to Number Theory. Prentice Hall, Upper Saddle River.

Copyright © 2026 by authors and Scientific Research Publishing Inc.

Creative Commons License

This work and the related PDF file are licensed under a Creative Commons Attribution 4.0 International License.