The inverse of 154 in mod 543 is 67, my code tell me its 58. This is my Python Code:
def inverse(modulo, number):
ri1 = number
ri2 = modulo
ti1 = 1
ti2 = 0
qi = 0
ti = 0
qi = 0
ri = 0
while ri1 != 0:
ri = ri2 % ri1
qi = (ri2 - ri) / ri1
ti = ti2 - (qi * ti-1)
ri2 = ri1
ri1 = ri
ti2 = ti1
ti1 = ti
return ti1
print(inverse(543, 154))
The following code works: