# Modular inverse (modular_inverse)

The inverse of a whole number modulo another.

## How to write it

### modular_inverse(a, m)

**a**

The number to invert. Takes a whole number.

**m**

The modulus, coprime to a. Takes a whole number.

## Examples

- $\displaystyle 3^{-1} \bmod 7 = 5$

  `modular_inverse(3, 7)`

  In the solver, `modular_inverse(3, 7)` gives `5`.

  [Open in the solver](https://hilberon.com/?q=modular_inverse%283%2C%207%29)

## Related functions

- [moebius_mu](https://hilberon.com/library/moebius_mu)

  Moebius function: 0 if a square divides n, else 1 or -1 by the parity of its prime factors.
- [lucas_l](https://hilberon.com/library/lucas_l)

  The n-th Lucas number.
- [multinomial](https://hilberon.com/library/multinomial)

  Multinomial coefficient: the ways to split n items into groups of the given sizes.
- [jacobi_symbol](https://hilberon.com/library/jacobi_symbol)

  Jacobi symbol (a/n), for an odd positive n.
- [multiplicative_order](https://hilberon.com/library/multiplicative_order)

  The least power of a number that is 1 modulo another.
- [is_square_free](https://hilberon.com/library/is_square_free)

  Test whether no square greater than 1 divides a whole number.

---
Source: https://hilberon.com/library/modular_inverse
