negative number divided by positive number, what would be remainder? [closed]
my question is
If $-27$ is divided by $5$, what would be the remainder?
Solution 1:
There are two conventions, depending on whether you allow the remainder to be negative.
Either you don't
$$-27 = -6 \times 5 + 3$$
or you do
$$-27 = -5 \times 5 + (-2)$$
Note that whatever convention you choose, the two possibilities for the remainder will always differ by $5$.
Solution 2:
Per the Euclidean Algorithm:
$$-27 = \underbrace{-6}_q\cdot \underbrace{5}_d + \underbrace{3}_r$$
where $q$ is the quotient when $-27$ (dividend) is divided by the divisor $d=5$, and $r$ is the remainder. It is standard to represent the remainder $r$ such that $0 \leq r \lt \;d.$
Solution 3:
There are various conventions for how to define the quotient and remainder for the division algorithm when extended from naturals to integers, i.e. the extension to negative integers.
The remainder is uniquely determined once one defines the quotient, and many conventions are based on a choice of which direction to round the quotient, e.g. towards $\,0\,$ or, towards the nearest integer, or towards $\,\pm\infty.$ Some programming languages provide all of the possibilities, e.g. see the floor, ceiling, round, truncate functions in Common Lisp.
A web search will turn up further discussion of such conventions in many places, e.g. on Wikipedia and D. Leijen, Division and Modulus for Computer Scientists.
Be sure to grok the difference between $\!\bmod\!$ as a (remainder) operation vs. (congruence) relation, which is discussed at length in this answer.
Solution 4:
Let $m$ be a negative integer $< 0$ and let $b$ be a positive integer $> 0$.
Proposition: There exist unique integers $q$ and $r$ satisfying the following conditions:
$q \le 0$
$0 \le -r \lt b\;$ (so $r$ is a nonpositive integer)
$m = qb + r$
The proof is left as an exercise for the interested reader.
There is nothing heretical about this. To some it might even be the more natural way to perform Euclidean Division on negative numbers. Why?
You are making great progress working with integers and are using them to measure lengths. You work with many rulers using 'tick' marks, but have to select the ruler with the required ‘Ticks per Unit Length Precision Granularity’.
You know if your unit length has 5 ticks and something is 27 ticks long, that you measure it on the ruler at (5*5 + 2) ticks, or
27 ticks / (5 ticks/Units) = $(5 + \frac{2}{5})$ Units
You naturally do the same thing when measuring to the left (negative lengths).
The next day you get a bit more abstract and define the rational numbers. It turns out that your method is actually the way to represent a rational number as a mixed number. Just for fun, check out
How to Convert a Negative Mixed Number Into an Improper Fraction : Fractions 101
Now convert $-5\frac{2}{5}$ into an improper fraction.