One. This is a common programming trick. Often you need to know the oddness and evenness of an integer.
The remainder operator can be used with negative integers. The rule is:
For example:
17 % 3 == 2 -17 % 3 == -2 17 % -3 == 2 -17 % -3 == -2
From the two pieces (the quotient and the remainder) the original integer can be put back together:
quotient * divisor + remainder theInteger
For example,
-17 / 3 == -5 ; -17 % 3 == -2 (-5) * 3 + (-2) = -15 + (-2) = -17
You may wish to practice with the following:
Five pirates find a chest of 123 gold coins and wish to divide the 123 coins evenly amoung themselves. How many coins does each pirate get?
The parrot gets any leftover coins. How many coins does the parrot get?