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$?
 A: 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 ____
A: The numbers $n^2,n^2+1,n^2+2,.....,n^2+2n$ are such that the integer part of its square roots are the same and equal to $n$. It follows that we are concerned with the numbers $$31^2 and\space 961,962,.....,999\\30^2 and\space 900,901,.....,960\\29^2 and\space 841,842,.....,899\\.....\\.....$$
For $31^2 and\space 961,962,.....,999$ one has $29$ and $33$ to be computed so $29\cdot34=986$ is the only number to be considered; for $30^2 and\space 900,901,.....,960$ one has $28$ and $32$ and the numbers $924$ and $952$ to be considered; these numbers as well as the first,which is $864$, to be considered for $29^2$ does not give a solution. But the second number, the number $891$ gives the solution. In fact
$$\left \lfloor{\sqrt{895}}\right \rfloor-2 \mid 895-4\iff 891=27\cdot33\\\left \lfloor{\sqrt{895}}\right \rfloor+2 \mid 895+4\iff 899=29\cdot31$$
