# div and mod functions over $\Bbb{Z}$

In the remark section of my textbook, it says that $$a \space \mathbf{div} \space d = \lfloor a/d\rfloor$$ and $$a \space \mathbf {mod}\space d = a - d$$.

Take $$a = 15$$ and $$d = 4 \gt 0$$.

$$15 \space \mathbf{div} \space 4 =\lfloor15/4\rfloor = 3$$

$$15 \space \mathbf {mod}\space 4 = 3 \neq 15 - 4 = 11$$

Am I mistaken?

• It probably is ${a \bmod d=a−d*q }$ – Zang MingJie Oct 26 '18 at 7:56
• You are right, there's a typo. $3=15-4\color{red}{\cdot3}$. – Yves Daoust Oct 26 '18 at 8:34

You're right. The solution at the bottom of the page contradicts the definition of $$\textrm{mod}$$ given in the remark. In fact, $$a \, \textrm{mod} \, b = a - a \, \textrm{div} \, d$$

• Ok, good. That's quite the error though. – Art Oct 26 '18 at 7:55
• @Art I agree, that's a big mistake for a textbook! – Sam Streeter Oct 26 '18 at 7:57

You are true. Nevertheless, this is a good introduction to modular notation. Let us define a new operation with this notation "$$\equiv$$". We say that $$a \equiv b \pmod m$$ if $$m |(a-b)$$. Notice that, in this new definition, $$3\equiv 7 \equiv 11 \equiv 15 \equiv 4k + 3 \pmod 4$$ for any integer $$k$$. Meaning that $$4|(7-3)$$ and $$4|(11-7)$$ and also $$4|(11-4)$$ and so on. This notation is pronounced congruent to. Therefore, we say that $$a$$ is congruent to $$b$$ mod $$m$$ meaning that $$a \equiv b \pmod m$$.

For any $$q$$, $$a=qd+a-qd.$$

The quotient is the largest number for which the term $$a-qd$$ is positive, and we have

$$a=(a\,\mathbf{div}\,d)\,d+a-(a\,\mathbf{div}\,d)\,d=(a\,\mathbf{div}\,d)\,d+a\,\mathbf{mod}\,d,$$ with $$0\le a-(a\,\mathbf{div}\,d)\,d=a\,\mathbf{mod}\,d

You are right. It should be $$a\bmod d=a-qd$$.