1

What would be the inverse element for this abelian group $[1,2,3,4,...,p-1]$ , in which p is a prime number, with this operation $(a*b)mod.p$? For all $a$ and $b$ of the set.

I know the inverse element has to be a multiplication of $p$ plus $1$, thus $a*b=kp+1$, with $k\in \mathbb{N}$ and $k>0$. But how can I determine it for each element?

Arthur
  • 1,557

2 Answers2

3

By Fermat's Theorem, if $a$ is one of $1,2,3,\dots, p-1$, then $a^{p-1}\equiv 1\pmod{p}$. Thus $(a)(a^{p-2})\equiv 1\pmod{p}$, and therefore $a^{p-2}\bmod p$ is the inverse of $a$.

Remark: As a method, the use of Fermat's theorem is not particularly impractical, if we use the Binary Method for modular exponentiation. A more commonly used alternative is to use the Extended Euclidean Algorithm.

André Nicolas
  • 507,029
1

Basically, you can use extended Euclidean algorithm or Euler's theorem in general.The modular inverse w.r.t a prime $p$ is $a^{p-2} \;(\text{mod} \; p)$ as $a^{p-1} \equiv 1 \; \;(\text{mod} \; p),$ by Fermat's little theorem. See this as well. There're number of implementations you can find in any language by simply googling.