You are on page 1of 5

Fermats little theorem

For other theorems named after Pierre de Fermat, see


Fermats theorem.

Fermats little theorem states that if p is a prime num-


ber, then for any integer a, the number a p a is an integer
multiple of p. In the notation of modular arithmetic, this
is expressed as

ap a (mod p).

For example, if a = 2 and p = 7, 27 = 128, and 128 2 =


7 18 is an integer multiple of 7.
If a is not divisible by p, Fermats little theorem is equiv-
alent to the statement that a p 1 1 is an integer multiple
of p, or in symbols

ap1 1 (mod p). [1][2]

For example, if a = 2 and p = 7 then 26 = 64 and 64 1


= 63 is thus a multiple of 7.
Fermats little theorem is the basis for the Fermat primal-
ity test and is one of the fundamental results of elementary
number theory. The theorem is named after Pierre de Pierre de Fermat
Fermat, who stated it in 1640. It is called the little the-
orem to distinguish it from Fermats last theorem.[3] This may be translated in modern terminology, with ex-
planations and formulas inserted between brackets, for
easier understanding:
1 History
Every prime number [p] divides necessar-
Pierre de Fermat rst stated the theorem in a letter dated ily one of the powers 1 of any [geometric]
October 18, 1640, to his friend and condant Frnicle de progression [a, a2 , a3 , ...] [that is there exists t
Bessy. His formulation is equivalent to the following:[3] such that p divides at 1], and the exponent of
this power [t] divides the given prime 1 [di-
If p is a prime and a is any integer not di- vides p 1]; and, after one has found the rst
visible by p, then a p 1 1 is divisible by p. power [t] that satises the question, all those
whose exponents are multiple of the exponent
In fact, the original statement was of the rst one satisfy similarly the question
[that is, all multiples of the rst t have the same
property].
Tout nombre premier mesure infaillible-
ment une des puissances 1 de quelque pro-
gression que ce soit, et l'exposant de la dite Fermat did not consider the case where a is a multiple of
puissance est sous-multiple du nombre pre- p nor prove his assertion, only stating:[4]
mier donn 1 ; et, aprs qu'on a trouv la
premire puissance qui satisfait la question, Et cette proposition est gnralement vraie
toutes celles dont les exposants sont multiples en toutes progressions et en tous nombres pre-
de l'exposant de la premire satisfont tout de miers ; de quoi je vous envoierois la dmons-
mme la question. tration, si je n'apprhendois d'tre trop long.

1
2 5 PSEUDOPRIMES

(And this proposition is generally true for


all series [sic] and for all prime numbers; I
would send you a demonstration of it, if I did a(n) 1 (mod n),
not fear going on for too long.)[5] where (n) denotes Eulers totient function (which counts
the integers between 1 and n that are coprime to n). Eu-
Euler provided the rst published proof in 1736 in a pa- lers theorem is indeed a generalization, because if n = p
per entitled Theorematum Quorundam ad Numeros Pri- is a prime number, then (p) = p 1.
mos Spectantium Demonstratio in the Proceedings of the
A slight generalization of Eulers theorem, which imme-
St. Petersburg Academy,[6] but Leibniz had given virtu-
diately follows from it, is: if a, n, x, y are integers with n
ally the same proof in an unpublished manuscript from
[3] positive and a and n coprime, then
sometime before 1683.
The term Fermats Little Theorem was probably rst If x y (mod (n)) , then ax
used in print in 1913 in Zahlentheorie by Kurt Hensel: ay (mod n) .

Fr jede endliche Gruppe besteht nun ein This follows as x is of the form y + (n)k, so
Fundamentalsatz, welcher der kleine Fermat-
sche Satz genannt zu werden pegt, weil ein
ganz spezieller Teil desselben zuerst von Fer- ax = ay+(n)k = ay (a(n) )k ay 1k ay (mod n).
mat bewiesen worden ist.
In this form, the theorem nds many uses in cryptogra-
(There is a fundamental theorem holding in phy and, in particular, underlies the computations used
every nite group, usually called Fermats little in the RSA public key encryption method.[7] The special
Theorem because Fermat was the rst to have case with n a prime may be considered a consequence of
proved a very special part of it.) Fermats little theorem.
Fermats little theorem is also related to the Carmichael
An early use in English occurs in A.A. Albert, Modern function and Carmichaels theorem, as well as to
Higher Algebra (1937), which refers to the so-called lit- Lagranges theorem in group theory.
tle Fermat theorem on page 206. The algebraic setting of Fermats little theorem can be
generalized to nite elds.
1.1 Further history
Main article: Chinese hypothesis 4 Converse

Some mathematicians independently made the related The converse of Fermats little theorem is not generally
hypothesis (sometimes incorrectly called the Chinese Hy- true, as it fails for Carmichael numbers. However, a
pothesis) that 2p 2 (mod p) if and only if p is a prime. slightly stronger form of the theorem is true, and is known
Indeed, the if part is true, and is a special case of Fer- as Lehmers theorem. The theorem is as follows:
mats little theorem. However, the only if part of this If there exists an a such that
hypothesis is false: for example, 2341 2 (mod 341), but
341 = 11 31 is a pseudoprime. See below.
ap1 1 (mod p)

2 Proofs and for all primes q dividing p 1

Main article: Proofs of Fermats little theorem a(p1)/q 1 (mod p)

Several proofs of Fermats little theorem are known. It is then p is prime.


frequently proved as a corollary of Eulers theorem. This theorem forms the basis for the LucasLehmer test,
an important primality test.

3 Generalizations
5 Pseudoprimes
Fermats little theorem is a special case of Eulers theo-
rem: for any modulus n and any integer a coprime to n, If a and p are coprime numbers such that a p 1 1 is di-
we have visible by p, then p need not be prime. If it is not, then
3

p is called a pseudoprime to base a (or a Fermat pseudo- RSA


prime). F. Sarrus in 1820 found 341 = 11 31 as one of
the rst pseudoprimes, to base 2.[8] p-derivation
A number p that is a pseudoprime to base a for every Frobenius endomorphism
number a coprime to p is called a Carmichael number
(e.g. 561). Alternately, any number p satisfying the Table of congruences
equality

(p1 ) 8 Notes

gcd ap1 , p =1
a=1 [1] Long 1972, pp. 8788

is either a prime or a Carmichael number. [2] Pettofrezzo & Byrkit 1970, pp. 110111

[3] Burton 2011, p. 514

6 MillerRabin primality test [4] Fermat, Pierre (1894), Tannery, P.; Henry, C., eds.,
Oeuvres de Fermat. Tome 2: Correspondance, Paris:
Gauthier-Villars, pp. 206212 (in French)
The MillerRabin primality test uses the following exten-
sion of Fermats little theorem: [5] Mahoney 1994, p. 295 for the English translation

[6] Ore 1988, p. 273


If p is an odd prime number, and p 1 =
2s d, with d odd, then for every a prime to p, [7] Trappe, Wade; Washington, Lawrence C. (2002), Intro-
either ad 1 mod p, or there exists t such that duction to Cryptography with Coding Theory, Prentice-
t
0 t < s and a2 d 1 mod p Hall, p. 78, ISBN 0-13-061814-4

[8] https://oeis.org/A128311
This result may be deduced from Fermats little theorem
by the fact that, if p is an odd prime, then the integers
modulo p form a nite eld, in which 1 has exactly two
square roots, 1 and 1. 9 References
The MillerRabin test uses this property in the following
way: given p = 2s d + 1, with d odd, an odd integer for Burton, David M. (2011), The History of Mathemat-
which primality has to be tested, choose randomly a such ics / An Introduction (7th ed.), McGraw-Hill, ISBN
that 1 < a < p; then compute b = ad mod p; if b is not 1 978-0-07-338315-6
nor 1, then square it repeatedly modulo p until you get
1, 1, or have squared d times. If b 1 and 1 has not Long, Calvin T. (1972), Elementary Introduction to
been obtained, then p is not prime. Otherwise, p may be Number Theory (2nd ed.), Lexington: D. C. Heath
prime or not. If p is not prime, the probability that this is and Company, LCCN 77171950
proved by the test is higher than 1/4. Therefore, after k
Mahoney, Michael Sean (1994), The Mathemati-
non-conclusive random tests, the probability that p is not
cal Career of Pierre de Fermat, 16011665 (2nd
prime is lower than (3/4)k , and may thus be made as low
ed.), Princeton University Press, ISBN 978-0-691-
as desired, by increasing k.
03666-3
In summary, the test either proves that a number is not
prime, or asserts that it is prime with a probability of er- Ore, Oystein (1988) [1948], Number Theory and Its
ror that may be chosen as low as desired. The test is very History, Dover, ISBN 978-0-486-65620-5
simple to implement and computationally more ecient
than all known deterministic tests. Therefore, it is gener- Pettofrezzo, Anthony J.; Byrkit, Donald R. (1970),
ally used before starting a proof of primality. Elements of Number Theory, Englewood Clis:
Prentice Hall, LCCN 71081766

7 See also
10 Further reading
Fermat quotient
Paulo Ribenboim (1995). The New Book of Prime
Fractions with prime denominators: numbers with Number Records (3rd ed.). New York: Springer-
behavior relating to Fermats little theorem Verlag. ISBN 0-387-94457-5. pp. 2225, 49.
4 11 EXTERNAL LINKS

11 External links
Jnos Bolyai and the pseudoprimes (in Hungarian)

Fermats Little Theorem at cut-the-knot


Euler Function and Theorem at cut-the-knot

Fermats Little Theorem and Sophies Proof

Hazewinkel, Michiel, ed. (2001) [1994], Fermats


little theorem, Encyclopedia of Mathematics,
Springer Science+Business Media B.V. / Kluwer
Academic Publishers, ISBN 978-1-55608-010-4

Weisstein, Eric Wolfgang. Fermats Little Theo-


rem. MathWorld.

Weisstein, Eric Wolfgang. Fermats Little Theo-


rem Converse. MathWorld.
5

12 Text and image sources, contributors, and licenses


12.1 Text
Fermats little theorem Source: https://en.wikipedia.org/wiki/Fermat{}s_little_theorem?oldid=784558474 Contributors: AxelBoldt,
Mav, Zundark, Taral, XJaM, Michael Hardy, Blueshade, Ixfd64, Chinju, Nikai, Rotem Dan, Ideyal, Dysprosia, Sabbut, Robbot, Fredrik,
Gandalf61, Bethenco, Wikibot, Tosha, Giftlite, Lupin, Peruvianllama, Dratman, Python eggs, Gubbubu, CryptoDerk, Profvk, Alex
Cohn, Almit39, Sam Hocevar, Discospinster, Kooo, Ericamick, DonDiego, PittBill, Steveha, Obradovic Goran, Jumbuck, Neonum-
bers, Burn, Wtmitchell, Ling Kah Jai, Oleg Alexandrov, OwenX, Guardian of Light, JFG, Mensanator, Graham87, BD2412, Pako,
Erkcan, Mathbot, Maxal, Chobot, Siddhant, Dmharvey, Vecter, RussBot, Arthur Rubin, SmackBot, RDBury, Mmernex, BeteNoir,
Wzhao553, Hmains, Kurykh, PrimeHunter, TrogdorPolitiks, Bigmantonyd, Andrei Stroe, Rohit math, Karakal, Mr. Lefty, Hvn0413,
Gauravk, Otac0n, Jingwang, Blackcloak, ChrisCork, Nutster, CRGreathouse, Misof, MC10, Fmalinkevich, Navigatr85, Heder~enwiki,
Widefox, Salgueiro~enwiki, JAnDbot, BlendsInWell, Connor Behan, Nthitz, David Callan, N4nojohn, Fruits Monster, Boris Allen, An-
dareed, Policron, Vcpandya, Pleasantville, Mrh30, BotKung, SieBot, OKBot, JMOprof, Sphilbrick, ClueBot, DragonBot, NuclearWar-
fare, Silas Maxeld, Johnuniq, Rangergordon, Virginia-American, Addbot, Non-dropframe, Pabloximenes, Download, Loupeter, Legobot,
Luckas-bot, Yobot, Charleswallingford, KamikazeBot, AnomieBOT, Rubinbot, Xqbot, Quintus314, Rebbing, Adrionwells, X7q, Sebas-
tiangarth, AstaBOTh15, BasvanPelt, EmausBot, Vanished user bc8e8hwkjahw8tijwu, Tdupu10000, Zarboublian, Tttfkkk, D.Lazard,
Toshio Yamaguchi, Donner60, Llightex, Anita5192, Wcherowi, Adityasinghhhhh, Adityasinghhhhhh, Gaurav178, Alpha1337Saint, Joel B.
Lewis, Cenkner, Armadillopteryx, Mjbuoni, GKFX, M hariprasad, Dexbot, Razibot, Epicgenius, Purnendu Karmakar, Qnwu, Jos Carlos
Matemticas, Freemanjs, Gavnerfsk, Sreenidhi V, Sr33r4G, Magic links bot and Anonymous: 115

12.2 Images
File:Nuvola_apps_edu_mathematics_blue-p.svg Source: https://upload.wikimedia.org/wikipedia/commons/3/3e/Nuvola_apps_edu_
mathematics_blue-p.svg License: GPL Contributors: Derivative work from Image:Nuvola apps edu mathematics.png and Image:Nuvola
apps edu mathematics-p.svg Original artist: David Vignoni (original icon); Flamurai (SVG convertion); bayo (color)
File:Pierre_de_Fermat.jpg Source: https://upload.wikimedia.org/wikipedia/commons/f/f3/Pierre_de_Fermat.jpg License: Public do-
main Contributors: http://www-groups.dcs.st-and.ac.uk/~{}history/PictDisplay/Fermat.html Original artist: ?

12.3 Content license


Creative Commons Attribution-Share Alike 3.0

You might also like