How to find all integer solutions of an equation which are divisible by 8? I have to find out all integer solutions of $n^2+15$ which are divisible by 8. So my idea was to solve the following equation.
$$n^2+15=8\cdot k \to n^2=8\cdot k-15 \to  n=\sqrt{8\cdot k-15}$$
But this doesn't work.I tried some numbers $n=1, n=3, n=5, n=7$ for these numbers I get integer solutions of $n^2+15$ which are divisible by 8. It seems to be that $n$ must be odd. How do I solve this correctly?
Best regards
 A: Hint:
It's very simple with congruences mod. $8$:
$$n^2+15\equiv 0\mod8\iff n^2\equiv 1\mod 8.$$
Now calculate the squares of the units mod.8, which are
$$\{\pm 1,\pm 3\}.$$
A: HINT: I would suggest using modularity (mod 8).
$n^2 + 15 \equiv 0 \pmod 8$.
From there, that is the same as $n^2 - 1 \equiv 0 \pmod 8$.
So, $(n+1)(n-1) \equiv 0 \pmod 8$.
Obviously, $n$ can't be even, because then $n+1$ and $n-1$ would be odd, in which case the product $(n+1)(n-1)$ would then be odd, and never $\equiv 0 \pmod 8$. 
Can you see where to go from there?
A: $n^2 + 15 = 8k \implies$
$n^2 -1 = 8(k-2) \implies$
$(n + 1)(n-1) = 8(k-2)$
If $n$ is even then $n+1$ and $n-1$ are odd and this is impossible.
If $n$ is odd then $n+1$ and $n-1$ are even.  If one of them is not divisible by $4$ than the other one is.  So if $n$ is odd hen $(n+1)(n-1)=n^2 -1$ is divisible by $8$ and $n^2 +15$ is divisible by $8$.
..or ..
Postactively:  If $n = 2k+1$ than $n^2 + 15 = (2k+1)^2 + 4k^2 + 4k + 16 = 4(k^2 + k + 2)= 8(\frac {k(k+1) }2 + 1)$
... or ...
Let $n = 4k + i; i = 0, \pm 1, \pm 2$
Then $n^2 + 15 = 16k + 8ki + i^2 + 15$ so $n^2 + 15$ is divisible by $8$ iff $15+i^2$ is.  $15+ 0^2$ and 15+ (\pm 2)^2$ are not.  $15 + (\pm 1)^2 = 16$ is.
So $n^2 + 15$ is divisible by $8$ iff $n \equiv \pm 1 \mod 4$ iff $n$ is odd.
