0

I guess it is a elementary school question, however I could not be sure: What are the remainders when:

$-8$ is divided by $3$
$8$ is divided by $-3$

According to: $0<r<n$ where $m=qn+r$ rule first one should be 1 and the second one should be -4. However I guess second one is not true. Could you please explain it?

3 Answers3

2

It depends on how you wish to define remainder. If we only allow positive divisors, then the standard convention is for the remainder to be the unique non-negative quantity less than the divisor such that the difference between the original quantity and the remainder is an integer multiple of the divisor. (The remainder may be zero unlike in the definition you give.) This definition can be used even if we talk about real numbers. Formally we can let $x\%y = x-\lfloor \frac{x}{y} \rfloor y$.

As for negative divisors, in some programming languages $x\%(-y)$ is defined as $-(x\%y)$ for all positive $y$. I've not seen it used in mathematics.

user21820
  • 57,693
  • 9
  • 98
  • 256
1

Your statement concerning the remainder $r$ cannot be true ($r$ can equal 0 and if $n<0$ it does not make sense) You should use $$0\leq r<|n|$$ instead.

Consider then that $-8=3\times (-3)+1$ and $ 8=(-3)\times(-2)+2$.

Edit Remark that the remainders add up to the divider ($1+2=3$). Can you prove that given two positive numbers $m$ and $n$ such that $m$ is not a multiple of $n$, the remainders of the Euclidian divisions of $-m$ divided by $n$ and $m$ divided by $-n$ add up to $n$ and that the quotients differ by $1$ ?

Tom-Tom
  • 6,867
0

Generally speaking, we want the remainder to be positive, as in the case of the Division Algorithm for integers:

If $m$ is a positive integer divisor and $n$ is any integer dividend, then there exists unique integers $q$ (quotient) and $r$ (remainder) such that $$n = mq+r, \quad \text{and}\;0\leq r\lt m.$$

(Note: the Division Algorithm addresses integers divided by positive divisors.)

To see how this works, we can use the number line to approach all such remainder questions.

Let's model what we do in the positive dividend case. Say we want to calculate the remainder when $10$ is divided by $3$. $$\dfrac {10}{3} = 3\times 3 + 1$$

That is, $9$ is the greatest integer less than or equal to $10$ that is divisible by $3$. This appears on the number line one integer unit to the left of $10$. So our remainder is $10 - 9 = 1$.

In the negative dividend case, we can do likewise. $$\dfrac{-8}{3} = -3\times 3 + 1$$

$-9$ is the greatest integer less than or equal to $-8$ that is divisible by $3$. It appears one unit to the left of the dividend $-8$ on the number line. So the remainder is $-8 - (-9) = +1$.

amWhy
  • 209,954
  • 1
    I agree with the first sentence. We (as in math folks) want the remainder to be positive. However, programmers do it differently, and some languages/processors enforce a different convention. The reason is that when dividing an integer $a$ by another $b$ if $q= a, \mathrm{DIV}, b$ is the quotient, and $r= a, \mathrm{MOD}, b$ is the remainder, then naturally we want $$a=q\cdot b+r$$ to hold. But (not unnaturally, but incompatibly) they also want the rule $$(-a),\mathrm{DIV},b=-(a,\mathrm{DIV},b)$$ to hold. Houston, we have a problem! This forces $(-8),\mathrm{MOD},3=-2$ et cetera. – Jyrki Lahtonen Apr 24 '14 at 08:23