Why is $a^{-1}$ mod $p$ equal to $a^{p-2}$ mod $p$ in modular arithmetic?
-
3Because, by Fermat's little theorem, if $a\neq 0\pmod{p}$, then $a^{p-1}=1\pmod{p}$. – Jun 24 '15 at 16:01
-
How do you get from $a^{p-1} = 1$ to $a^{p-2} = a^{-1}$? Dividing both sides by $a$? – Sean Hill Jun 24 '15 at 16:07
-
$a^{-1}\pmod{p}$ is defined to be the one (if existing) and only element in $\mathbb Z/p\mathbb Z$ such that $$a^{-1}\cdot a=a\cdot a^{-1}=1\pmod{p}$$ and $a^{p-2}\pmod{p}$ satisfies this property whenever $a\neq 0\pmod{p}$. It is a general fact that uniqueness in $\mathbb Z/p\mathbb Z$ follows from existence. – Jun 24 '15 at 16:11
-
@G.Sassatelli Are you saying the inverse of each number from $1$ to $p-1$ is different, modulo $p$? – Sean Hill Jun 24 '15 at 16:28
-
$0$ does not have an inverse $\pmod{p}$. It is true that $x^{-1}=y^{-1}\pmod{p}\implies x=y\pmod{p}$, but what I said actually was that for all $a\in\mathbb Z/p\mathbb Z$ it holds $$\begin{cases}b\cdot a=a\cdot b=1\pmod{p}\c\cdot a=a\cdot c=1\pmod{p}\end{cases}\implies c=b\pmod{p}$$ – Jun 24 '15 at 16:32
-
I don't understand what that means or how it applies here. What is b and c and how is that relevant? – Sean Hill Jun 24 '15 at 16:37
2 Answers
${\rm mod}\ p\!:\ a\not\equiv 0\,\overset{\rm Fermat}\Longrightarrow\ \overbrace{a\, \color{#c00}{a^{p-2}}}^{\Large a^{p-1}}\equiv 1\ $ so $\ a^{-1}\equiv \color{#c00}{a^{p-2}}\ $ (by definition of "inverse")
Note: this implicitly uses uniqueness of inverses. Proof: $ $ if $\, c',c\,$ are both inverses of $\, a\,$ then
$$ c' \equiv c'(ac)\equiv (c'a)c\equiv c\qquad $$
Such uniqueness holds very generally since the proof uses only commutativity and associativity.
Remark $\ $ Note that the proof uses basic congruence laws, e.g. the first congruence multiplies $\,\color{#c00}{1\equiv ac}\,$ times $\,c'\equiv c\,$ to get $\,c'\cdot\color{#c00}1\equiv c'(\color{#c00}{ac})\,$ by the Congruence Product Rule.
The uniqueness of inverses (and uniqueness theorems in general) often play key roles in much less trivial ways. A nice recent example is this proof that $\,4ab-1 \mid 4a^2-1\,\Rightarrow\, a=b$.

- 272,048
-
What exactly is "unique" here? The inverse mod $p$? Are you saying the inverse of each number from $0$ to $p-1$ have unique inverses mod $p$? – Sean Hill Jun 24 '15 at 16:17
-
@user64283 Here uniqueness means $,ac\equiv 1\equiv ac',\Rightarrow, c\equiv c'\pmod p,\ $ i.e. if $,c,$ and $,c'$ are both inverses of $,a,$ then they are congruent. – Bill Dubuque Jun 24 '15 at 16:20
-
i.e. a root of the $\rm\color{#c00}{congruence},$ $,ax\equiv 1,$ is unique (up to congruence), i.e. $\color{#0a0}{\text{any two roots are }}\color{#c00}{\rm congruent}$. It proves helpful to think of congruences as generalized $\rm\color{#90f}{equalities}$, recalling for equalities that an $\rm\color{#90f}{equation}$ has unique roots means $\color{#0a0}{\text{any two roots are }}\color{#90f}{\rm equal}$ – Bill Dubuque May 31 '23 at 14:51
Because $a^{p-1} = 1$ mod p in modular arithmetic, whenever p is a prime and a ≠ 0.

- 10,113