Negative modulus In the programming world, modulo operations involving negative numbers give different results in different programming languages and this seems to be the only thing that Wikipedia mentions in any of its articles relating to negative numbers and modular arithmetic. It is fairly clear that from a number theory perspective $-13 \equiv 2 \mod 5$. This is because a modulus of $5$ is defined as the set $\{0,1,2,3,4\}$ and having $-13 \equiv -3 \mod 5$ would contradict that because $-3 \not\in \{0,1,2,3,4\}$. My question is then regarding a negative modulus. What definition of a modulus of $-5$ would make the most sense in number theory? One in which $13 \equiv -2 \mod -5$, one in which $13 \equiv 3 \mod -5$, or something else entirely?

The multiples of 5 are the exact same as the multiples of $-5$, it's just they're indexed differently. So $13 \equiv -2 \bmod -5$ is just as valid as $13 \equiv 3 \bmod -5$, since $13 = -3 \times -5 - 2 = -2 \times -5 + 3$.
It is true that $-3 \not\in \{0, 1, 2, 3, 4\}$. But $-3$ is in $\{0, -4, -3, -2, -1\}$. We could say that 2 and $-3$ are "representatives" of the same "coset" (I hope this doesn't sound like I'm inventing the terminology off the cuff). This coset consists of all numbers that are 2 more than a multiple of 5 or 3 less than a multiple of 5: $5n + 2$ or $5n - 3$, where $n$ is any integer.
Obviously there are infinitely many other numbers to represent a particular coset. But something like $13 \equiv 13 \bmod -5$ looks like an obfuscation. In general, for $a \equiv b \bmod c$, you want $|b| < |c|$. But the preference is usually for $b$ positive, unless $b = c - 1$, in which case mathematicians much prefer to write $a \equiv -1 \bmod c$. Look up Fermat's little theorem or Wilson's theorem for examples of this.
