Proof for $\forall x\in \mathbb{Z}^+, \exists t \in \mathbb{Z}, 5 \nmid x \to ((x^2= 5t + 1) \vee (x^2 = 5t – 1))$ I am trying to write a proof for the following: If $x$ is a positive integer that is not divisible by $5$, then $x^2$ can be written either as $x^2 = 5t+1$ or $x^2 = 5t−1$ for some integer $t$. So far, I have managed to get that if $x$ is not divisible by $5$, then it is one of the following cases, where $n$ represents a positive integer: 
\begin{align*}
x & = 5n + 1\\
x & = 5n + 2\\
x & = 5n + 3\\
x & = 5n + 4
\end{align*}
I have tried substituting for $x$, but with two different variables $n$ and $t$ and everything, I'm not sure how I would prove they can be equal. Any help would be much appreciated. Thank you!
 A: If $x = 5n-1$, then
$$x^2 = (5n-1)(5n-1) = 5n(5n-1) - (5n-1) = 5n(5n-1) - 5n+1 $$ 
When you divide $x^2$ by $5$, the first two terms above has no remainders, and therefore, $x^2$ modulo $5$ is $1$. (note: $t$ in this case would be equal to $n(5n-1)-n$)
If $x = 5n-2$, then
$$x^2 = (5n-2)(5n-2) = 5n(5n-2) - 2(5n-2) = 5n(5n-2) - 2\cdot 5n + 2\cdot 2 $$ 
When you divide $x^2$ by $5$, the first two terms above has no remainders, and therefore, $x^2$ modulo $5$ is $-1$.
Similar calculations would show the required result.
A: Your method is the simplest way to do it. But all the other answers seemed to use a similar method, so here is a different approach. 
Note that if $x \not \equiv 0 \pmod 5$ and $x^2-1 \not \equiv 0 \pmod 5$ and $x^2+1 \not \equiv 0\pmod 5$, multiplying these gives us that $x^5 -x\not \equiv 0 \pmod 5$. A contradiction by Fermat's Little Theorem. 
A: If $5 \not \mid x$, then 


*

*$x \equiv 1\mod 5$, 

*$x \equiv 2 \mod 5$, 

*$x \equiv 3 \mod 5$ or 

*$x \equiv 4 \mod 5$. 


Now $1^2 \equiv 4^2 \equiv 1\mod 5$ and $2^2 \equiv 3^2 \equiv -1\mod 5$ and therefore $x^2 \equiv 1 \mod 5$ or $x^2 \equiv -1 \mod 5$.
A: Once you get that far, just check every case:
$x = 5n+1$:
$$x^2 = 25n^2 - 10n + 1 = 5(5n^2 + 2n) + 1 = 5k + 1$$
$x = 5n + 2$:
$$x^2 = 25n^2 + 20n + 4 = 25n^2 + 20n + 5 - 1 = 5(5n^2 + 4n + 1) - 1 = 5t - 1$$
$x = 5n + 3$:
$$x^2 = 25n^2 + 30n + 9 = 25n^2 + 30n + 10 - 1 = 5(5n^2 + 6n + 2) -1 = 5l - 1$$
$x = 5n + 4$:
$$x^2 = 25n^2 + 40n + 16 = 25n^2 + 40n + 15 + 1 = 5(5n^2 + 8n + 3) + 1 = 5m + 1$$
$k,t,l,m$ are all positive integers.
