This is documentation for Mathematica 8, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.2)

PowerMod

PowerMod
gives .
PowerMod
finds the modular inverse of a modulo m.
PowerMod
finds a modular r^(th) root of a.
  • Integer mathematical function, suitable for both symbolic and numerical manipulation.
  • For positive b, PowerMod gives the same result as Mod but is much more efficient.
  • PowerMod allows negative and rational values of b. It returns unevaluated if the corresponding modular inverse or root does not exist.
  • PowerMod automatically threads over lists.
In[1]:=
Click for copyable input
Out[1]=
In[2]:=
Click for copyable input
Out[2]=
Compute the multiplicative inverse of 3 modulo 7:
Check the result:
PowerMod works with numbers of any size, and does not need to compute the explicit power:
PowerMod automatically threads itself over lists:
Compute the modular square root of 6 modulo 10:
Build an RSA-like toy encryption scheme. Start with the modulus:
Find the universal exponent of the multiplication group modulo n:
Private key:
Public key:
Encrypt a message:
Decrypt it:
Modular square roots may not exist:
New in 1