-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)

2
  • What have you done to try to solve the problem at hand? Commented Nov 25, 2020 at 14:22
  • most probably you have different division problem, check stackoverflow.com/questions/21316968/… Commented Nov 25, 2020 at 14:23

1 Answer 1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.