invmod
invmod(x,m)
Take the inverse of x
modulo m
: y
such that $xy = 1 \pmod m$.
Examples
julia> invmod(3, 7)
5
julia> invmod(6, 11)
2
The invmod
function calculates the modular multiplicative inverse of x
modulo m
. It returns y
such that x * y ≡ 1 (mod m)
. Here are a couple of examples:
-
Calculate inverse modulo 7:
julia> invmod(3, 7) 5
This example calculates the modular multiplicative inverse of
3
modulo7
, which is5
. - Calculate inverse modulo 11:
julia> invmod(6, 11) 2
Here, the inverse of
6
modulo11
is2
.
Note that the invmod
function throws an error if the modular inverse does not exist.
See Also
abs2, beta, binomial, ceil, cell, cross, ctranspose, ctranspose!, cummin, cumprod, cumprod!, cumsum, cumsum!, cumsum_kbn, div, divrem, eigfact, eigfact!, eigmin, eps, erf, erfc, erfcinv, erfcx, erfi, erfinv, exp, exp10, exp2, expm1, exponent, factor, factorial, factorize, floor, gcd, invmod, log, log10, log1p, log2, logspace, max, min, mod, mod1, modf, next, nextpow, nextprod, num, primes, primesmask, prod, realmin, sqrt, sum!, sumabs, sumabs!, sumabs2, sumabs2!,User Contributed Notes
Add a Note
The format of note supported is markdown, use triple backtick to start and end a code block.