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

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


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


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.