Modular multiplicative inverse (SymPy, WMA)
ModularInverse
[k, n] ModularInverse[k,n]
gives the smallest positive integer r where the remainder of the division of r x k by n is equal to 1.
ModularInverse[2, 3]
The following is be True for all values n, k which have a modular inverse:
k = 2; n = 3; Mod[ModularInverse[k, n] * k, n] == 1
Some modular inverses just do not exists. For example when k is a multiple of n:
ModularInverse[k, k]