Function invmod #
Calculate the (modular) multiplicative inverse of a modulo b. Solution to the equation ax ≣ 1 (mod b)
See https://en.wikipedia.org/wiki/Modular_multiplicative_inverse.
Syntax #
math.invmod(a, b)
Parameters #
Parameter | Type | Description |
---|---|---|
a |
number | BigNumber | An integer number |
b |
number | BigNumber | An integer number |
Returns #
Type | Description |
---|---|
number | BigNumber | Returns an integer number where invmod(a,b)*a ≣ 1 (mod b) |
Throws #
Type | Description —- | ———–
Examples #
math.invmod(8, 12) // returns NaN
math.invmod(7, 13) // returns 2
math.invmod(15151, 15122) // returns 10429