# 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

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}$. –  T. Bongers 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.

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