In: Math
find the multiplicative inverse of 32(mod 101). answer must range from 0 to 100
Searching one by one is very tedious, instead I have used python-program to solve it, which is as follows
# Python program to find
# modular inverse using extended
# Euclid algorithm
# Returns modulo inverse of a with
# respect to m using extended Euclid
def modInverse(a, m):
m0 = m
y = 0
x = 1
if (m == 1):
return 0
while (a > 1):
# q is quotient
q = a // m
t = m
# m is remainder now,
process
# same as Euclid's
algo
m = a % m
a = t
t = y
# Update x and y
y = x - q * y
x = t
# Make x positive
if (x < 0):
x = x + m0
return x
# Driver program to test above function
a = 32
m = 101
print("Modular multiplicative inverse is",
modInverse(a, m))
The out put is as follows
Modular multiplicative inverse is 60.
Now manually we can verify 32*60(mod 101)= 1.