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

189 Views Asked by At

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?

enter image description here

4

There are 4 best solutions below

2
On BEST ANSWER

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$

0
On

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

0
On

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

0
On

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