Sequence $f(m), f(f(m)),\ldots$ never contains a square I have the following problem, and I would like to know if my proof is correct, and if there is a faster way to prove the result.
Problem

Let $\{x\}$ denote the closest integer to the real number $x$. Define $f(n)=n+\{\sqrt n\}$. Prove that for every positive integer $m$, the sequence $$f(m), f(f(m)),\ldots$$ never contains the square of an integer.

Attempt
First suppose that $m=k^2$, then $f(m)=k^2+k$. If $f(m)=n^2$ was a square we would have $$4n^2+1=(2k+1)^2$$ But this is only possible when $n=0$. We may therefore assume that $m$ is not a square.
Let therefore $k^2<m<(k+1)^2$. Since $\{\sqrt{m}\}=k,k+1$ we have that $$f(m)<(k+1)^2+k+1<(k+2)^2$$
Therefore if $f(m)$ is a square we wust have $f(m)=(k+1)^2$. There are two possibilities:

*

*$m=(k+1)^2-k=k^2+k+1$ and $\{\sqrt{k^2+k+1}\}=k$

*$m=(k+1)^2-(k+1)=k^2+k$ and $\{\sqrt{k^2+k}\}=k+1$
Both of these are impossible.

$\{\sqrt{k^2+k+1}\}=k+1$

Proof: The above happens if $\sqrt{k^2+k+1}\geq k+\frac{1}{2}$. Squaring both sides yields $1\geq\frac{1}{4}$.

$\{\sqrt{k^2+k}\}=k$

Proof: The above happens if $\sqrt{k^2+k}\leq k+\frac{1}{2}$. Squaring both sides yields $0\leq\frac{1}{4}$.

A stronger observation is that the given $f(n)$ is precisely the $n$-th non-square integer. I will try to sketch a proof-
Note that the number of non-square integers between $k$-th and $(k-1)$-th square integers is
$$k^2-(k-1)^2-1=2(k-1)$$
So, the number of non-square integers below the $k$-th square integer is
$$2\left (1+2+\dots +(k-1)\right)=k(k-1)$$
Now, we want $n$ such that
$$n=k(k-1)$$
i.e.,
$$k=\frac{1+\sqrt{4n+1}}2$$
So, the $n$-th non-square integer is
$$\left(\frac{1+\sqrt{4n+1}}2\right)^2-1\;\text{ if $\left(\frac{1+\sqrt{4n+1}}2\right)^2$ is an integer}\\
\text{or }\left\lfloor\left(\frac{1+\sqrt{4n+1}}2\right)^2\right\rfloor\;\text{ if $\left(\frac{1+\sqrt{4n+1}}2\right)^2$ is not an integer}$$
which is
$$n+\left(\frac{\sqrt{4n+1}-1}2\right)\text{ or }\left\lfloor n+\left(\frac{1+\sqrt{4n+1}}2\right)\right\rfloor$$
So, it suffices to show that
$$\langle n\rangle=\begin{cases}
\left(\frac{\sqrt{4n+1}-1}2\right)&\text{ if it is an integer}\\
\left\lfloor \frac{1+\sqrt{4n+1}}2\right\rfloor&\text{ if not}
\end{cases}$$
To do this, it is enough to see that the first expression is an integer iff $n=m(m-1)$ for some $m\in \mathbb N$. So, it reduces to proving
$$\langle m\sqrt{m-1}\rangle=m$$
and indeed
$$(m-1)-\frac 12<\sqrt{m(m-1)}<(m-1)+\frac 12$$
And, for the second exp0ression, we only need to observe that
$$\left\lfloor \sqrt{n+\frac 14}+\frac 12\right\rfloor=\left\lfloor \sqrt{n+\frac 12}\right\rfloor$$
Leaving aside a few details (which I leave for you to fill), this more or less completes the proof.
