0

A student has asked me to look at this problem:

Prove that for every $n \in \mathbb{N}_{\geq 0}$, when we divide $n^2$ by $7$, the remainder is either $0$, $1$, $2$ or $4$.

AmorFati
  • 1,888

4 Answers4

3

Modular arithmetic is distributive: $ab\pmod{r}\equiv (a\pmod{r})(b\pmod{r})$.

$n\pmod{7}$ can take on any value in $\{0,1,2,\cdots,6\}$. So just square each value and recalculate the mod 7. For example, $4^2\equiv 2\pmod{7}$. Show that the resulting remainders are $0,1,2,4$.

Alex R.
  • 32,771
0

Hint $$n^2=n \cdot {\bf n} \pmod{7} \\ n^2-1= {\bf(n-1)\cdot (n+1)} \pmod{7} \\ n^2-4= {\bf(n-2)\cdot (n+2)} \pmod{7} \\ n^2-2= {\bf(n-3)\cdot (n+3)} \pmod{7} \\ $$

Now, among the 7 consecutive integers $n-3,n-2,n-2,n,n+1,n+2, n+3$ one is divisible by $7$.

N. S.
  • 132,525
0

$\begin{align}\bmod 7\!:\,\ &\ n\, \equiv \pm\{0,1,2,3\}\\ \Rightarrow\ \ \ &n^2\equiv\ \ \ \{0,1,4,2\}\end{align}$

Bill Dubuque
  • 272,048
0

Well if you divide $n$ by $7$ you get a remainder $r$ where $r$ may be $0,1,2,3,4,5,6$.

So $n = 7q + r$. If you square it you get $n^2 = 49q^2 + 14qr + r^2$. If you divide that by $7$ the remainder you get will be the remainder of $r^2$. As $r = 0, 1,2,3,4,5,6$ we know $r^2 = 0, 1,4,9,16,25,36$ and if we take those remainders we get $0, 1, 4,2,2,4,1$.

That's all.

=====

If we want to make the calculations easier, note that $7q + r = 7(q+1) + (r-7),$ so we can replace $r=4,5,6$ with $4-7 = -3$ and $5-7 = -2$ and $6-7 = -1$. The $49q^2 + 14qr$ terms don't matter, as they are divisible by $7,$ so it doesn't matter if we do $(7q + r) = 49q^2 + 14qr + r^2$ or $(7(q+1)+(r-7))^2 = 49(q+1)^2 + 14q(r-7) + (r-7)^2$ if $r-7 = -1,-2$ or $-3$.

So if we let $r' = r$ if $r = 0,1,2,3$ and $r'= -3,-2,-1$ if $r = 4,5,6$ then $r'^2 = 0^2, (\pm 1)^2, (\pm 2)^2, (\pm 3)^2 = 0, 1, 4,9,$ and the remainder of $9$ is $2$.

We call this type of remainder arithmetic modulo arithmetic. We use the notation $a \equiv b \pmod n$ to mean $a$ and $b$ have the same remainder if divided by $n$. We can see that if $a \equiv b \pmod n$ and $c\equiv b \pmod n$ then we know $a+c\equiv b+d \pmod n$ and $a\times c \equiv b\times d \pmod n$.

And so if $n \equiv r \pmod 3$ then $n^2 \equiv r^2 \pmod 3$. And since every $n$ is $\equiv 0, \pm 1, \pm 2$ or $\pm 3\pmod 7$ we know our answers.

It may seem complicated but you get used to it really fast. And it's very useful.

J. W. Tanner
  • 60,406
fleablood
  • 124,253