WLJS LogoWLJS Notebook

ModularInverse

ModularInverse[k, n] gives the modular inverse of k modulo n.

The modular inverse of k modulo n is an integer m such that k*m ≡ 1 (mod n). It exists only when GCD[k, n] == 1.

Examples

ModularInverse[3, 7]
(* Verify: 3 * 5 = 15 ≡ 1 (mod 7) *)
Mod[3 * ModularInverse[3, 7], 7]
ModularInverse[17, 100]

*See the official Wolfram Language Reference for more details.

On this page