Function reference · Math

modinv

Computes a modular multiplicative inverse.

For supported integers a and m, modinv returns a value x such that a*x is congruent to 1 modulo m. The inverse only exists when the inputs satisfy the required coprimality conditions.

Examples

These examples use Nerdamer Notation.

Find the inverse of 3 modulo 7.

modinv(3,7)
// → 5

Find the inverse of 10 modulo 17.

modinv(10,17)
// → 12

Interfaces

The same operation is available through the interfaces below.

Nerdamer Notation

Nerdamer Notation

Use this form inside input passed to nerdamer(...).

modinv(arg1, arg2)

← Back to Reference