Modulo operator practice

Hey everyone. I already solved the Chapter 3 assignment, but I was wondering if anyone could provide advice on how to do long division for modulo operators involving negative numbers (ex. -3 mod 90, 7 mod -35). I just want to have a better understanding of the modulo operator.

1 Like

x == (x // y) * y + (x % y)

will always be true for all integer values of x and y, with the exception of y = 0.

1 Like

have you checked out some explanations about modulo on stackoverflow? i think this link explains some of the complexities of it pretty well: https://stackoverflow.com/questions/3883004/the-modulo-operation-on-negative-numbers-in-python