Greatest $n<1000$ such that $\left \lfloor{\sqrt{n}}\right \rfloor-2 \mid n-4$ and $\left \lfloor{\sqrt{n}}\right \rfloor+2 \mid n+4$? My first attempt was incorrect, and it is supposed to be a middle school problem.
So, if $n=k^2$
Then $k-2 \mid n-4$ and $k+2 \mid n+4$, so $n-4 \mid (n-4)(n+4)$. I then assumed the answer would be a perfect square  (not a great assumption) to get $n=961=31^2$. I then reasoned that $n$ would be around this value, so I checked these numbers and I think it was $958$. Is there a better way to do this, rather than just checking values less than $1000$?

Let $k=[\sqrt n]$. Then we know that 
$$
k^2\le n<k^2+2k+1.
$$
So $n-4$ is in the range $[k^2-4,k^2+2k-4]$. Of the numbers in that range
only $k^2-4$, $k^2+k-6$ and $k^2+2k-8$ are divisible by $k-2$, so $n$ has to be one of $k^2,k^2+k-2, k^2+2k-4$.
We also see that $n+4$ is in the range $[k^2+4,k^2+2k+4]$. Of those numbers only
$k^2+k-2$ and $k^2+2k$ are divisible by $k+2$. Therefore $n$ also needs to be one of $k^2+k-6$, $k^2+2k-4$.
Looks like $n=k^2+2k-4=(k+1)^2-5$ is the only remaining alternative. 
Therefore the answer is ____
