# How to show that the square of an integer$\equiv 0,1,-1\pmod 5$?

How to show that the square of an integer$\equiv 0,1,-1\pmod 5$ ?

I know that every integer can be expressed as $3k$, $3k+1$, $3k+2$. I tried to solve this by squaring these expressions, but I am stuck. Previously I had solved another problem like this. There I was able to show that the square of an odd integer when divided by 8, leaves remainder 1.

• Hint: every integer can be expressed as $5k,5k+1,5k+2,5k+3$ or $5k+4$. Mar 18 '17 at 10:21
• You're using mod 3 forms. Instead use mod 5 forms. Even simpler, just square 0,1,2,3,4 and reduce mod 5. Mar 18 '17 at 10:22
• oh! thank you! how fool I am! I will delete this Q. Mar 18 '17 at 10:23

Simpler: $$x\equiv 0,\pm1,\pm2\mod5,\enspace\text{so}\quad x^2\equiv 0, 1, 4(\equiv -1)\mod 5.$$

we know that $$x\equiv 0,1,2,3,4 \mod 5$$ thus we have by squaring $$x^2\equiv 0,1,4 ,9,16\equiv 0,1,-1,-1,1\mod 5$$

Every integer can be expressed as $5a,5a\pm1,5a\pm2$ where $a$ is any integer

$(5a)^2=5\cdot5a^2$

$(5a\pm1)^2=5(5a^2\pm2a)+1$

$(5a\pm2)^2=5(5a^2\pm4a)+4=5(5a^2\pm4a+1)-1$

The trick is look at the remainders of numbers upon division by $5$. Each number has a remainder of either $0, 1, 2, 3,$ or $4$, but we're considering them modulo $5$, so $3-5=-2$ and $4-5=-1$ let's us square each of $0, \pm 1, \pm 2$, giving $0, 1,$ and $4\equiv -1$ modulo $5$, respectively.

Hence the square of any integer is congruent to either $0, 1,$ or $-1$ modulo $5$.

We know that: $a=bq+r$
Let $b = 5$. Also here, $r < b$. Therefore,
$a=5q \quad\qquad\Rightarrow\quad a^2=25q^2 \quad\qquad\qquad\Rightarrow\quad a^2=5m$ [for some integer m]
$a=5q+1 \quad\Rightarrow\quad a^2=25q^2+10q+1 \quad\Rightarrow\quad a^2=5m+1$ [for some integer m]
$a=5q+2 \quad\Rightarrow\quad a^2=25q^2+20q+4 \quad\Rightarrow\quad a^2=5m-1$ [for some integer m]
$a=5q+3 \quad\Rightarrow\quad a^2=25q^2+30q+9 \quad\Rightarrow\quad a^2=5m-1$ [for some integer m]
$a=5q+4 \quad\Rightarrow\quad a^2=25q^2+40q+16 \quad\Rightarrow\quad a^2=5m+1$ [for some integer m]

Hence from the results above, we can say that:
For any integer $n$,
$n \equiv 0,\pm 1$ (mod 5)