Why $5 (\mod 7)$ is $5$?
$\frac 57$ is equal to $0.7$. Remaining is $1$.
by definition, the remainder when dividing $\frac mn$ is such a number $r$ such that
$0≤r<n$
There exists some $k$ such that $k\times n+r=m$
In this case: $1\times7+r=5$, so $r = -2$
And now? how do I get the $5$ as result?
$\endgroup$ 24 Answers
$\begingroup$We can also write $5=7*(-1)+12$ or $5=7*2-9$, that doesn't make the remainder on the division either $12$ or $-9$ (but it does show that those numbers are congruent to $5$ modulo $7$). When doing integer arithmetic modulo $h$, you have to find a remainder $0\leq j<h$.
$\endgroup$ $\begingroup$Recall the correct definition:
We say that $a \equiv b \mod n$ if there exists some integer $k \in\mathbb{Z}$ such that $a-b=kn$.
In your example, $5 \equiv 5 \mod 7$ since $5-5=0=0 \times 7$.
$\endgroup$ 1 $\begingroup$$\cfrac 57 \approx 0.713$
But modular arithmetic is integer division, unlike above.
$5 \mod 7\equiv 5$
$7$ goes into $5$ zero times
$k+(0*7)=5 \implies k=5$, and the remainder is $5$ after $7$ goes into $5$ zero times
$\endgroup$ 2 $\begingroup$One has to be careful not to confuse two related but slightly different things which can be meant when talking about "$\mod n$":
- Given two numbers $a$ and $b$, we can ask if they are equivalent modulo $n$. We say $a$ and $b$ are equivalent modulo $n$, written $$a\equiv b \mod n$$ if $n$ divides $a-b$, i.e. if there is an integer $k\in\mathbb{Z}$ such that $a-b=kn$. This is a relation which two numbers might or might not satisfy. There are in fact many numbers which are all equivalent modulo $n$. For example, all of the numbers $5$, $-2$ and $12$ are equivalent modulo $7$. So any of the following are true $$5\equiv -2 \mod 7$$ $$-2\equiv 5 \mod 7$$ $$5\equiv 5 \mod 7$$ $$5\equiv12 \mod 7$$
- Given a number $a$ we can ask for the remainder of $a$ after division by $n$. This is the unique $0\leq r<n$ such that $a\equiv r\mod n$. Sometimes people use the notation $(a\mod n)$ for this number $r$. So you would write $r=(a\mod n)$. With this notation, only the first two of the following statements are true: $$(5\mod 7)=5$$ $$(-2\mod 7)=5$$ $$(5\mod 7)=-2$$ $$(-2\mod 7)=-2$$