Divisibility theorem based proof for any square mod 4 being either 0 or 1 Kindly help me in understanding the below proof for given statement:
If $n$ is a square, then leaves a remainder $0$ or $1$ when divided by 4.
Proof: The divisibility theorem states that for two integers $a,b$ with $b>0$, then there is a unique pair of integers $q$ and $r$ such that $a =qb +r$ and $0\le r <b$.
Let the number $n= a^2$, for $a$ being an integer. If $b$(divisor)$=4$, then $a = 4q +r$, where $r \in \{0, 1, 2, 3\}$, so that $n = (4q+r)^2 = 16q^2 + 8qr + r^2$.
If $r=0$, then $n=4(4q^2 +2qr) +0$; if $r=1$, then $n=4(4q^2 +2qr)+1$; if $r=2$, then $n =4(4q^2 +2qr+1) +0$; and if $r =3$, then $n = (4q^2 +2qr+2)+1$. In each case , the remainder is $0$ or $1$.

The difficulty lies in the last para. where according to me it should be:
If $r=0$, then $n=4(4q^2 +2qr) +0$; if $r=1$, then $n=4(4q^2 +2qr)+1$; if $r=2$, then $n =4(4q^2 +2qr) +2$; and if $r =3$, then $n = (4q^2 +2qr)+3$. 

Any integer is of the form $2n$ or $2n-1$ (i.e odd or even) 
Now sq. of any number will be in the form $$(2n)^2 =4p or (4n-1)^2 =4q +1$$ 
So we find when that if $n$ is a square, then leaves a remainder $0$ or $1$ when divided by $4$.
