Why is $a^{-1}$ mod $p$ equal to $a^{p-2}$ mod $p$? [closed]

Solution 1:

${\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 $$

This uniqueness proof holds very generally since is uses only commutativity and associativity.

Remark $\ $ 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$.