simple 'why' question about modular arithmetic 13 mod 5

6.1k Views Asked by At

After checking out khan academy "what is modular arithmetic" https://www.khanacademy.org/computing/computer-science/cryptography/modarithmetic/a/what-is-modular-arithmetic

they say that 13/5 = 2 remainder 3, and therefore 13 mod 5 = 3 but 13/5 = 2.6 I do not know where they get the remainder 3 from

can someone please explain?

6

There are 6 best solutions below

0
On BEST ANSWER

Since $13 = 2 \cdot 5 + 3$, the remainder when $13$ is divided by $5$ is $3$.

0
On

What $13$ mod $5 = 3$ means is that you take $13$ and subtract $5$ repeatedly until you get a number less than $5$. $13-5=8$ and $8-5=3$. $3$ is less than $5$. Therefore, $13$ mod $5 = 3$.

0
On

Do you know how to convert improper fractions into mixed fractions? That's basically what we're doing here: \begin{align*} \frac{13}{5} = \frac{2(5) + 3}{5} = 2 + \frac{3}{5} = 2\frac{3}{5} \end{align*} The leftover part that remains after taking out as many $5$'s as we could from $13$ is $3$, so that's our remainder.

0
On

13/5 = 2.6 means that 5 'fits' into 13 2 times and a an additional "0.6" time (that's the rest of the division)

So 13=5+5+0.6*5, 13=5+5+3.

0
On

Integer arithmetic--where the numbers that go into the operations and the results that come out are all integers--is important in mathematics and in practical applications of mathematics. In integer arithmetic, the result of $13 \div 5$ cannot be $2.6,$ because $2.6$ is not an integer: instead, $2.6$ is a rational number, which also has many important uses in mathematics and in practical applications but is not useful in this particular case.

I was taught integer division in school long before rational division. Possibly not all school curricula do it this way, but "$13$ divided by $5$ is $2$ with a remainder of $3$" is an old concept.

3
On

It's not really correct to think of $\!\!\mod n$ as an operation returning integers $\{0, \dots, n - 1\}$ (as in, for example, the C operator $a\;\%\;b$); rather, $a = b\pmod{n}$ simply means that $n|(b - a)$. Here, $13=3\pmod{5}$ because $13 - 3 = 10$ is divisible by $5$.

(So, what's the problem just writing $13\pmod{5}= 3$? In general, we want to talk about relations like $a = b\pmod{X}$ for various "things" X (groups, ideals, vector spaces, etc.). For integers, we have a convenient choice of representative of the corresponding classes: Every integer $a$ satisfies $a = b\pmod{n}$ for exactly one choice of $b = 0, \dots, n - 1$. Such canonical representatives don't exist in general. More damningly, thinking about $a\to a\pmod{n}$ as a function or operation $\mathbb{Z} \to \mathbb{Z}$ rather than a relation means that expected, desirable properties fail to hold. For example, $5\pmod{3} = 2$ and $4\pmod{3} = 1$, but $(5\mod{3}) + (4\mod{3})$ would equal $3$, whereas $(5 + 4)\pmod{3} = 0$.) The same applies to multiplication, etc.