-1
def mod_inverse_iterative(a, b):
    x, y, u, v = 0, 1, 1, 0
    while a != 0:
        q  = b / a
        r=b % a
        m = x - u * q
        n=y - v * q
        b, a, x, y, u, v = a, r, u, v, m, n
    return b, x, y

print(mod_inverse_iterative(66185,4080))

output python 2: (5, -275, 4461) output python 3: (5, -1376.9583960493067, 11238.87370164165)

Alexander L. Hayes
  • 3,892
  • 4
  • 13
  • 34
  • What have *you* done to try to solve the problem at hand? – esqew Nov 25 '20 at 14:22
  • most probably you have different division problem, check https://stackoverflow.com/questions/21316968/division-in-python-2-7-and-3-3 – drompix Nov 25 '20 at 14:23

1 Answers1

0

As someone already said in comments is due to python division. Check this link if you need more hints to port from python 2 to 3.

Also check this link from python docs.

So, just change q = b / a for q = b // a

Nestor
  • 519
  • 1
  • 7
  • 21