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

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.

• The notion you have considered is fine, Modulus operator just gives you the remainder. So $0$ is the only number that fits the division giving out another $0$ after multiplication and gives $0$ finally. I think 'chessmath' even posted the same thing. – IDOK Feb 20 '12 at 17:48
• "10 goes into 0 zero times with 10 leftover" means $\:0 - 10\cdot 0 = 10$. This is the error you need to address. – Math Gems Feb 20 '12 at 18:09
• I usually think of this relation, (x + y)mod(y) = (x)mod(y) so using your example, (0 + 10)mod(10) = 0 – CleoR Nov 5 '15 at 13:28
• Using the example below from @will, I guess you could say "0 pizzas divided by 10 students results in each student getting zero pizzas allocated to them, with zero unallocated pizzas leftover." (Thus 0/10 === 0 and also 0%10 === 0) – mikermcneil Mar 19 '19 at 23:41
• I simply don't understand why your students think $10$ is left over. How could a nonzero number be left over from dividing nothing? – Allawonder Sep 2 '19 at 4:10

$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$.

• This will probably work best for my situation. Most of the students may be confused if I bring in the division theorem, although that would likely be best for math students. This idea goes back to what they know. – jtpereyda Feb 20 '12 at 18:45
• How are there 0 left over if 10 didn't go anywhere any times? – Deji Jun 30 '16 at 14:02

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$$.

• Nicely explained through the division algorithm theorem. – dacabdi Sep 2 '17 at 18:27

Well it is actually more easy to explain than most try to do. Example:

4mod2 = the 2 is inside the 4 two times and rest is 0 So if you do "if(4%2 == 0)" this would be true. in a case of "if(i%2 == 0)" this would also be true for i=0. Why is that so? Because the rest of the modulo does not depend on the denominator. if you have 0 as a numerator , the rest will never be more than the numerater itself. It doesnt matter how big your denominator grows. eg x%y => the value will never be more than x. It is simply not possible. Everytime y is bigger than x, the rest will become 0 automaticaly. 0%0+n = 0 1%1+n = 0 2%2+n = 0 x%x+n = 0

Tell me, if you have zero pizzas and you want to give 10 students pizzas, how many pizzas will be left? Excatly, zero ones. Your students reasoned 10 students wants to eat 0 zero pizzas and there are 10 pizzas left. So actually you have to show them, there are 10 students left with empty stomachs but still zero pizzas on the table. (students are always hungry, this will work)

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.

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.

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$.

This helped me, I'm a programming student.

• 0%2 = 0 (0/2 = 0 remainder 0)
• 1%2 = 1 (1/2 = 0 remainder 1)
• 2%2 = 0 (2/2 = 1 remainder 0)
• 4%2 = 0 (4/2 = 2 remainder 0)
• 5%2 = 1 (5/2 = 2 remainder 1)

You said intuition?

The modulo operation finds the remainder after division of one number by another.

A mod B

But when it comes to intuition and understanding the logic behind the scene, modulo operation is the distance from ZERO by moving to direction of A in range B.

The distance colored in orange:

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.

Think of it this way.

x mod n where n > 0 and x > 0.

For example x = 49 and n = 10. As we no there are 9 remaining.

However, how does x have anything remaining if there was nothing there to start with.
I.E x = 0.

0 mod n == 0 as there was nothing to divide into to begin with so it can't have a remainder.