1 | initial version |

There are various ways to compute the inverse of a number modulo some other number.

They include

- using the function
`inverse_mod`

. - working in the ring of integers modulo
`n`

.

Using `inverse_mod`

:

```
sage: n = 14
sage: a = 5
sage: b = inverse_mod(a, n)
sage: b
3
sage: a * b
15
sage: (a * b) % n
1
```

Using the ring of integers modulo `n`

:

```
sage: n = 14
sage: A = Zmod(n)
sage: a = A(5)
sage: a
5
sage: b = a^-1
sage: b
3
sage: b * a
1
```

Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.