Is there an equivalent in mathematical language to the modulo (or mod) function in computing?
- 19,406
- 363
2 Answers
I have seen the percent sign (%) represent mod in computing. So when you are thinking of as x % n, a mathematician would equivalently write this as $x \bmod n$.
There is a subtlety here, though. When you are using mod in computing, you are thinking of it as a function that returns the least non-negative value that is the remainder after performing the division of $x$ by $n$. Typically in mathematics, though, we think of modulo as a restriction on the set of numbers we are currently working with. You will hear the phrase "we are working $\bmod n$ right now," and we'll have the modulo $\pmod n$ written off the side in parenthesis almost like a reminder.
You'll usually often see the notation $y \equiv x \pmod n$ and sometimes more you'll see the more compact notation $y \equiv_n x$. These both would be read as "$x$ and $y$ are congruent $\bmod n$". We choose to say that $x$ and $y$ are congruent (rather than equivalent) because they are just members of the same equivalence class $\bmod n$.
For a concrete example we can look at the integers modulo $7$, more concisely written as $\mathbb{Z}_7$. Now $\mathbb{Z}_7$ consists of $7$ elements, $\{0,1,2,3,4,5,6\}$. But these elements aren't exactly numbers. Each of these elements in $\mathbb{Z}_7$ represents an equivalence class. The element $3$ in $\mathbb{Z}_7$ represents the equivalence class of all integers that are congruent to $3\pmod 7$, so it is the integers in the set $\{\dotsc, -11,-4,3,10,17, \dotsc\}$.
- 19,406
The mathematical symbol in many computer languages and also mathematics is mod it represents modular divsion . Eg $15 mod 2=7$
- 16,138