<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.sarg.dev/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=23.84.110.223</id>
	<title>Vero - Wikipedia - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.sarg.dev/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=23.84.110.223"/>
	<link rel="alternate" type="text/html" href="https://wiki.sarg.dev/index.php/Special:Contributions/23.84.110.223"/>
	<updated>2026-06-11T20:49:50Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.44.2</generator>
	<entry>
		<id>https://wiki.sarg.dev/index.php?title=Proofs_of_Fermat%27s_little_theorem&amp;diff=65004</id>
		<title>Proofs of Fermat&#039;s little theorem</title>
		<link rel="alternate" type="text/html" href="https://wiki.sarg.dev/index.php?title=Proofs_of_Fermat%27s_little_theorem&amp;diff=65004"/>
		<updated>2025-02-19T17:09:41Z</updated>

		<summary type="html">&lt;p&gt;23.84.110.223: /* Simplifications */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Short description|none}} &amp;lt;!-- This short description is INTENTIONALLY &amp;quot;none&amp;quot; - please see WP:SDNONE before you consider changing it! --&amp;gt;&lt;br /&gt;
This article collects together a variety of [[mathematical proof|proofs]] of [[Fermat&#039;s little theorem]], which states that&lt;br /&gt;
:&amp;lt;math&amp;gt;a^p \equiv a \pmod p&amp;lt;/math&amp;gt;&lt;br /&gt;
for every [[prime number]] &#039;&#039;p&#039;&#039; and every [[integer]] &#039;&#039;a&#039;&#039; (see [[modular arithmetic]]).&lt;br /&gt;
&lt;br /&gt;
==Simplifications==&lt;br /&gt;
Some of the &#039;&#039;&#039;proofs of Fermat&#039;s little theorem&#039;&#039;&#039; given below depend on two simplifications.&lt;br /&gt;
&lt;br /&gt;
The first is that we may assume that {{mvar|a}} is in the range {{math|0 ≤ &#039;&#039;a&#039;&#039; ≤ &#039;&#039;p&#039;&#039; − 1}}. This is a simple consequence of the laws of [[modular arithmetic]]; we are simply saying that we may first reduce {{mvar|a}} modulo&amp;amp;nbsp;{{mvar|p}}. This is consistent with reducing &amp;lt;math&amp;gt;a^p &amp;lt;/math&amp;gt; modulo&amp;amp;nbsp;{{mvar|p}}, as one can check.&lt;br /&gt;
&lt;br /&gt;
Secondly, it suffices to prove that&lt;br /&gt;
:&amp;lt;math&amp;gt;a^{p-1} \equiv 1 \pmod p&amp;lt;/math&amp;gt;&lt;br /&gt;
for {{mvar|a}} in the range {{math|1 ≤ &#039;&#039;a&#039;&#039; ≤ &#039;&#039;p&#039;&#039; − 1}}. Indeed, if the previous assertion holds for such {{mvar|a}}, multiplying both sides by {{math|&#039;&#039;a&#039;&#039;}} yields the original form of the theorem,&lt;br /&gt;
:&amp;lt;math&amp;gt;a^p \equiv a \pmod p &amp;lt;/math&amp;gt;&lt;br /&gt;
On the other hand, if {{math|&#039;&#039;a&#039;&#039; {{=}} 0}}, the theorem holds trivially.&lt;br /&gt;
&lt;br /&gt;
==Combinatorial proofs==&lt;br /&gt;
&lt;br /&gt;
===Proof by counting necklaces===&lt;br /&gt;
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 [[Double counting (proof technique)|counting a collection of objects in two different ways]]).&lt;br /&gt;
&lt;br /&gt;
The proof given here is an adaptation of [[Solomon W. Golomb|Golomb]]&#039;s proof.&amp;lt;ref&amp;gt;{{Citation|last = Golomb|first = Solomon W.|author-link = Solomon W. Golomb|url = http://www.cimat.mx/~mmoreno/teaching/spring08/Fermats_Little_Thm.pdf|title = Combinatorial proof of Fermat&#039;s &amp;quot;Little&amp;quot; Theorem|journal = [[American Mathematical Monthly]]|volume = 63|issue = 10|year =1956|pages = 718|jstor = 2309563|doi = 10.2307/2309563}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To keep things simple, let us assume that {{mvar|a}} is a [[positive integer]]. Consider all the possible [[string (computer science)|strings]] of {{math|&#039;&#039;p&#039;&#039;}} symbols, using an [[alphabet]] with {{mvar|a}} different symbols. The total number of such strings is {{math|&#039;&#039;a&amp;lt;sup&amp;gt;p&amp;lt;/sup&amp;gt;&#039;&#039;}} since there are {{mvar|a}} possibilities for each of {{mvar|p}} positions (see [[rule of product]]).&lt;br /&gt;
&lt;br /&gt;
For example, if {{math|&#039;&#039;p&#039;&#039;&amp;amp;nbsp;{{=}}&amp;amp;nbsp;5}} and {{math|&#039;&#039;a&#039;&#039; {{=}} 2}}, then we can use an alphabet with two symbols (say {{mvar|A}} and {{mvar|B}}), and there are {{math|2&amp;lt;sup&amp;gt;5&amp;lt;/sup&amp;gt;&amp;amp;nbsp;{{=}}&amp;amp;nbsp;32}} strings of length 5:&lt;br /&gt;
: {{math|&#039;&#039;AAAAA&#039;&#039;}}, {{math|&#039;&#039;AAAAB&#039;&#039;}}, {{math|&#039;&#039;AAABA&#039;&#039;}}, {{math|&#039;&#039;AAABB&#039;&#039;}}, {{math|&#039;&#039;AABAA&#039;&#039;}}, {{math|&#039;&#039;AABAB&#039;&#039;}}, {{math|&#039;&#039;AABBA&#039;&#039;}}, {{math|&#039;&#039;AABBB&#039;&#039;}},&lt;br /&gt;
: {{math|&#039;&#039;ABAAA&#039;&#039;}}, {{math|&#039;&#039;ABAAB&#039;&#039;}}, {{math|&#039;&#039;ABABA&#039;&#039;}}, {{math|&#039;&#039;ABABB&#039;&#039;}}, {{math|&#039;&#039;ABBAA&#039;&#039;}}, {{math|&#039;&#039;ABBAB&#039;&#039;}}, {{math|&#039;&#039;ABBBA&#039;&#039;}}, {{math|&#039;&#039;ABBBB&#039;&#039;}},&lt;br /&gt;
: {{math|&#039;&#039;BAAAA&#039;&#039;}}, {{math|&#039;&#039;BAAAB&#039;&#039;}}, {{math|&#039;&#039;BAABA&#039;&#039;}}, {{math|&#039;&#039;BAABB&#039;&#039;}}, {{math|&#039;&#039;BABAA&#039;&#039;}}, {{math|&#039;&#039;BABAB&#039;&#039;}}, {{math|&#039;&#039;BABBA&#039;&#039;}}, {{math|&#039;&#039;BABBB&#039;&#039;}},&lt;br /&gt;
: {{math|&#039;&#039;BBAAA&#039;&#039;}}, {{math|&#039;&#039;BBAAB&#039;&#039;}}, {{math|&#039;&#039;BBABA&#039;&#039;}}, {{math|&#039;&#039;BBABB&#039;&#039;}}, {{math|&#039;&#039;BBBAA&#039;&#039;}}, {{math|&#039;&#039;BBBAB&#039;&#039;}}, {{math|&#039;&#039;BBBBA&#039;&#039;}}, {{math|&#039;&#039;BBBBB&#039;&#039;}}.&lt;br /&gt;
&lt;br /&gt;
We will argue below that if we remove the strings consisting of a single symbol from the list (in our example, {{math|&#039;&#039;AAAAA&#039;&#039;}} and {{math|&#039;&#039;BBBBB&#039;&#039;}}), the remaining {{math|&#039;&#039;a&amp;lt;sup&amp;gt;p&amp;lt;/sup&amp;gt;&#039;&#039; − &#039;&#039;a&#039;&#039;}} strings can be arranged into groups, each group containing exactly {{mvar|p}} strings. It follows that {{math|&#039;&#039;a&amp;lt;sup&amp;gt;p&amp;lt;/sup&amp;gt;&#039;&#039; − &#039;&#039;a&#039;&#039;}} is divisible by&amp;amp;nbsp;{{mvar|p}}.&lt;br /&gt;
&lt;br /&gt;
====Necklaces====&lt;br /&gt;
[[Image:Proofs-of-Fermats-Little-Theorem-bracelet1.svg|frame|right|Necklace representing seven different strings ({{math|&#039;&#039;ABCBAAC&#039;&#039;}}, {{math|&#039;&#039;BCBAACA&#039;&#039;}}, {{math|&#039;&#039;CBAACAB&#039;&#039;}}, {{math|&#039;&#039;BAACABC&#039;&#039;}}, {{math|&#039;&#039;AACABCB&#039;&#039;}}, {{math|&#039;&#039;ACABCBA&#039;&#039;}}, {{math|&#039;&#039;CABCBAA&#039;&#039;}})]]&lt;br /&gt;
[[Image:Proofs-of-Fermats-Little-Theorem-bracelet2.svg|frame|right|Necklace representing only one string ({{math|&#039;&#039;AAAAAAA&#039;&#039;}})]]&lt;br /&gt;
&lt;br /&gt;
Let us think of each such string as representing a [[necklace (combinatorics)|necklace]]. That is, we connect the two ends of the string together and regard two strings as the same necklace if we can [[circular shift|rotate]] one string to obtain the second string; in this case we will say that the two strings are &#039;&#039;friends&#039;&#039;. In our example, the following strings are all friends:&lt;br /&gt;
: {{math|&#039;&#039;AAAAB&#039;&#039;}}, {{math|&#039;&#039;AAABA&#039;&#039;}}, {{math|&#039;&#039;AABAA&#039;&#039;}}, {{math|&#039;&#039;ABAAA&#039;&#039;}}, {{math|&#039;&#039;BAAAA&#039;&#039;}}.&lt;br /&gt;
In full, each line of the following list corresponds to a single necklace, and the entire list comprises all 32 strings.&lt;br /&gt;
: {{math|&#039;&#039;AAAAB&#039;&#039;}}, {{math|&#039;&#039;AAABA&#039;&#039;}}, {{math|&#039;&#039;AABAA&#039;&#039;}}, {{math|&#039;&#039;ABAAA&#039;&#039;}}, {{math|&#039;&#039;BAAAA&#039;&#039;}}, &lt;br /&gt;
: {{math|&#039;&#039;AAABB&#039;&#039;}}, {{math|&#039;&#039;AABBA&#039;&#039;}}, {{math|&#039;&#039;ABBAA&#039;&#039;}}, {{math|&#039;&#039;BBAAA&#039;&#039;}}, {{math|&#039;&#039;BAAAB&#039;&#039;}},&lt;br /&gt;
: {{math|&#039;&#039;AABAB&#039;&#039;}}, {{math|&#039;&#039;ABABA&#039;&#039;}}, {{math|&#039;&#039;BABAA&#039;&#039;}}, {{math|&#039;&#039;ABAAB&#039;&#039;}}, {{math|&#039;&#039;BAABA&#039;&#039;}},&lt;br /&gt;
: {{math|&#039;&#039;AABBB&#039;&#039;}}, {{math|&#039;&#039;ABBBA&#039;&#039;}}, {{math|&#039;&#039;BBBAA&#039;&#039;}}, {{math|&#039;&#039;BBAAB&#039;&#039;}}, {{math|&#039;&#039;BAABB&#039;&#039;}},&lt;br /&gt;
: {{math|&#039;&#039;ABABB&#039;&#039;}}, {{math|&#039;&#039;BABBA&#039;&#039;}}, {{math|&#039;&#039;ABBAB&#039;&#039;}}, {{math|&#039;&#039;BBABA&#039;&#039;}}, {{math|&#039;&#039;BABAB&#039;&#039;}},&lt;br /&gt;
: {{math|&#039;&#039;ABBBB&#039;&#039;}}, {{math|&#039;&#039;BBBBA&#039;&#039;}}, {{math|&#039;&#039;BBBAB&#039;&#039;}}, {{math|&#039;&#039;BBABB&#039;&#039;}}, {{math|&#039;&#039;BABBB&#039;&#039;}},&lt;br /&gt;
: {{math|&#039;&#039;AAAAA&#039;&#039;}},&lt;br /&gt;
: {{math|&#039;&#039;BBBBB&#039;&#039;}}.&lt;br /&gt;
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 {{math|32&amp;amp;nbsp;−&amp;amp;nbsp;2}} is divisible by {{math|5}}.&lt;br /&gt;
&lt;br /&gt;
One can use the following rule to work out how many friends a given string {{math|&#039;&#039;S&#039;&#039;}} has:&lt;br /&gt;
: If {{math|&#039;&#039;S&#039;&#039;}} is built up of several copies of the string {{math|&#039;&#039;T&#039;&#039;}}, and {{math|&#039;&#039;T&#039;&#039;}} cannot itself be broken down further into repeating strings, then the number of friends of {{math|&#039;&#039;S&#039;&#039;}} (including {{math|&#039;&#039;S&#039;&#039;}} itself) is equal to the &#039;&#039;length&#039;&#039; of {{math|&#039;&#039;T&#039;&#039;}}.&lt;br /&gt;
&lt;br /&gt;
For example, suppose we start with the string {{math|&#039;&#039;S&#039;&#039;&amp;amp;nbsp;{{=}}&amp;amp;nbsp;&#039;&#039;ABBABBABBABB&#039;&#039;}}, which is built up of several copies of the shorter string {{math|&#039;&#039;T&#039;&#039;&amp;amp;nbsp;{{=}}&amp;amp;nbsp;&#039;&#039;ABB&#039;&#039;}}. If we rotate it one symbol at a time, we obtain the following 3 strings:&lt;br /&gt;
: {{math|&#039;&#039;ABBABBABBABB&#039;&#039;}},&lt;br /&gt;
: {{math|&#039;&#039;BBABBABBABBA&#039;&#039;}},&lt;br /&gt;
: {{math|&#039;&#039;BABBABBABBAB&#039;&#039;}}.&lt;br /&gt;
There aren&#039;t any others because {{mvar|ABB}} is exactly 3 symbols long and cannot be broken down into further repeating strings.&lt;br /&gt;
&lt;br /&gt;
====Completing the proof====&lt;br /&gt;
Using the above rule, we can complete the proof of Fermat&#039;s little theorem quite easily, as follows. Our starting pool of {{math|&#039;&#039;a&amp;lt;sup&amp;gt; p&amp;lt;/sup&amp;gt;&#039;&#039;}} strings may be split into two categories:&lt;br /&gt;
* Some strings contain {{mvar|p}} identical symbols. There are exactly {{mvar|a}} of these, one for each symbol in the alphabet. (In our running example, these are the strings {{mvar|AAAAA}} and {{mvar|BBBBB}}.)&lt;br /&gt;
* The rest of the strings use at least two distinct symbols from the alphabet. If we can break up a given string {{mvar|S}} into repeating copies of some string {{mvar|T}}, the length of {{mvar|T}} must divide the length of {{mvar|S}}. But since the length of {{mvar|S}} is the prime {{mvar|p}}, the only possible length for {{mvar|T}} is also {{mvar|p}}. Therefore, the above rule tells us that {{mvar|S}} has exactly {{mvar|p}} friends (including {{mvar|S}} itself).&lt;br /&gt;
&lt;br /&gt;
The second category contains {{math|&#039;&#039;a&amp;lt;sup&amp;gt; p&amp;lt;/sup&amp;gt;&#039;&#039; − &#039;&#039;a&#039;&#039;}} strings, and they may be arranged into groups of {{mvar|p}} strings, one group for each necklace. Therefore, {{math|&#039;&#039;a&amp;lt;sup&amp;gt; p&amp;lt;/sup&amp;gt;&#039;&#039; − &#039;&#039;a&#039;&#039;}} must be divisible by {{mvar|p}}, as promised.&lt;br /&gt;
&lt;br /&gt;
===Proof using dynamical systems===&lt;br /&gt;
This proof uses some basic concepts from [[dynamical system]]s.&amp;lt;ref&amp;gt;{{Citation|last = Iga|first = Kevin|title = A Dynamical Systems Proof of Fermat&#039;s Little Theorem|journal = [[Mathematics Magazine]]|volume = 76|issue = 1|year = 2003|pages = 48–51|doi = 10.2307/3219132|jstor = 3219132}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We start by considering a family of [[function (mathematics)|functions]] &#039;&#039;T&#039;&#039;&amp;lt;sub&amp;gt;&#039;&#039;n&#039;&#039;&amp;lt;/sub&amp;gt;(&#039;&#039;x&#039;&#039;), where &#039;&#039;n&#039;&#039; ≥ 2 is an [[integer]], mapping the [[interval (mathematics)|interval]] [0, 1] to itself by the formula&lt;br /&gt;
:&amp;lt;math&amp;gt;T_n(x) = \begin{cases}&lt;br /&gt;
 \{ nx \} &amp;amp; 0 \leq x &amp;lt; 1, \\&lt;br /&gt;
 1        &amp;amp; x = 1,&lt;br /&gt;
\end{cases}&amp;lt;/math&amp;gt;&lt;br /&gt;
where {&#039;&#039;y&#039;&#039;} denotes the [[fractional part]] of &#039;&#039;y&#039;&#039;. For example, the function &#039;&#039;T&#039;&#039;&amp;lt;sub&amp;gt;3&amp;lt;/sub&amp;gt;(&#039;&#039;x&#039;&#039;) is illustrated below:&lt;br /&gt;
&lt;br /&gt;
[[Image:Proofs-of-Fermats-Little-Theorem-dynamic1.png|200px|center|An example of a &#039;&#039;T&#039;&#039;&amp;lt;sub&amp;gt;&#039;&#039;n&#039;&#039;&amp;lt;/sub&amp;gt; function]]&lt;br /&gt;
&lt;br /&gt;
A number &#039;&#039;x&#039;&#039;&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt; is said to be a &#039;&#039;[[fixed point (mathematics)|fixed point]]&#039;&#039; of a function &#039;&#039;f&#039;&#039;(&#039;&#039;x&#039;&#039;) if &#039;&#039;f&#039;&#039;(&#039;&#039;x&#039;&#039;&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;) = &#039;&#039;x&#039;&#039;&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;; in other words, if &#039;&#039;f&#039;&#039; leaves &#039;&#039;x&#039;&#039;&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt; fixed. The fixed points of a function can be easily found graphically: they are simply the &#039;&#039;x&#039;&#039; coordinates of the points where the [[Graph of a function|graph]] of &#039;&#039;f&#039;&#039;(&#039;&#039;x&#039;&#039;) intersects the graph of the line &#039;&#039;y&#039;&#039; = &#039;&#039;x&#039;&#039;. For example, the fixed points of the function &#039;&#039;T&#039;&#039;&amp;lt;sub&amp;gt;3&amp;lt;/sub&amp;gt;(&#039;&#039;x&#039;&#039;) are 0, 1/2, and 1; they are marked by black circles on the following diagram:&lt;br /&gt;
&lt;br /&gt;
[[Image:Proofs-of-Fermats-Little-Theorem-dynamic2.png|180px|center|Fixed points of a &#039;&#039;T&#039;&#039;&amp;lt;sub&amp;gt;&#039;&#039;n&#039;&#039;&amp;lt;/sub&amp;gt; function]]&lt;br /&gt;
&lt;br /&gt;
We will require the following two lemmas.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Lemma 1.&#039;&#039;&#039; For any &#039;&#039;n&#039;&#039; ≥ 2, the function &#039;&#039;T&#039;&#039;&amp;lt;sub&amp;gt;&#039;&#039;n&#039;&#039;&amp;lt;/sub&amp;gt;(&#039;&#039;x&#039;&#039;) has exactly &#039;&#039;n&#039;&#039; fixed points.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Proof.&#039;&#039;&#039; There are 3 fixed points in the illustration above, and the same sort of geometrical argument applies for any &#039;&#039;n&#039;&#039; ≥ 2.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Lemma 2.&#039;&#039;&#039; For any positive integers &#039;&#039;n&#039;&#039; and &#039;&#039;m&#039;&#039;, and any 0 ≤ x ≤ 1,&lt;br /&gt;
:&amp;lt;math&amp;gt;T_m(T_n(x)) = T_{mn}(x).&amp;lt;/math&amp;gt;&lt;br /&gt;
In other words, &#039;&#039;T&#039;&#039;&amp;lt;sub&amp;gt;&#039;&#039;mn&#039;&#039;&amp;lt;/sub&amp;gt;(&#039;&#039;x&#039;&#039;) is the [[function composition|composition]] of &#039;&#039;T&#039;&#039;&amp;lt;sub&amp;gt;&#039;&#039;n&#039;&#039;&amp;lt;/sub&amp;gt;(&#039;&#039;x&#039;&#039;) and &#039;&#039;T&#039;&#039;&amp;lt;sub&amp;gt;&#039;&#039;m&#039;&#039;&amp;lt;/sub&amp;gt;(&#039;&#039;x&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Proof.&#039;&#039;&#039; The proof of this lemma is not difficult, but we need to be slightly careful with the endpoint &#039;&#039;x&#039;&#039; = 1. For this point the lemma is clearly true, since&lt;br /&gt;
:&amp;lt;math&amp;gt;T_m(T_n(1)) = T_m(1) = 1 = T_{mn}(1).&amp;lt;/math&amp;gt;&lt;br /&gt;
So let us assume that 0 ≤ &#039;&#039;x&#039;&#039; &amp;lt; 1. In this case,&lt;br /&gt;
:&amp;lt;math&amp;gt;T_n(x) = \{nx\} &amp;lt; 1, &amp;lt;/math&amp;gt;&lt;br /&gt;
so &#039;&#039;T&#039;&#039;&amp;lt;sub&amp;gt;&#039;&#039;m&#039;&#039;&amp;lt;/sub&amp;gt;(&#039;&#039;T&#039;&#039;&amp;lt;sub&amp;gt;&#039;&#039;n&#039;&#039;&amp;lt;/sub&amp;gt;(&#039;&#039;x&#039;&#039;)) is given by&lt;br /&gt;
:&amp;lt;math&amp;gt;T_m(T_n(x)) = \{m\{nx\}\}.&amp;lt;/math&amp;gt;&lt;br /&gt;
Therefore, what we really need to show is that&lt;br /&gt;
:&amp;lt;math&amp;gt;\{m\{nx\}\} = \{mnx\}.&amp;lt;/math&amp;gt;&lt;br /&gt;
To do this we observe that {&#039;&#039;nx&#039;&#039;} = &#039;&#039;nx&#039;&#039; − &#039;&#039;k&#039;&#039;, where &#039;&#039;k&#039;&#039; is the [[integer part]] of &#039;&#039;nx&#039;&#039;; then&lt;br /&gt;
:&amp;lt;math&amp;gt;\{m\{nx\}\} = \{mnx - mk\} = \{mnx\},&amp;lt;/math&amp;gt;&lt;br /&gt;
since &#039;&#039;mk&#039;&#039; is an integer.&lt;br /&gt;
&lt;br /&gt;
Now let us properly begin the proof of Fermat&#039;s little theorem, by studying the function &#039;&#039;T&#039;&#039;&amp;lt;sub&amp;gt;&#039;&#039;a&#039;&#039;&amp;lt;sup&amp;gt;&#039;&#039;p&#039;&#039;&amp;lt;/sup&amp;gt;&amp;lt;/sub&amp;gt;(&#039;&#039;x&#039;&#039;). We will assume that &#039;&#039;a&#039;&#039; ≥ 2. From Lemma 1, we know that it has &#039;&#039;a&#039;&#039;&amp;lt;sup&amp;gt;&#039;&#039;p&#039;&#039;&amp;lt;/sup&amp;gt; fixed points. By Lemma 2 we know that&lt;br /&gt;
:&amp;lt;math&amp;gt;T_{a^p}(x) = \underbrace{T_a(T_a( \cdots T_a(x) \cdots ))}_{p\text{ times}},&amp;lt;/math&amp;gt;&lt;br /&gt;
so any fixed point of &#039;&#039;T&#039;&#039;&amp;lt;sub&amp;gt;&#039;&#039;a&#039;&#039;&amp;lt;/sub&amp;gt;(&#039;&#039;x&#039;&#039;) is automatically a fixed point of &#039;&#039;T&#039;&#039;&amp;lt;sub&amp;gt;&#039;&#039;a&#039;&#039;&amp;lt;sup&amp;gt;&#039;&#039;p&#039;&#039;&amp;lt;/sup&amp;gt;&amp;lt;/sub&amp;gt;(&#039;&#039;x&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
We are interested in the fixed points of &#039;&#039;T&#039;&#039;&amp;lt;sub&amp;gt;&#039;&#039;a&#039;&#039;&amp;lt;sup&amp;gt;&#039;&#039;p&#039;&#039;&amp;lt;/sup&amp;gt;&amp;lt;/sub&amp;gt;(&#039;&#039;x&#039;&#039;) that are &#039;&#039;not&#039;&#039; fixed points of &#039;&#039;T&#039;&#039;&amp;lt;sub&amp;gt;&#039;&#039;a&#039;&#039;&amp;lt;/sub&amp;gt;(&#039;&#039;x&#039;&#039;). Let us call the set of such points &#039;&#039;S&#039;&#039;. There are &#039;&#039;a&#039;&#039;&amp;lt;sup&amp;gt;&#039;&#039;p&#039;&#039;&amp;lt;/sup&amp;gt; − &#039;&#039;a&#039;&#039; points in &#039;&#039;S&#039;&#039;, because by Lemma 1 again, &#039;&#039;T&#039;&#039;&amp;lt;sub&amp;gt;&#039;&#039;a&#039;&#039;&amp;lt;/sub&amp;gt;(&#039;&#039;x&#039;&#039;) has exactly &#039;&#039;a&#039;&#039; fixed points. The following diagram illustrates the situation for &#039;&#039;a&#039;&#039; = 3 and &#039;&#039;p&#039;&#039; = 2. The black circles are the points of &#039;&#039;S&#039;&#039;, of which there are 3&amp;lt;sup&amp;gt;2&amp;lt;/sup&amp;gt; − 3 = 6.&lt;br /&gt;
&lt;br /&gt;
[[Image:Proofs-of-Fermats-Little-Theorem-dynamic3.png|250px|center|Fixed points in the set &#039;&#039;S&#039;&#039;]]&lt;br /&gt;
&lt;br /&gt;
The main idea of the proof is now to split the set &#039;&#039;S&#039;&#039; up into its [[orbit (dynamics)|orbits]] under &#039;&#039;T&#039;&#039;&amp;lt;sub&amp;gt;&#039;&#039;a&#039;&#039;&amp;lt;/sub&amp;gt;. What this means is that we pick a point &#039;&#039;x&#039;&#039;&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt; in &#039;&#039;S&#039;&#039;, and repeatedly apply &#039;&#039;T&#039;&#039;&amp;lt;sub&amp;gt;&#039;&#039;a&#039;&#039;&amp;lt;/sub&amp;gt;(x) to it, to obtain the sequence of points&lt;br /&gt;
:&amp;lt;math&amp;gt; x_0, T_a(x_0), T_a(T_a(x_0)), T_a(T_a(T_a(x_0))), \ldots. &amp;lt;/math&amp;gt;&lt;br /&gt;
This sequence is called the orbit of &#039;&#039;x&#039;&#039;&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt; under &#039;&#039;T&#039;&#039;&amp;lt;sub&amp;gt;&#039;&#039;a&#039;&#039;&amp;lt;/sub&amp;gt;. By Lemma 2, this sequence can be rewritten as&lt;br /&gt;
:&amp;lt;math&amp;gt; x_0, T_a(x_0), T_{a^2}(x_0), T_{a^3}(x_0), \ldots. &amp;lt;/math&amp;gt;&lt;br /&gt;
Since we are assuming that &#039;&#039;x&#039;&#039;&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt; is a fixed point of &#039;&#039;T&#039;&#039;&amp;lt;sub&amp;gt;&#039;&#039;a&#039;&#039;&amp;lt;sup&amp;gt; &#039;&#039;p&#039;&#039;&amp;lt;/sup&amp;gt;&amp;lt;/sub&amp;gt;(&#039;&#039;x&#039;&#039;), after &#039;&#039;p&#039;&#039; steps we hit &#039;&#039;T&#039;&#039;&amp;lt;sub&amp;gt;&#039;&#039;a&#039;&#039;&amp;lt;sup&amp;gt;&#039;&#039;p&#039;&#039;&amp;lt;/sup&amp;gt;&amp;lt;/sub&amp;gt;(&#039;&#039;x&#039;&#039;&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;) = &#039;&#039;x&#039;&#039;&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;, and from that point onwards the sequence repeats itself.&lt;br /&gt;
&lt;br /&gt;
However, the sequence &#039;&#039;cannot&#039;&#039; begin repeating itself any earlier than that. If it did, the length of the repeating section would have to be a divisor of &#039;&#039;p&#039;&#039;, so it would have to be 1 (since &#039;&#039;p&#039;&#039; is prime). But this contradicts our assumption that &#039;&#039;x&#039;&#039;&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt; is not a fixed point of &#039;&#039;T&#039;&#039;&amp;lt;sub&amp;gt;&#039;&#039;a&#039;&#039;&amp;lt;/sub&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
In other words, the orbit contains exactly &#039;&#039;p&#039;&#039; distinct points. This holds for every orbit of &#039;&#039;S&#039;&#039;. Therefore, the set &#039;&#039;S&#039;&#039;, which contains &#039;&#039;a&#039;&#039;&amp;lt;sup&amp;gt;&#039;&#039;p&#039;&#039;&amp;lt;/sup&amp;gt;&amp;amp;nbsp;−&amp;amp;nbsp;&#039;&#039;a&#039;&#039; points, can be broken up into orbits, each containing &#039;&#039;p&#039;&#039; points, so &#039;&#039;a&#039;&#039;&amp;lt;sup&amp;gt;&#039;&#039;p&#039;&#039;&amp;lt;/sup&amp;gt;&amp;amp;nbsp;−&amp;amp;nbsp;&#039;&#039;a&#039;&#039; is divisible by &#039;&#039;p&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
(This proof is essentially the same as the [[#Proof by counting necklaces|necklace-counting proof]] given above, simply viewed through a different lens: one may think of the interval [0,&amp;amp;nbsp;1] as given by sequences of digits in base &#039;&#039;a&#039;&#039; (our distinction between 0 and 1 corresponding to the familiar distinction between representing integers as ending in &amp;quot;.0000...&amp;quot; and &amp;quot;.9999...&amp;quot;). &#039;&#039;T&#039;&#039;&amp;lt;sub&amp;gt;&#039;&#039;a&#039;&#039;&amp;lt;sup&amp;gt;&#039;&#039;n&#039;&#039;&amp;lt;/sup&amp;gt;&amp;lt;/sub&amp;gt; amounts to shifting such a sequence by &#039;&#039;n&#039;&#039; many digits. The fixed points of this will be sequences that are cyclic with period dividing &#039;&#039;n&#039;&#039;. In particular, the fixed points of &#039;&#039;T&#039;&#039;&amp;lt;sub&amp;gt;&#039;&#039;a&#039;&#039;&amp;lt;sup&amp;gt;&#039;&#039;p&#039;&#039;&amp;lt;/sup&amp;gt;&amp;lt;/sub&amp;gt; can be thought of as the necklaces of length &#039;&#039;p&#039;&#039;, with &#039;&#039;T&#039;&#039;&amp;lt;sub&amp;gt;&#039;&#039;a&#039;&#039;&amp;lt;sup&amp;gt;&#039;&#039;n&#039;&#039;&amp;lt;/sup&amp;gt;&amp;lt;/sub&amp;gt; corresponding to rotation of such necklaces by &#039;&#039;n&#039;&#039; spots.&lt;br /&gt;
&lt;br /&gt;
This proof could also be presented without distinguishing between 0 and 1, simply using the half-open interval [0, 1); then &#039;&#039;T&#039;&#039;&amp;lt;sub&amp;gt;&#039;&#039;n&#039;&#039;&amp;lt;/sub&amp;gt; would only have &#039;&#039;n&#039;&#039; − 1 fixed points, but &#039;&#039;T&#039;&#039;&amp;lt;sub&amp;gt;&#039;&#039;a&#039;&#039;&amp;lt;sup&amp;gt;&#039;&#039;p&#039;&#039;&amp;lt;/sup&amp;gt;&amp;lt;/sub&amp;gt; − &#039;&#039;T&#039;&#039;&amp;lt;sub&amp;gt;&#039;&#039;a&#039;&#039;&amp;lt;/sub&amp;gt; would still work out to &#039;&#039;a&#039;&#039;&amp;lt;sup&amp;gt;&#039;&#039;p&#039;&#039;&amp;lt;/sup&amp;gt; − &#039;&#039;a&#039;&#039;, as needed.)&lt;br /&gt;
&lt;br /&gt;
===Multinomial proofs===&lt;br /&gt;
&lt;br /&gt;
====Proofs using the binomial theorem====&lt;br /&gt;
&lt;br /&gt;
====Proof 1====&lt;br /&gt;
&lt;br /&gt;
This proof, due to [[Leonhard Euler|Euler]],&amp;lt;ref name=&amp;quot;Dickson&amp;quot;/&amp;gt; uses [[mathematical induction|induction]] to prove the theorem for all integers {{math|&#039;&#039;a&#039;&#039;&amp;amp;nbsp;≥&amp;amp;nbsp;0}}.&lt;br /&gt;
&lt;br /&gt;
The base step, that {{math|0&amp;lt;sup&amp;gt;&#039;&#039;p&#039;&#039;&amp;lt;/sup&amp;gt;&amp;amp;nbsp;≡&amp;amp;nbsp;0 (mod&amp;amp;nbsp;&#039;&#039;p&#039;&#039;)}}, is trivial. Next, we must show that if the theorem is true for {{math|&#039;&#039;a&#039;&#039;&amp;amp;nbsp;{{=}}&amp;amp;nbsp;&#039;&#039;k&#039;&#039;}}, then it is also true for {{math|&#039;&#039;a&#039;&#039;&amp;amp;nbsp;{{=}}&amp;amp;nbsp;&#039;&#039;k&#039;&#039;&amp;amp;nbsp;+&amp;amp;nbsp;1}}. For this inductive step, we need the following lemma.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Lemma&#039;&#039;&#039;. For any integers {{math|&#039;&#039;x&#039;&#039;}} and {{math|&#039;&#039;y&#039;&#039;}} and for any prime {{math|&#039;&#039;p&#039;&#039;}}, {{math|(&#039;&#039;x&#039;&#039;&amp;amp;nbsp;+&amp;amp;nbsp;&#039;&#039;y&#039;&#039;)&amp;lt;sup&amp;gt;&#039;&#039;p&#039;&#039;&amp;lt;/sup&amp;gt;&amp;amp;nbsp;≡&amp;amp;nbsp;&#039;&#039;x&amp;lt;sup&amp;gt;p&amp;lt;/sup&amp;gt;&#039;&#039;&amp;amp;nbsp;+&amp;amp;nbsp;&#039;&#039;y&amp;lt;sup&amp;gt;p&amp;lt;/sup&amp;gt;&#039;&#039;&amp;amp;nbsp;(mod&amp;amp;nbsp;&#039;&#039;p&#039;&#039;)}}.&lt;br /&gt;
&lt;br /&gt;
The lemma is a case of the [[freshman&#039;s dream]]. Leaving the proof for later on, we proceed with the induction.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Proof&#039;&#039;&#039;. Assume &#039;&#039;k&#039;&#039;&amp;lt;sup&amp;gt;&#039;&#039;p&#039;&#039;&amp;lt;/sup&amp;gt; ≡ &#039;&#039;k&#039;&#039; (mod &#039;&#039;p&#039;&#039;), and consider (&#039;&#039;k&#039;&#039;+1)&amp;lt;sup&amp;gt;&#039;&#039;p&#039;&#039;&amp;lt;/sup&amp;gt;. By the lemma we have&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;math&amp;gt;(k+1)^p \equiv k^p + 1^p \pmod{p}.&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Using the induction hypothesis, we have that &#039;&#039;k&#039;&#039;&amp;lt;sup&amp;gt;&#039;&#039;p&#039;&#039;&amp;lt;/sup&amp;gt; ≡ &#039;&#039;k&#039;&#039; (mod &#039;&#039;p&#039;&#039;); and, trivially, 1&amp;lt;sup&amp;gt;&#039;&#039;p&#039;&#039;&amp;lt;/sup&amp;gt; = 1. Thus&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;math&amp;gt;(k+1)^p \equiv k + 1 \pmod{p},&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
which is the statement of the theorem for &#039;&#039;a&#039;&#039; = &#039;&#039;k&#039;&#039;+1. ∎&lt;br /&gt;
&lt;br /&gt;
In order to prove the lemma, we must introduce the [[binomial theorem]], which states that for any positive integer &#039;&#039;n&#039;&#039;,&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;math&amp;gt;(x+y)^n=\sum_{i=0}^n{n \choose i}x^{n-i}y^i,&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where the coefficients are the [[binomial coefficients]],&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;math&amp;gt;{n \choose i}=\frac{n!}{i!(n-i)!},&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
described in terms of the [[factorial]] function, &#039;&#039;n&#039;&#039;! = 1×2×3×⋯×&#039;&#039;n&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Proof of Lemma.&#039;&#039;&#039; We consider the binomial coefficient when the exponent is a prime &#039;&#039;p&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;math&amp;gt;{p \choose i}=\frac{p!}{i!(p-i)!}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The binomial coefficients are all integers.  The numerator contains a factor &#039;&#039;p&#039;&#039; by the definition of factorial.  When 0 &amp;lt; &#039;&#039;i&#039;&#039; &amp;lt; &#039;&#039;p&#039;&#039;, neither of the terms in the denominator includes a factor of &#039;&#039;p&#039;&#039; (relying on the primality of &#039;&#039;p&#039;&#039;), leaving the coefficient itself to possess a prime factor of &#039;&#039;p&#039;&#039; from the numerator, implying that&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;math&amp;gt;{p \choose i} \equiv 0 \pmod{p},\qquad 0 &amp;lt; i &amp;lt; p.&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Modulo &#039;&#039;p&#039;&#039;, this eliminates all but the first and last terms of the sum on the right-hand side of the binomial theorem for prime &#039;&#039;p&#039;&#039;. ∎&lt;br /&gt;
&lt;br /&gt;
The primality of &#039;&#039;p&#039;&#039; is essential to the lemma; otherwise, we have examples like&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;math&amp;gt;{4 \choose 2} = 6,&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
which is not divisible by 4.&lt;br /&gt;
&lt;br /&gt;
====Proof 2====&lt;br /&gt;
&lt;br /&gt;
Using the Lemma, we have:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;math&amp;gt;k^p \equiv ((k-1)+1)^p \equiv (k-1)^p + 1 \equiv ((k-2)+1)^p + 1 \equiv (k-2)^p + 2 \equiv \dots \equiv k \pmod{p}&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
====Proof using the multinomial expansion====&lt;br /&gt;
The proof, which was first discovered by [[Gottfried Wilhelm Leibniz|Leibniz]] (who did not publish it)&amp;lt;ref&amp;gt;{{Citation|last = Vacca|first = Giovanni|author-link = Giovanni Vacca (mathematician)|journal = Bibliotheca Mathematica| series = 2nd series|volume = 8|issue = 2|pages = 46–48|language = it|year = 1894|title = Intorno alla prima dimostrazione di un teorema di Fermat}}&amp;lt;/ref&amp;gt; and later rediscovered by [[Leonhard Euler|Euler]],&amp;lt;ref name=&amp;quot;Dickson&amp;quot;/&amp;gt; is a very simple application of the [[multinomial theorem]], which states&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;math&amp;gt;(x_1 + x_2 + \cdots + x_m)^n&lt;br /&gt;
 = \sum_{k_1,k_2,\dots,k_m \atop k_1+k_2+\dots+k_m=n} {n \choose k_1, k_2, \ldots, k_m}&lt;br /&gt;
 x_1^{k_1} x_2^{k_2} \cdots x_m^{k_m}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;math&amp;gt;{n \choose k_1, k_2, \ldots, k_m} = \frac{n!}{k_1! k_2! \dots k_m!}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and the summation is taken over all sequences of nonnegative integer indices {{math|&#039;&#039;k&#039;&#039;&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;, &#039;&#039;k&#039;&#039;&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;, ..., &#039;&#039;k&amp;lt;sub&amp;gt;m&amp;lt;/sub&amp;gt;&#039;&#039;}} such the sum of all {{math|&#039;&#039;k&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;&#039;&#039;}} is {{math|&#039;&#039;n&#039;&#039;}}.&lt;br /&gt;
&lt;br /&gt;
Thus if we express {{math|&#039;&#039;a&#039;&#039;}} as a sum of 1s (ones), we obtain&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;math&amp;gt;a^p = (1 + 1 + ... + 1)^p&lt;br /&gt;
 = \sum_{k_1,k_2,\dots,k_a \atop k_1+k_2+\dots+k_a=p} {p \choose k_1, k_2, \ldots, k_a}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Clearly, if {{math|&#039;&#039;p&#039;&#039;}} is prime, and if {{math|&#039;&#039;k&amp;lt;sub&amp;gt;j&amp;lt;/sub&amp;gt;&#039;&#039;}} is not equal to {{math|&#039;&#039;p&#039;&#039;}} for any {{math|&#039;&#039;j&#039;&#039;}}, we have&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;math&amp;gt;{p \choose k_1, k_2, \ldots, k_a} \equiv 0 \pmod p,&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and if {{math|&#039;&#039;k&amp;lt;sub&amp;gt;j&amp;lt;/sub&amp;gt;&#039;&#039;}} is equal to {{math|&#039;&#039;p&#039;&#039;}} for some {{math|&#039;&#039;j&#039;&#039;}} then&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;math&amp;gt;{p \choose k_1, k_2, \ldots, k_a} = 1.&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Since there are exactly {{math|&#039;&#039;a&#039;&#039;}} elements such that {{math|&#039;&#039;k&amp;lt;sub&amp;gt;j&amp;lt;/sub&amp;gt;&#039;&#039;&amp;amp;nbsp;{{=}}&amp;amp;nbsp;&#039;&#039;p&#039;&#039;}} for some {{math|&#039;&#039;j&#039;&#039;}}, the theorem follows.&lt;br /&gt;
&lt;br /&gt;
(This proof is essentially a coarser-grained variant of the [[#Proof by counting necklaces|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 {{math|&#039;&#039;p&#039;&#039;}} can be seen as a consequence of the fact that each nontrivial necklace of length {{math|&#039;&#039;p&#039;&#039;}} can be unwrapped into a string in {{math|&#039;&#039;p&#039;&#039;}} many ways.&lt;br /&gt;
&lt;br /&gt;
This multinomial expansion is also, of course, what essentially underlies the [[#Proofs using the binomial theorem|binomial theorem-based proof]] above)&lt;br /&gt;
&lt;br /&gt;
===Proof using power product expansions===&lt;br /&gt;
&lt;br /&gt;
An additive-combinatorial proof based on formal power product expansions was given by Giedrius Alkauskas.&amp;lt;ref&amp;gt;{{Citation|last = Alkauskas|first = Giedrius|arxiv = 0801.0805|title = A Curious Proof of Fermat&#039;s Little Theorem|journal = [[American Mathematical Monthly]]|volume = 116|issue = 4|year = 2009|pages = 362–364|jstor = 40391097|doi=10.4169/193009709x470236}}&amp;lt;/ref&amp;gt; This proof uses neither the [[Euclidean algorithm]] nor the [[binomial theorem]], but rather it employs [[formal power series]] with [[rational number|rational]] coefficients.&lt;br /&gt;
&lt;br /&gt;
==Proof as a particular case of Euler&#039;s theorem==&lt;br /&gt;
This proof,&amp;lt;ref name=&amp;quot;Dickson&amp;quot;&amp;gt;{{Citation|last = Dickson|first = Leonard Eugene|author-link = Leonard Eugene Dickson|title = History of the Theory of Numbers| volume = I|chapter = Fermat&#039;s and Wilson&#039;s theorems, generalizations, and converses; symmetric functions of {{math|1, 2, ..., &#039;&#039;p&#039;&#039;&amp;amp;nbsp;−&amp;amp;nbsp;1}} modulo {{math|&#039;&#039;p&#039;&#039;}}|publisher = [[Dover Publications|Dover]]|isbn = 978-0-486-44232-7|year = 2005|orig-year = 1919|zbl = 1214.11001|title-link = History of the Theory of Numbers}}&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;{{Citation|last = Hardy|first = G. H.|author-link = G. H. Hardy|last2 = Wright|first2 = E. M.|author2-link = E. M. Wright|publisher = [[Oxford University Press]]|year = 2008|edition = 6th|chapter = Fermat&#039;s Theorem and its Consequences|title = An Introduction to the Theory of Numbers|isbn = 978-0-19-921986-5|title-link = An Introduction to the Theory of Numbers}}&amp;lt;/ref&amp;gt; discovered by [[James Ivory (mathematician)|James Ivory]]&amp;lt;ref&amp;gt;{{Citation|last = Ivory|first = James|author-link = James Ivory (mathematician)|journal = The Mathematical Repository |series=New Series|year = 1806|volume = 1|issue = II|pages = 6–8|title = Demonstration of a theorem respecting prime numbers}}&amp;lt;/ref&amp;gt; and rediscovered by [[Peter Gustav Lejeune Dirichlet|Dirichlet]],&amp;lt;ref&amp;gt;{{Citation|last = Lejeune Dirichlet|first = Peter Gustav|author-link = Peter Gustav Lejeune Dirichlet|journal = [[Crelle&#039;s Journal|Journal für die reine und angewandte Mathematik]]|year = 1828|volume = 3|pages = 390–393|title = Démonstrations nouvelles de quelques théorèmes relatifs aux nombres|language = fr}}&amp;lt;/ref&amp;gt; requires some background in [[modular arithmetic]].&lt;br /&gt;
&lt;br /&gt;
Let us assume that {{math|&#039;&#039;a&#039;&#039;}} is positive and not divisible by {{math|&#039;&#039;p&#039;&#039;}}.&lt;br /&gt;
&lt;br /&gt;
The idea is that if we write down the sequence of numbers&lt;br /&gt;
{{NumBlk|:|&amp;lt;math&amp;gt;a, 2a, 3a, \ldots, (p-1)a&amp;lt;/math&amp;gt;|{{EquationRef|A}}}}&lt;br /&gt;
and reduce each one modulo {{math|&#039;&#039;p&#039;&#039;}}, the resulting sequence turns out to be a rearrangement of&lt;br /&gt;
{{NumBlk|:|&amp;lt;math&amp;gt;1, 2, 3, \ldots, p-1.&amp;lt;/math&amp;gt;|{{EquationRef|B}}}}&lt;br /&gt;
Therefore, if we multiply together the numbers in each sequence, the results must be identical modulo {{math|&#039;&#039;p&#039;&#039;}}:&lt;br /&gt;
:&amp;lt;math&amp;gt;a \times 2a \times 3a \times \cdots \times (p-1)a \equiv 1 \times 2 \times 3 \times \cdots \times (p-1) \pmod p.&amp;lt;/math&amp;gt;&lt;br /&gt;
Collecting together the {{math|&#039;&#039;a&#039;&#039;}} terms yields&lt;br /&gt;
:&amp;lt;math&amp;gt;a^{p-1} (p-1)! \equiv (p-1)! \pmod p.&amp;lt;/math&amp;gt;&lt;br /&gt;
Finally, we may “cancel out” the numbers {{math|1, 2, ..., &#039;&#039;p&#039;&#039; − 1}} from both sides of this equation, obtaining&lt;br /&gt;
:&amp;lt;math&amp;gt;a^{p-1} \equiv 1 \pmod p.&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
There are two steps in the above proof that we need to justify:&lt;br /&gt;
* Why the elements of the sequence ({{EquationNote|A}}), reduced modulo {{mvar|p}}, are a rearrangement of ({{EquationNote|B}}), and&lt;br /&gt;
* Why it is valid to “cancel” in the setting of modular arithmetic.&lt;br /&gt;
We will prove these things below; let us first see an example of this proof in action.&lt;br /&gt;
&lt;br /&gt;
===An example===&lt;br /&gt;
&lt;br /&gt;
If {{math|&#039;&#039;a&#039;&#039;&amp;amp;nbsp;{{=}}&amp;amp;nbsp;3}} and {{math|&#039;&#039;p&#039;&#039;&amp;amp;nbsp;{{=}}&amp;amp;nbsp;7}}, then the sequence in question is&lt;br /&gt;
:&amp;lt;math&amp;gt;3, 6, 9, 12, 15, 18;&amp;lt;/math&amp;gt;&lt;br /&gt;
reducing modulo&amp;amp;nbsp;7 gives&lt;br /&gt;
:&amp;lt;math&amp;gt;3, 6, 2, 5, 1, 4,&amp;lt;/math&amp;gt;&lt;br /&gt;
which is just a rearrangement of&lt;br /&gt;
:&amp;lt;math&amp;gt;1, 2, 3, 4, 5, 6.&amp;lt;/math&amp;gt;&lt;br /&gt;
Multiplying them together gives&lt;br /&gt;
:&amp;lt;math&amp;gt;3 \times 6 \times 9 \times 12 \times 15 \times 18 \equiv 3 \times 6 \times 2 \times 5 \times 1 \times 4 \equiv 1 \times 2 \times 3 \times 4 \times 5 \times 6 \pmod 7;&amp;lt;/math&amp;gt;&lt;br /&gt;
that is,&lt;br /&gt;
:&amp;lt;math&amp;gt;3^6 (1 \times 2 \times 3 \times 4 \times 5 \times 6) \equiv (1 \times 2 \times 3 \times 4 \times 5 \times 6) \pmod 7.&amp;lt;/math&amp;gt;&lt;br /&gt;
Canceling out 1&amp;amp;nbsp;×&amp;amp;nbsp;2&amp;amp;nbsp;×&amp;amp;nbsp;3&amp;amp;nbsp;×&amp;amp;nbsp;4&amp;amp;nbsp;×&amp;amp;nbsp;5&amp;amp;nbsp;×&amp;amp;nbsp;6 yields&lt;br /&gt;
:&amp;lt;math&amp;gt;3^6 \equiv 1 \pmod 7, &amp;lt;/math&amp;gt;&lt;br /&gt;
which is Fermat&#039;s little theorem for the case {{math|&#039;&#039;a&#039;&#039;&amp;amp;nbsp;{{=}}&amp;amp;nbsp;3}} and&amp;amp;nbsp;{{math|&#039;&#039;p&#039;&#039;&amp;amp;nbsp;{{=}}&amp;amp;nbsp;7}}.&lt;br /&gt;
&lt;br /&gt;
===The cancellation law===&lt;br /&gt;
&lt;br /&gt;
Let us first explain why it is valid, in certain situations, to “cancel”. The exact statement is as follows. If {{math|&#039;&#039;u&#039;&#039;}}, {{math|&#039;&#039;x&#039;&#039;}}, and&amp;amp;nbsp;{{math|&#039;&#039;y&#039;&#039;}} are integers, and {{math|&#039;&#039;u&#039;&#039;}} is not divisible by a prime number {{math|&#039;&#039;p&#039;&#039;}}, and if&lt;br /&gt;
{{NumBlk|:|&amp;lt;math&amp;gt;ux \equiv uy \pmod p,&amp;lt;/math&amp;gt;|{{EquationRef|C}}}}&lt;br /&gt;
then we may “cancel” {{math|&#039;&#039;u&#039;&#039;}} to obtain&lt;br /&gt;
{{NumBlk|:|&amp;lt;math&amp;gt;x \equiv y \pmod p.&amp;lt;/math&amp;gt;|{{EquationRef|D}}}}&lt;br /&gt;
Our use of this &#039;&#039;&#039;cancellation law&#039;&#039;&#039; in the above proof of Fermat&#039;s little theorem was valid because the numbers {{math|1, 2, ..., &#039;&#039;p&#039;&#039;&amp;amp;nbsp;−&amp;amp;nbsp;1}} are certainly not divisible by {{math|&#039;&#039;p&#039;&#039;}} (indeed they are &#039;&#039;smaller&#039;&#039; than {{math|&#039;&#039;p&#039;&#039;}}).&lt;br /&gt;
&lt;br /&gt;
We can prove the cancellation law easily using [[Euclid&#039;s lemma]], which generally states that if a prime {{math|&#039;&#039;p&#039;&#039;}} divides a product {{math|&#039;&#039;ab&#039;&#039;}} (where {{math|&#039;&#039;a&#039;&#039;}} and {{math|&#039;&#039;b&#039;&#039;}} are integers), then {{math|&#039;&#039;p&#039;&#039;}} must divide {{math|&#039;&#039;a&#039;&#039;}} or {{math|&#039;&#039;b&#039;&#039;}}. Indeed, the assertion ({{EquationNote|C}}) simply means that {{math|&#039;&#039;p&#039;&#039;}} divides {{math|&#039;&#039;ux&#039;&#039; − &#039;&#039;uy&#039;&#039; {{=}} &#039;&#039;u&#039;&#039;(&#039;&#039;x&#039;&#039; − &#039;&#039;y&#039;&#039;)}}. Since {{math|&#039;&#039;p&#039;&#039;}} is a prime which does not divide {{math|&#039;&#039;u&#039;&#039;}}, Euclid&#039;s lemma tells us that it must divide {{math|&#039;&#039;x&#039;&#039;&amp;amp;nbsp;−&amp;amp;nbsp;&#039;&#039;y&#039;&#039;}} instead; that is, ({{EquationNote|D}}) holds.&lt;br /&gt;
&lt;br /&gt;
Note that the conditions under which the cancellation law holds are quite strict, and this explains why Fermat&#039;s little theorem demands that {{mvar|p}} is a prime. For example, {{math|2×2 ≡ 2×5 (mod 6)}}, but it is not true that {{math|2 ≡ 5 (mod 6)}}. However, the following generalization of the cancellation law holds: if {{mvar|u}}, {{mvar|x}}, {{mvar|y}}, and {{mvar|z}} are integers, if {{mvar|u}} and {{mvar|z}} are [[Coprime integers|relatively prime]], and if&lt;br /&gt;
:&amp;lt;math&amp;gt;ux \equiv uy \pmod z,&amp;lt;/math&amp;gt;&lt;br /&gt;
then we may “cancel” {{mvar|&#039;&#039;u&#039;&#039;}} to obtain&lt;br /&gt;
:&amp;lt;math&amp;gt;x \equiv y \pmod z.&amp;lt;/math&amp;gt;&lt;br /&gt;
This follows from a [[Euclid&#039;s lemma#Proof|generalization of Euclid&#039;s lemma]].&lt;br /&gt;
&lt;br /&gt;
===The rearrangement property===&lt;br /&gt;
&lt;br /&gt;
Finally, we must explain why the sequence&lt;br /&gt;
:&amp;lt;math&amp;gt;a, 2a, 3a, \ldots, (p-1)a, &amp;lt;/math&amp;gt;&lt;br /&gt;
when reduced modulo &#039;&#039;p&#039;&#039;, becomes a rearrangement of the sequence&lt;br /&gt;
:&amp;lt;math&amp;gt;1, 2, 3, \ldots, p-1.&amp;lt;/math&amp;gt;&lt;br /&gt;
To start with, none of the terms {{math|&#039;&#039;a&#039;&#039;}}, {{math|2&#039;&#039;a&#039;&#039;}}, ..., {{math|(&#039;&#039;p&#039;&#039;&amp;amp;nbsp;−&amp;amp;nbsp;1)&#039;&#039;a&#039;&#039;}} can be congruent to zero modulo {{math|&#039;&#039;p&#039;&#039;}}, since if {{math|&#039;&#039;k&#039;&#039;}} is one of the numbers {{math|1,&amp;amp;nbsp;2,&amp;amp;nbsp;...,&amp;amp;nbsp;&#039;&#039;p&#039;&#039;&amp;amp;nbsp;−&amp;amp;nbsp;1}}, then {{math|&#039;&#039;k&#039;&#039;}} is relatively prime with {{math|&#039;&#039;p&#039;&#039;}}, and so is {{math|&#039;&#039;a&#039;&#039;}}, so [[Euclid&#039;s lemma]] tells us that {{math|&#039;&#039;ka&#039;&#039;}} shares no factor with {{math|&#039;&#039;p&#039;&#039;}}. Therefore, at least we know that the numbers {{math|&#039;&#039;a&#039;&#039;}}, {{math|2&#039;&#039;a&#039;&#039;}}, ..., {{math|(&#039;&#039;p&#039;&#039;&amp;amp;nbsp;−&amp;amp;nbsp;1)&#039;&#039;a&#039;&#039;}}, when reduced modulo {{math|&#039;&#039;p&#039;&#039;}}, must be found among the numbers {{math|1,&amp;amp;nbsp;2,&amp;amp;nbsp;3,&amp;amp;nbsp;...,&amp;amp;nbsp;&#039;&#039;p&#039;&#039;&amp;amp;nbsp;−&amp;amp;nbsp;1}}.&lt;br /&gt;
&lt;br /&gt;
Furthermore, the numbers {{math|&#039;&#039;a&#039;&#039;}}, {{math|2&#039;&#039;a&#039;&#039;}}, ..., {{math|(&#039;&#039;p&#039;&#039;&amp;amp;nbsp;−&amp;amp;nbsp;1)&#039;&#039;a&#039;&#039;}} must all be &#039;&#039;distinct&#039;&#039; after reducing them modulo {{math|&#039;&#039;p&#039;&#039;}}, because if&lt;br /&gt;
:&amp;lt;math&amp;gt;ka \equiv ma \pmod p, &amp;lt;/math&amp;gt;&lt;br /&gt;
where {{math|&#039;&#039;k&#039;&#039;}} and {{math|&#039;&#039;m&#039;&#039;}} are one of {{math|1,&amp;amp;nbsp;2,&amp;amp;nbsp;...,&amp;amp;nbsp;&#039;&#039;p&#039;&#039;&amp;amp;nbsp;−&amp;amp;nbsp;1}}, then the cancellation law tells us that&lt;br /&gt;
:&amp;lt;math&amp;gt;k \equiv m \pmod p. &amp;lt;/math&amp;gt;&lt;br /&gt;
Since both {{math|&#039;&#039;k&#039;&#039;}} and {{math|&#039;&#039;m&#039;&#039;}} are between {{math|1}} and {{math|&#039;&#039;p&#039;&#039;&amp;amp;nbsp;−&amp;amp;nbsp;1}}, they must be equal. Therefore, the terms {{math|&#039;&#039;a&#039;&#039;}}, {{math|2&#039;&#039;a&#039;&#039;}}, ..., {{math|(&#039;&#039;p&#039;&#039;&amp;amp;nbsp;−&amp;amp;nbsp;1)&#039;&#039;a&#039;&#039;}} when reduced modulo {{math|&#039;&#039;p&#039;&#039;}} must be distinct. &lt;br /&gt;
To summarise: when we reduce the {{math|&#039;&#039;p&#039;&#039;&amp;amp;nbsp;−&amp;amp;nbsp;1}} numbers {{math|&#039;&#039;a&#039;&#039;}}, {{math|2&#039;&#039;a&#039;&#039;}}, ..., {{math|(&#039;&#039;p&#039;&#039;&amp;amp;nbsp;−&amp;amp;nbsp;1)&#039;&#039;a&#039;&#039;}} modulo {{math|&#039;&#039;p&#039;&#039;}}, we obtain distinct members of the sequence {{math|1}},&amp;amp;nbsp;{{math|2}},&amp;amp;nbsp;...,&amp;amp;nbsp;{{math|&#039;&#039;p&#039;&#039;&amp;amp;nbsp;−&amp;amp;nbsp;1}}. Since there are exactly {{math|&#039;&#039;p&#039;&#039;&amp;amp;nbsp;−&amp;amp;nbsp;1}} of these, the only possibility is that the former are a rearrangement of the latter.&lt;br /&gt;
&lt;br /&gt;
===Applications to Euler&#039;s theorem===&lt;br /&gt;
&lt;br /&gt;
This method can also be used to prove [[Euler&#039;s theorem]], with a slight alteration in that the numbers from {{math|1}} to {{math|&#039;&#039;p&#039;&#039; − 1}} are substituted by the numbers less than and coprime with some number {{mvar|m}} (not necessarily prime). Both the rearrangement property and the cancellation law (under the generalized form mentioned [[#The cancellation law|above]]) are still satisfied and can be utilized.&lt;br /&gt;
&lt;br /&gt;
For example, if {{math|&#039;&#039;m&#039;&#039; {{=}} 10}}, then the numbers less than&amp;amp;nbsp;{{math|&#039;&#039;m&#039;&#039;}} and coprime with {{math|&#039;&#039;m&#039;&#039;}} are {{math|1}}, {{math|3}}, {{math|7}}, and {{math|9}}. Thus we have:&lt;br /&gt;
:&amp;lt;math&amp;gt;a \times 3a \times 7a \times 9a \equiv 1 \times 3 \times 7 \times 9 \pmod {10}. &amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Therefore,&lt;br /&gt;
:&amp;lt;math&amp;gt;{a^{\varphi(10)}} \equiv 1 \pmod {10}. &amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Proof as a corollary of Euler&#039;s criterion==&lt;br /&gt;
&lt;br /&gt;
{{main|Euler&#039;s criterion#Alternative proof}}&lt;br /&gt;
&lt;br /&gt;
==Proofs using group theory==&lt;br /&gt;
&lt;br /&gt;
===Standard proof===&lt;br /&gt;
This proof&amp;lt;ref&amp;gt;{{Citation|last = Weil|first = André|author-link = André Weil|last2 = Rosenlicht|first2 = Maxwell|author-link2 = Maxwell Rosenlicht|title = Number Theory for beginners|year = 1979|publisher = [[Springer Science+Business Media|Springer-Verlag]]|isbn = 978-0-387-90381-1|doi = 10.1007/978-1-4612-9957-8|section = §&amp;amp;nbsp;VIII|zbl = 0405.10001|url-access = registration|url = https://archive.org/details/numbertheoryforb0000weil}}&amp;lt;/ref&amp;gt; requires the most basic elements of [[group theory]].&lt;br /&gt;
&lt;br /&gt;
The idea is to recognise that the set {{math|&#039;&#039;G&#039;&#039;&amp;amp;nbsp;{{=}}&amp;amp;nbsp;{1, 2, ..., &#039;&#039;p&#039;&#039; − 1}}}, with the operation of multiplication (taken modulo {{math|&#039;&#039;p&#039;&#039;}}), forms a [[group (mathematics)|group]]. The only group axiom that requires some effort to verify is that each element of {{math|&#039;&#039;G&#039;&#039;}} is invertible. Taking this on faith for the moment, let us assume that {{math|&#039;&#039;a&#039;&#039;}} is in the range {{math|1 ≤ &#039;&#039;a&#039;&#039; ≤ &#039;&#039;p&#039;&#039; − 1}}, that is, {{math|&#039;&#039;a&#039;&#039;}} is an element of {{math|&#039;&#039;G&#039;&#039;}}. Let {{math|&#039;&#039;k&#039;&#039;}} be the [[order (group theory)|order]] of {{math|&#039;&#039;a&#039;&#039;}}, that is, {{math|&#039;&#039;k&#039;&#039;}} is the smallest positive integer such that {{math|&#039;&#039;a&amp;lt;sup&amp;gt;k&amp;lt;/sup&amp;gt;&#039;&#039;&amp;amp;nbsp;≡&amp;amp;nbsp;1&amp;amp;nbsp;(mod&amp;amp;nbsp;&#039;&#039;p&#039;&#039;)}}. Then the numbers {{math|1, &#039;&#039;a&#039;&#039;, &#039;&#039;a&#039;&#039;&amp;lt;sup&amp;gt;2&amp;lt;/sup&amp;gt;, ..., &#039;&#039;a&#039;&#039;&amp;lt;sup&amp;gt;&#039;&#039;k&#039;&#039;&amp;amp;nbsp;−1&amp;lt;/sup&amp;gt;}} reduced modulo&amp;amp;nbsp;{{math|&#039;&#039;p&#039;&#039;}} form a [[subgroup]] of&amp;amp;nbsp;{{math|&#039;&#039;G&#039;&#039;}} whose [[Order (group theory)|order]] is&amp;amp;nbsp;{{math|&#039;&#039;k&#039;&#039;}} and therefore, by [[Lagrange&#039;s theorem (group theory)|Lagrange&#039;s theorem]], {{math|&#039;&#039;k&#039;&#039;}} divides the order of {{math|&#039;&#039;G&#039;&#039;}}, which is {{math|&#039;&#039;p&#039;&#039;&amp;amp;nbsp;−&amp;amp;nbsp;1}}. So {{math|&#039;&#039;p&#039;&#039;&amp;amp;nbsp;−&amp;amp;nbsp;1&amp;amp;nbsp;{{=}}&amp;amp;nbsp;&#039;&#039;km&#039;&#039;}} for some positive integer {{math|&#039;&#039;m&#039;&#039;}} and then&lt;br /&gt;
:&amp;lt;math&amp;gt;a^{p-1} \equiv a^{km} \equiv (a^k)^m \equiv 1^m \equiv 1 \pmod p. &amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To prove that every element {{math|&#039;&#039;b&#039;&#039;}} of {{math|&#039;&#039;G&#039;&#039;}} is invertible, we may proceed as follows. First, {{math|&#039;&#039;b&#039;&#039;}} is [[Coprime integers|coprime]] to {{math|&#039;&#039;p&#039;&#039;}}. Thus [[Bézout&#039;s identity]] assures us that there are integers {{math|&#039;&#039;x&#039;&#039;}} and {{math|&#039;&#039;y&#039;&#039;}} such that {{math|&#039;&#039;bx&#039;&#039;&amp;amp;nbsp;+&amp;amp;nbsp;&#039;&#039;py&#039;&#039;&amp;amp;nbsp;{{=}}&amp;amp;nbsp;1}}. Reading this equality modulo {{math|&#039;&#039;p&#039;&#039;}}, we see that {{math|&#039;&#039;x&#039;&#039;}} is an inverse for {{math|&#039;&#039;b&#039;&#039;}}, since {{math|&#039;&#039;bx&#039;&#039;&amp;amp;nbsp;≡&amp;amp;nbsp;1&amp;amp;nbsp;(mod&amp;amp;nbsp;&#039;&#039;p&#039;&#039;)}}. Therefore, every element of {{math|&#039;&#039;G&#039;&#039;}} is invertible. So, as remarked earlier, {{math|&#039;&#039;G&#039;&#039;}} is a group.&lt;br /&gt;
&lt;br /&gt;
For example, when {{math|&#039;&#039;p&#039;&#039; {{=}} 11}}, the inverses of each element are given as follows:&lt;br /&gt;
:{| border=&amp;quot;1&amp;quot; cellspacing=&amp;quot;0&amp;quot; cellpadding=&amp;quot;8&amp;quot;&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | {{math|&#039;&#039;a&#039;&#039;}}&lt;br /&gt;
| 1 || 2 || 3 || 4 || 5 || 6 || 7 || 8 || 9 || 10&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | {{math|&#039;&#039;a&#039;&#039;&amp;lt;sup&amp;gt; −1&amp;lt;/sup&amp;gt;}}&lt;br /&gt;
| 1 || 6 || 4 || 3 || 9 || 2 || 8 || 7 || 5 || 10&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Euler&#039;s proof===&lt;br /&gt;
If we take the previous proof and, instead of using Lagrange&#039;s theorem, we try to prove it in this specific situation, then we get Euler&#039;s third proof, which is the one that he found more natural.&amp;lt;ref&amp;gt;{{Citation|last = Weil|first = André|author-link = André Weil|title = Number theory: An approach through history; from Hammurapi to Legendre|publisher = [[Birkhäuser]]|year = 2007|isbn = 978-0-8176-4565-6|section = §&amp;amp;nbsp;III.VI|zbl = 1149.01013|orig-year = 1984}}&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;{{Citation|last = Euler|first = Leonhard|author-link = Leonhard Euler|title = Theoremata circa residua ex divisione potestatum relicta|language = la|url = http://math.dartmouth.edu/~euler/docs/originals/E262.pdf|journal = Novi Commentarii Academiae Scientiarum Petropolitanae|volume = 7|year = 1761|pages = 49–82}}&amp;lt;/ref&amp;gt; Let {{math|&#039;&#039;A&#039;&#039;}} be the set whose elements are the numbers {{math|1, &#039;&#039;a&#039;&#039;, &#039;&#039;a&#039;&#039;&amp;lt;sup&amp;gt;2&amp;lt;/sup&amp;gt;, ..., &#039;&#039;a&#039;&#039;&amp;lt;sup&amp;gt;&#039;&#039;k&#039;&#039;&amp;amp;nbsp;−&amp;amp;nbsp;1&amp;lt;/sup&amp;gt;}} reduced modulo&amp;amp;nbsp;{{math|&#039;&#039;p&#039;&#039;}}. If {{math|&#039;&#039;A&#039;&#039;&amp;amp;nbsp;{{=}}&amp;amp;nbsp;&#039;&#039;G&#039;&#039;}}, then {{math|&#039;&#039;k&#039;&#039;&amp;amp;nbsp;{{=}}&amp;amp;nbsp;&#039;&#039;p&#039;&#039;&amp;amp;nbsp;−&amp;amp;nbsp;1}} and therefore {{math|&#039;&#039;k&#039;&#039;}} divides {{math|&#039;&#039;p&#039;&#039;&amp;amp;nbsp;−1}}. Otherwise, there is some {{math|&#039;&#039;b&#039;&#039;&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;&amp;amp;nbsp;∈&amp;amp;nbsp;&#039;&#039;G&#039;&#039;\&#039;&#039;A&#039;&#039;}}.&lt;br /&gt;
&lt;br /&gt;
Let {{math|&#039;&#039;A&#039;&#039;&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;}} be the set whose elements are the numbers {{math|&#039;&#039;b&#039;&#039;&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;, &#039;&#039;ab&#039;&#039;&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;, &#039;&#039;a&#039;&#039;&amp;lt;sup&amp;gt;2&amp;lt;/sup&amp;gt;&#039;&#039;b&#039;&#039;&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;, ..., &#039;&#039;a&#039;&#039;&amp;lt;sup&amp;gt;&#039;&#039;k&#039;&#039; − 1&amp;lt;/sup&amp;gt;&#039;&#039;b&#039;&#039;&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;}} reduced modulo&amp;amp;nbsp;{{math|&#039;&#039;p&#039;&#039;}}. Then {{math|&#039;&#039;A&#039;&#039;&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;}} has {{math|&#039;&#039;k&#039;&#039;}} distinct elements because otherwise there would be two distinct numbers {{math|&#039;&#039;m&#039;&#039;, &#039;&#039;n&#039;&#039;&amp;amp;nbsp;∈&amp;amp;nbsp;{0, 1, ..., &#039;&#039;k&#039;&#039; − 1}}} such that {{math|&#039;&#039;a&amp;lt;sup&amp;gt;m&amp;lt;/sup&amp;gt;b&#039;&#039;&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt; ≡ &#039;&#039;a&amp;lt;sup&amp;gt;n&amp;lt;/sup&amp;gt;b&#039;&#039;&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt; (mod &#039;&#039;p&#039;&#039;)}}, which is impossible, since it would follow that {{math|&#039;&#039;a&amp;lt;sup&amp;gt;m&amp;lt;/sup&amp;gt;&#039;&#039; ≡ &#039;&#039;a&amp;lt;sup&amp;gt;n&amp;lt;/sup&amp;gt;&#039;&#039; (mod &#039;&#039;p&#039;&#039;)}}. On the other hand, no element of {{math|&#039;&#039;A&#039;&#039;&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;}} can be an element of {{math|&#039;&#039;A&#039;&#039;}}, because otherwise there would be numbers {{math|&#039;&#039;m&#039;&#039;, &#039;&#039;n&#039;&#039;&amp;amp;nbsp;∈&amp;amp;nbsp;{0, 1, ..., &#039;&#039;k&#039;&#039;&amp;amp;nbsp;−&amp;amp;nbsp;1}}} such that {{math|&#039;&#039;a&amp;lt;sup&amp;gt;m&amp;lt;/sup&amp;gt;b&#039;&#039;&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt; ≡ &#039;&#039;a&amp;lt;sup&amp;gt;n&amp;lt;/sup&amp;gt;&#039;&#039; (mod &#039;&#039;p&#039;&#039;)}}, and then {{math|&#039;&#039;b&#039;&#039;&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt; ≡ &#039;&#039;a&amp;lt;sup&amp;gt;n&amp;lt;/sup&amp;gt;a&#039;&#039;&amp;lt;sup&amp;gt;&#039;&#039;k&#039;&#039; − &#039;&#039;m&#039;&#039;&amp;lt;/sup&amp;gt; ≡ &#039;&#039;a&#039;&#039;&amp;lt;sup&amp;gt;&#039;&#039;n&#039;&#039; + &#039;&#039;k&#039;&#039; − &#039;&#039;m&#039;&#039;&amp;lt;/sup&amp;gt; (mod &#039;&#039;p&#039;&#039;)}}, which is impossible, since {{math|&#039;&#039;b&#039;&#039;&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt; ∉ &#039;&#039;A&#039;&#039;}}.&lt;br /&gt;
&lt;br /&gt;
So, the set {{math|&#039;&#039;A&#039;&#039;∪&#039;&#039;A&#039;&#039;&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;}} has {{math|2&#039;&#039;k&#039;&#039;}} elements. If it turns out to be equal to&amp;amp;nbsp;&#039;&#039;G&#039;&#039;, then {{math|2&#039;&#039;k&#039;&#039;&amp;amp;nbsp;{{=}}&amp;amp;nbsp;&#039;&#039;p&#039;&#039;&amp;amp;nbsp;−1}} and therefore {{math|&#039;&#039;k&#039;&#039;}} divides {{math|&#039;&#039;p&#039;&#039;&amp;amp;nbsp;−1}}. Otherwise, there is some {{math|&#039;&#039;b&#039;&#039;&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;&amp;amp;nbsp;∈&amp;amp;nbsp;&#039;&#039;G&#039;&#039;\(&#039;&#039;A&#039;&#039;∪&#039;&#039;A&#039;&#039;&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;)}} and we can start all over again, defining {{math|&#039;&#039;A&#039;&#039;&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;}} as the set whose elements are the numbers {{math|&#039;&#039;b&#039;&#039;&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;, &#039;&#039;ab&#039;&#039;&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;, &#039;&#039;a&#039;&#039;&amp;lt;sup&amp;gt;2&amp;lt;/sup&amp;gt;&#039;&#039;b&#039;&#039;&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;, ..., &#039;&#039;a&#039;&#039;&amp;lt;sup&amp;gt;&#039;&#039;k&#039;&#039;&amp;amp;nbsp;−&amp;amp;nbsp;1&amp;lt;/sup&amp;gt;&#039;&#039;b&#039;&#039;&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;}} reduced modulo&amp;amp;nbsp;{{math|&#039;&#039;p&#039;&#039;}}. Since {{math|&#039;&#039;G&#039;&#039;}} is finite, this process must stop at some point and this proves that {{math|&#039;&#039;k&#039;&#039;}} divides {{math|&#039;&#039;p&#039;&#039;&amp;amp;nbsp;−&amp;amp;nbsp;1}}.&lt;br /&gt;
&lt;br /&gt;
For instance, if {{math|&#039;&#039;a&#039;&#039; {{=}} 5}} and {{math|&#039;&#039;p&#039;&#039; {{=}} 13}}, then, since&lt;br /&gt;
* {{math|5&amp;lt;sup&amp;gt;2&amp;lt;/sup&amp;gt;&amp;amp;nbsp;{{=}}&amp;amp;nbsp;25&amp;amp;nbsp;≡&amp;amp;nbsp;12&amp;amp;nbsp;(mod&amp;amp;nbsp;13)}},&lt;br /&gt;
* {{math|5&amp;lt;sup&amp;gt;3&amp;lt;/sup&amp;gt;&amp;amp;nbsp;{{=}}&amp;amp;nbsp;125&amp;amp;nbsp;≡&amp;amp;nbsp;8&amp;amp;nbsp;(mod&amp;amp;nbsp;13)}},&lt;br /&gt;
* {{math|5&amp;lt;sup&amp;gt;4&amp;lt;/sup&amp;gt;&amp;amp;nbsp;{{=}}&amp;amp;nbsp;625&amp;amp;nbsp;≡&amp;amp;nbsp;1&amp;amp;nbsp;(mod&amp;amp;nbsp;13)}},&lt;br /&gt;
we have {{math|&#039;&#039;k&#039;&#039;&amp;amp;nbsp;{{=}}&amp;amp;nbsp;4}} and {{math|&#039;&#039;A&#039;&#039;&amp;amp;nbsp;{{=}}&amp;amp;nbsp;{1,&amp;amp;nbsp;5,&amp;amp;nbsp;8,&amp;amp;nbsp;12}}}. Clearly, {{math|&#039;&#039;A&#039;&#039;&amp;amp;nbsp;≠&amp;amp;nbsp;&#039;&#039;G&#039;&#039;&amp;amp;nbsp;{{=}}&amp;amp;nbsp;{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}}}. Let {{math|&#039;&#039;b&#039;&#039;&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;}} be an element of {{math|&#039;&#039;G&#039;&#039;\&#039;&#039;A&#039;&#039;}}; for instance, take {{math|&#039;&#039;b&#039;&#039;&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;&amp;amp;nbsp;{{=}}&amp;amp;nbsp;2}}. Then, since&lt;br /&gt;
* {{math|2×1&amp;amp;nbsp;{{=}}&amp;amp;nbsp;2}},&lt;br /&gt;
* {{math|2×5&amp;amp;nbsp;{{=}}&amp;amp;nbsp;10}},&lt;br /&gt;
* {{math|2×8&amp;amp;nbsp;{{=}}&amp;amp;nbsp;16&amp;amp;nbsp;≡&amp;amp;nbsp;3&amp;amp;nbsp;(mod&amp;amp;nbsp;13)}},&lt;br /&gt;
* {{math|2×12&amp;amp;nbsp;{{=}}&amp;amp;nbsp;24&amp;amp;nbsp;≡&amp;amp;nbsp;11&amp;amp;nbsp;(mod&amp;amp;nbsp;13)}},&lt;br /&gt;
we have {{math|&#039;&#039;A&#039;&#039;&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;&amp;amp;nbsp;{{=}}&amp;amp;nbsp;{2,&amp;amp;nbsp;3,&amp;amp;nbsp;10,&amp;amp;nbsp;11}}}. Clearly, {{math|&#039;&#039;A&#039;&#039;∪&#039;&#039;A&#039;&#039;&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt; ≠ &#039;&#039;G&#039;&#039;}}. Let {{math|&#039;&#039;b&#039;&#039;&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;}} be an element of {{math|&#039;&#039;G&#039;&#039;\(&#039;&#039;A&#039;&#039;∪&#039;&#039;A&#039;&#039;&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;)}}; for instance, take {{math|&#039;&#039;b&#039;&#039;&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt; {{=}}&amp;amp;nbsp;4}}. Then, since&lt;br /&gt;
* {{math|4×1&amp;amp;nbsp;{{=}}&amp;amp;nbsp;4}},&lt;br /&gt;
* {{math|4×5&amp;amp;nbsp;{{=}}&amp;amp;nbsp;20&amp;amp;nbsp;≡&amp;amp;nbsp;7&amp;amp;nbsp;(mod&amp;amp;nbsp;13)}},&lt;br /&gt;
* {{math|4×8&amp;amp;nbsp;{{=}}&amp;amp;nbsp;32&amp;amp;nbsp;≡&amp;amp;nbsp;6&amp;amp;nbsp;(mod&amp;amp;nbsp;13)}},&lt;br /&gt;
* {{math|4×12&amp;amp;nbsp;{{=}}&amp;amp;nbsp;48&amp;amp;nbsp;≡&amp;amp;nbsp;9&amp;amp;nbsp;(mod&amp;amp;nbsp;13)}},&lt;br /&gt;
we have {{math|&#039;&#039;A&#039;&#039;&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;&amp;amp;nbsp;{{=}}&amp;amp;nbsp;{4,&amp;amp;nbsp;6,&amp;amp;nbsp;7,&amp;amp;nbsp;9}}}. And now {{math|&#039;&#039;G&#039;&#039;&amp;amp;nbsp;{{=}}&amp;amp;nbsp;&#039;&#039;A&#039;&#039;∪&#039;&#039;A&#039;&#039;&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;∪&#039;&#039;A&#039;&#039;&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;}}.&lt;br /&gt;
&lt;br /&gt;
Note that the sets {{math|&#039;&#039;A&#039;&#039;}}, {{math|&#039;&#039;A&#039;&#039;&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;}}, and so on are in fact the [[coset]]s of {{math|&#039;&#039;A&#039;&#039;}} in {{math|&#039;&#039;G&#039;&#039;}}.&lt;br /&gt;
&lt;br /&gt;
==Notes==&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{DEFAULTSORT:Fermat&#039;s Little Theorem, Proofs Of}}&lt;br /&gt;
[[Category:Modular arithmetic]]&lt;br /&gt;
[[Category:Number theory]]&lt;br /&gt;
[[Category:Article proofs]]&lt;/div&gt;</summary>
		<author><name>23.84.110.223</name></author>
	</entry>
</feed>