Prove that $24|n^2-1$, if $(n,6)=1$ $n^2-1 = (n-1)(n+1)$
Then $24|(n-1)(n+1)$
$(n,6)=1$: $\exists a,b\in\mathbb{Z}$ that $n = 6\cdot a+b$
Investigate the residues, which arise when dividing the number n by two and three:
$\frac{6\cdot a+b}{3} = \frac{6\cdot a}{3}+\frac{b}{3} = 2\cdot a+\frac{b}{3}$
$\frac{6\cdot a+b}{2} = 3\cdot a+\frac{b}{2}$
Is this correct? How to prove it using resiudes? 
Thank You.
 A: If $\gcd(n,6)=1$, then there is some integer $k$ such that $n=6k\pm 1$.  We compute $$n^2-1=(6k\pm 1)^2-1 = 36k^2\pm 12k = 12k (3k\pm 1)$$
Now, if $k$ is even, then $24|12k$ already.  If instead $k$ is odd, then $3k\pm 1$ is even, so again $24|12k(3k\pm 1)$.
A: Note that $\gcd(n,6)=1 \implies n = 6 a + 1$ or $n=6a+5$, where $a \in \mathbb{Z}$. 
For $n=6a+1$,
$$(n-1)(n+1) = 12a(3a+1).$$
Since $a(3a+1)$ is always even, i.e., $a(3a+1)=2k$, $(n-1)(n+1) = 24k$. 
Similar is the case for $n = 6a+5$.
A: If $\gcd(n,6)=1$, then $n$ is odd and $n^2 \equiv 1 \bmod 8$.
If $\gcd(n,6)=1$, then $\gcd(n,3)=1$ and $n^2 \equiv 1 \bmod 3$.
Thus $24 = lcm(8,3)$ divides $n^2-1$.
A: Given $n-1, n, n+1$ and $n+2$ then $2$ divides two of them and $4$ divides one of them and $8$ divides the product $(n-1)n(n+1)(n+2)$.  If $n$ is odd then we know the two that $2$ and $4$ divides must be $n-1$ and $n+1$ and that $8$ divides the product $(n-1)(n+1)$.
Given $n-1, n , n+1$ then $3$ divides exactly one of them.  If $3\not \mid n$ then $3$ divide either $n-1$ or $n + 1$ so $3|(n+1)(n-1)$.
So if $n$ is odd and $3 \not \mid n$, then $3*8|(n+1)(n-1)$.
That will be the case if $\gcd(n,6) = 1$.  So if $\gcd(n,6) =1$ then $n$ is odd and $3\not \mid 6$ and so $24 = 3*8|(n+1)(n-1) = n^2 - 1$.
......
Using residues:
$\gcd(n,6) = 1$ so $\gcd(2, n) = 1$ so $\gcd(8^n, 1) $ so $n \equiv 1, 3,5, 7 \equiv \pm 1, \pm 3\mod 8$.  So $n^2 \equiv 1, 9\equiv 1 \mod 8$.
$\gcd(n,6) = 1$ so $\gcd(3, n) =1$ so $n \equiv \pm 1 \mod 3$.  So $n^2 \equiv 1 \mod 8$.
So $n^2 -1 \equiv 0 \mod 3$ and $n^2 -1 \equiv 0 \mod 8$.
So $3|n^2 - 1$ and $8|n^2 -1$ and $24|n^2 - 1$.
