Inverse in ℤ/pℤ: inv inverse /

### 5.34.11 Inverse in ℤ/pℤ: inv inverse /

The inv command finds the inverse of an integer in ℤ/pℤ.
inverse is a synonym for inv.

Since ℤ/pℤ is only a field if p is prime, the inverse is only guaranteed to exist if p is prime (and the integer is non-zero).

- inv takes one argument:
  n%p, an element of ℤ/pℤ.
- inv(n%p) returns the reciprocal of n%p) in ℤ/pℤ.

#### Example

Input:

inv(3%13)

Output:

⎛ ⎝ | −4 | ⎞ ⎠ | %13

Indeed 3×−4=−12=1 (mod 13).
You can also find the reciprocal using division: Input:

1/(3%13)

Output:

⎛ ⎝ | −4 | ⎞ ⎠ | %13