Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Why is zero mod zero undefined?

To me, the answer must be zero, because $0 \times N + M = 0$ has only one solution for $M$, zero.
(Assuming $M$ and $N$ are integers.)

However, today I found out that it is undefined. Why?

share|cite|improve this question
It's not undefined in reality... only according to certain limited conventions that are not designed to cope with it... see my fuller answer below. – paul garrett Oct 15 '13 at 0:52

In general, when taking the remainder of $a$ divided by $b$, we use the division algorithm to find nonnegative integers $q,r$ such that $$a=bq+r$$ but also that $r<b$. If we have $b=0$, then we can't find a remainder when dividing by $b$ in the conventional sense.

share|cite|improve this answer
That's all. UpVote $0$k. – Felix Marin Oct 15 '13 at 0:55
I don't understand why the failure of a particular algorithm to give the correct result implies the result should be undefined though... division is defined in terms of I multiplication, and it's just as easy to do the same for modulus no? – Mehrdad Oct 15 '13 at 20:28

As you noted it only makes any sort of sense when applied to zero. By your definition the statement $$ a \equiv b\mod 0$$

Only makes sense when $a=b=0$. For any other numbers you would need a remainder after division by $0$ which you can't do. So it seems that there is no natural way of extending the concept of a congruence to include modding by $0$.

Incidentally it is an $ideal$ since $I = \lbrace 0 \rbrace$ is a trivial subgroup of $\mathbb{Z}$ with respect to addition and $i \in I \quad n \in \mathbb{Z} \Rightarrow in \in I$. Ideals are related to a generalization of modular arithmetic so it may be possible to come up with a consistent notion of modding by $0$.

share|cite|improve this answer
It's worth noting that if you think of it as a special case of "something mod zero is undefined" then yeah it looks like a special case indeed. But if you think of it as "zero mod anything is zero" then it makes perfect sense... – Mehrdad Oct 15 '13 at 1:08

To say $a=b \mod N$ is exactly, literally, to say that $a-b\in N\cdot \mathbb Z$ (for integers...). It is true that this would normally only be asked in situations where (as the other answers suggest) something is actually happening. Here. $0\cdot \mathbb Z=\{0\}$, so for integers $a,b$ the condition $a=b\mod 0$ literally is that $a-b\in\{0\}$, which is $a-b=0$.

As suggested by the other answers, there's little point to talking this way for a "modulus" $0$, and, more confusingly, the things that usually matter, that usually help understanding or provide alternatives, fail in various regards.

Ok, those failures are irrelevant in real situations, happily. And, if we cautiously revert to the minimal formal characterization in terms of equality in the quotient ring $\mathbb Z/(N\cdot \mathbb Z)$, we find that it's just asking about equality in $\mathbb Z/\{0\}\cong \mathbb Z$, which is the usual equality in $\mathbb Z$.

That is, the corollaries mess up for modulus $0$, but the "fancier/higher-level" notion is perfectly fine... if somewhat boring/pointless.

share|cite|improve this answer
The funny thing is, I came across this when I wrote some code, and I feel it was completely justified of me to expect the answer to be zero. What was I doing? I was reading a table of count numbers, and I was checking that count % rows was equal to 0 to make sure I was reading a whole number of rows. But the program crashed when the table was empty... yet I feel that's a pretty good justification for expecting the answer to be zero -- it's a very practical scenario! – Mehrdad Oct 15 '13 at 0:56
Yes, a programming environment should be able to accommodate that, but, ... maybe they don't...! :) Hard to anticipate... I would be in favor of $0$ reduced-mod $0$ being $0$, but I am more a mathematician than programmer, although I have written code in many languages (even in the 1960s, on Hollerith cards, etc. Close-to-the-metal. :) – paul garrett Oct 15 '13 at 1:00

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.