Write a method remainder
which takes two integer arguments, dividend
and divisor
, and returns the remainder when dividend is divided by divisor. Do NOT use the modulus operator (%) to calculate the remainder!
Dividend will always be greater than or equal to
divisor.
Make sure the implemented remainder
function works exactly the same as the Modulus Operator (%)
. For example n % 0 = NaN
, your method should return null
.
Some Random Test Cases are waiting up ahead...
SimpleInteger
is a tiny and immutable implementation of an integer number. Its interface is a very small subset of the java.math.BigInteger
API:
#add(SimpleInteger val)
#subtract(SimpleInteger val)
#multiply(SimpleInteger val)
#divide(SimpleInteger val)
#compareTo(SimpleInteger val)