> ## Documentation Index
> Fetch the complete documentation index at: https://docs.starknet.io/llms.txt
> Use this file to discover all available pages before exploring further.

# core::math::u256_inv_mod

Returns the inverse of `a` modulo `n`, or `None` if `a` is not invertible modulo `n`.
All `a`s will be considered not invertible for `n == 1`.

## Signature

```rust theme={null}
pub fn u256_inv_mod(a: u256, n: NonZero) -> Option>
```

## Examples

```rust theme={null}
use core::math::u256_inv_mod;

let inv = u256_inv_mod(3, 17);
assert!(inv == Some(6));
```
