How do I explain to students that $0 \bmod n$ equals $0$?

68.1k Views Asked by At

I am teaching a beginning programming class in Visual Basic (for non-CS majors). I told my students that the mod operator basically gives the remainder of the division. So, when seeing $0 \bmod 10$, some students (apparently) reasoned that, "$10$ goes into $0$ zero times and there are $10$ leftover."

What would be the best way to explain this to (non-math and non-CS major) students?

I would rather counter the "$10$ goes into $0$ zero times with $10$ leftover" reasoning than change my definition, if possible. I checked the documentation for the language, and it gave the same "remainder" definition that I gave.

6

There are 6 best solutions below

11
On BEST ANSWER

$10$ goes into $0$ zero times and there are $0$ left over.

Go back to long division the way you learned it in third or fourth grade: $$ \begin{array}{ccccccc} & & 0 \\ \\ 10 & ) & 0 \\ & & 0 \\ \hline & & 0 \end{array} $$ The remainder is $0$.

0
On

Well there is no problem $0$ is equal $0\times10+0$ what means that the rest of the Euclidean division is zero. You can do that for every positive integer.

1
On

If you want intuitive explanation say to them that leftover must not be greater that a size of cup (divisor) with which you take water from container (dividend) because if there was more water in container than size of the cup you could always take one full cup more.

I also think that showing them division algorithm equation would be also good: $$a = bq + r$$ than substitute variables $$0 = 10 q + r$$ and show them that only valid substitution for $q$ and $r$ is $0$ and $0$ because $0$ and $10$ would produce false equation $0 = 10$.

0
On

I also have a hard time putting together the question statement. But if someone were to ask me to explain $0 \mod 10 \equiv 0$ to them, I might say one of the following three things.

Everything is congruent to itself. That is, if I were to say $x \mod 10 \equiv x$, this is true for all $x$. But perhaps that's uninspired.

$10$ divides $0-0$. This is the standard (at least, the one I consider standard) definition of mod, and so $0 \equiv 0$.

By the division algorithm, we see that $0 = 0 \cdot 10 + 0$, so that (reading the two outside numbers) $0 \equiv 0$.

0
On

The remainder at the division with $k>0$ must be equal to some number between $0$ and $k-1$. The division remainder theorem should handle the rest.

0
On

If you're teaching future programmers, you will need to bring up the division theorem at some point. While Hardy's answer is surely best for the specific question you asked, your students will also need some guidance when negative numbers are involved.

For example, what do you expect from -22 Mod 3 or 7 Mod -2? The results will seem arcane at first, but are the clear consequences of the relationship to integer division, which I believe always rounds towards 0 in Visual Basic.

Other languages may handle the rounding differently, but the equation a = b * (a div b) + (a mod b) seems to be universal.