Actually, it depends on how integer division is rounded.
In C and Java, integer division rounds towards 0. So 17 / -3 = -5. So the
remainder is 17 - (-3 * -5) = 2.
In Python and Ruby, integer division always rounds down. So 17 / -3 = -6. So
the remainder is 17 - (-3 * -6) = -1.
Alternately, you can say that the remainder in C/Java takes the sign of the
dividend, and in Python/Ruby takes the sign of the divisor.