# Why is n mod 0 undefined?

I tried to find out what $n$ mod $0$ is, for some $n\in \mathbb{Z}$. Apparently it is an undefined operation - why?

I might say it depends on how you define what it means to mod out by a number.

A typical first way of thinking about mods is to say that $a \equiv b \pmod d$ if $a = b + dk$ for some integer $k$. In this sense, there is nothing wrong with saying $a \equiv b \pmod 0$, although this says nothing more than $a = b$.

A different first way of thinking about mods is to say that $a \equiv b \pmod d$ if when you divide $a$ by $d$, you get remainder $b$ (or something very similar). In this sense, as it does not make sense to divide by $0$, we are at a loss.

A typical higher idea is to consider $\mathbb{Z}$ as a group, and for the 'mod by $d$' operation to mean the equivalence classes induced by taking cosets of the subgroup generated by $d$, which I'll denote by $\langle d \rangle$. In this sense, the subgroup $\langle 0 \rangle$ is the trivial subgroup, so modding out by $0$ falls more along the lines of the first way of thinking I mentioned above : it's well-defined, but not really useful.

• Great Answer. Thanks. – Newb Oct 6 '13 at 5:13
• Well, it’s useful in the same sense that zero, the empty set, etc. are useful. – user76284 Jul 10 at 18:36

In general, $x = n \pmod a$ is defined by letting $x$ be the remainder of $n$ upon division by $a$. But division by zero isn't well-defined.

Added from comment: As mixedmath points out, the use of the idea of "modulo" has a higher definition as a group theoretic concept in which regarding numbers $\pmod{n}$ is equivalent to considering cosets $n\Bbb{Z}$ in the group of integers and forming the quotient group $\Bbb{Z}/n\Bbb{Z} = \Bbb{Z}_n$. But then taking $n = 0$ doesn't really tell you anything, since the quotient group is just $\Bbb{Z} / 0 \cong \Bbb{Z}$.

• Thanks! But is there not a definition of modulo that doesn't involve division? – Newb Oct 6 '13 at 5:10
• @Newb As mixedmath points out, the use of the idea of "modulo" has a higher definition as a group theoretic concept in which regarding numbers $\pmod{n}$ is equivalent to considering cosets $n\Bbb{Z}$ in the group of integers and forming the quotient group $\Bbb{Z}/n\Bbb{Z} = \Bbb{Z}_n$. But then taking $n = 0$ doesn't really tell you anything, since the quotient group is just $\Bbb{Z} / 0 \cong \Bbb{Z}$. – user61527 Oct 6 '13 at 5:14

$r = n\mod x$ means that

1. $0 \leq r < x$

2. for some $a$, $n = x a + r$

when $x=0$, the first condition cannot be satisfied.

Depends on how you define "mod". If you mean "the remainder after dividing", you can't divide by zero, so it's not defined.

However, another way of thinking about mods is as an equivalence relation. We can define it as $$a \equiv b \pmod{n} \iff n \mid (a-b)$$ where $x \mid y$ means "$x$ divides $y$". In this case, $a \equiv b \pmod{n}$ if and only if $0 \mid (a -b)$, which just means $a = b$.

Lastly, the most general way to think of mods is by using ring theory. Take a ring $R$. An ideal $I$ in $R$ is a subring that is contagious under multiplication, so for all $a \in R$, $x \in I \implies ax \in I$. So for the integers, an ideal might be $I = \{\cdots, -10, -5, 0, 5, 10, \cdots\}$, because if you multiply a multiple of five by something, it's still a multiple of five.

Given a ring and an ideal, we can construct a subring, $R/I$, referred to as "$R$ mod $I$". The elements in this ring are cosets of this ideal. For this example, the coset of $1$ would be $1 + I = \{\cdots, -9, -4, 1, 6, 10, \cdots\}$. Instead of adding and multiplying whole sets, we can pick any representative, and multiplication and addition still end up well-defined. This is modular arithmetic! $1 + 3 \equiv 6 + 3 \equiv -9 + 3 \pmod{5}$, after all.

As for the answer to your question, notice that "the integers mod $n$" is the same as $\mathbb{Z}/n\mathbb{Z}$. So if we let $n = 0$, we mod out by the zero ideal (i.e., $I = \{0\}$), the coset of $a$ would just be $\{a\}$, and we get something isomorphic to $\mathbb{Z}$ again. In other words, $n$ mod $0$ is $n$.

• :Could you tell me is mod 0 defined in the equivalence relation for congruent modulo since when an number is divided by zero it's undefined so could we have such a number in the set of an equivalence relation. – justin Jan 30 '15 at 13:43
• The trick is "a divided by b" vs "b divides a". The latter is defined as "there exists an $x$ such that $bx = a$". But the former is defined only when that $x$ is unique (because it returns that $x$). So even though $0/0$ is undefined, $0 \mid 0$, because there exists an $x$ such that $0x = 0$ (every $x$, actually). But zero doesn't divide anything else, because $0x$ is always zero. – Henry Swanson Jan 30 '15 at 19:42
• :I can't understand the concept you're trying to explain it might be because I haven't fully gone through these concepts.I'm really confused at whether integer 0 is in the equivalence relation for congruent modulo.Could you first tell me is the remainder of the congruent modulo included in the set of equivalence relation or do we just have the modulus in the equivalence relation.If the remainder is not included in the equivalence relation then we might not need to bother about a number divided by zero isn't it? – justin Jan 31 '15 at 4:54