If $k$ is the greatest integer such that $k < \sqrt{n+2}$ and $k|n$, prove that $n$ is a perfect square 
If $n>2$ an odd number and $k \in \mathbb{Z}$ such that $k$ is the greatest integer for which $k<\sqrt{n+2}$ and, furthermore, $k|n$ holds, prove that $n$ is a perfect square.

My idea of thinking was that, because $k$ is the greatest integer for which this inequality holds, we must have that $k < \sqrt{n+2} \leq k+1\Rightarrow k^2 < n+2 < (k+1)^2 \Rightarrow k^2 -2 < n < (k+1)^2 -2$. If I try to write $n=ak$ for some $a \in \mathbb{Z}$ (all of them are positive because of the assertion that $k$ is the greatest integer such that the inequality holds, and it holds for positive integers.) I get some intervals for $a$ but it doesn't help me get any further. Any suggestions?
 A: Let $n+2 = k^2+r$ where $0 \le r \lt 2k+1$, so $k = \lfloor \sqrt{n+2}\rfloor$ is the largest integer less than $\sqrt{n+2}$.
The requirement $k|n \rightarrow k|k^2+r-2 \rightarrow k| r-2 \rightarrow r = \lambda k+2$ for some integer $\lambda \ge 0$.
The restriction $r \lt 2k+1$ means that $\lambda = 0$ or $1$. $\lambda = 1$ leads to $n$ being even, so we are left with $\lambda = 0$. So $r=2$ and $n = k^2$ as required.
A: We first note the following:
Claim 1: The condition that $n$ is odd implies that $n \not = (a)(a+1)$ for all integer $a$, because as always, one of $a,a+1$ is even.
Write $n = ab$, with $1<a \le b < n$. Then if $a$ and $b$ are the same, then $n=a^2=b^2$, and we are done. So now it remains to consider the case $a$ and $b$ are not the same.
Then if $a$ and $b$ are not the same however, this and Claim 1 gives $b \ge a+2$. Thus
$$b^2 \ge b(a+2)$$ $$= ba +2b = n + 2b > n+2,$$ or in particular, $$b^2 > n+2,$$ or equivalently, $$b > \sqrt{n+2}.$$ This contradicts the hypothesis that $b \le \sqrt{n+2}$ however, which implies that $a$ and $b$ must be the same after all, which implies that $n=a^2=b^2$ must be a perfect square.
