## Problem 6A - 331246A

For all positive integers $n$, define:

$$
f(n)=[2 \sqrt{n}]-[\sqrt{n-1}+\sqrt{n+1}]
$$

Determine all positive integers $n$ for which
a) $f(n)=1$,
b) $f(n)=0$
holds.

Hint: If $r$ is a real number, the integer $g$ such that $g \leq r < g+1$ is denoted by $g=[r]$.
We define

$$
a_{n}=2 \sqrt{n} \quad b_{n}=\sqrt{n-1}+\sqrt{n+1}
$$

We first show that $a_{n}>b_{n}$ holds, and that the difference is very rapidly decreasing:

$$
\begin{gathered}
a_{n}-b_{n}=2 \sqrt{n}-(\sqrt{n-1}+\sqrt{n+1}) \\
a_{n}-b_{n}=\frac{(2 \sqrt{n}-(\sqrt{n-1}+\sqrt{n+1}))(2 \sqrt{n}+(\sqrt{n-1}+\sqrt{n+1}))}{2 \sqrt{n}+(\sqrt{n-1}+\sqrt{n+1})} \\
a_{n}-b_{n}=\frac{4 n-(n-1+n+1+2 \sqrt{(n-1)(n+1)})}{2 \sqrt{n}+\sqrt{n-1}+\sqrt{n+1}} \\
a_{n}-b_{n}=\frac{2 n-2 \sqrt{n^{2}-1}}{2 \sqrt{n}+\sqrt{n-1}+\sqrt{n+1}}
\end{gathered}
$$

$$
\begin{aligned}
& a_{n}-b_{n}=\frac{2\left(n-\sqrt{n^{2}-1}\right)\left(n+\sqrt{n^{2}-1}\right)}{(2 \sqrt{n}+\sqrt{n-1}+\sqrt{n+1})\left(n+\sqrt{n^{2}-1}\right)} \\
& a_{n}-b_{n}=\frac{2\left(n^{2}-\left(n^{2}-1\right)\right)}{(2 \sqrt{n}+\sqrt{n-1}+\sqrt{n+1})\left(n+\sqrt{n^{2}-1}\right)} \\
& a_{n}-b_{n}=\frac{2}{(2 \sqrt{n}+\sqrt{n-1}+\sqrt{n+1})\left(n+\sqrt{n^{2}-1}\right)}
\end{aligned}
$$

Since the denominator contains only positive terms, this proves on the one hand that $a_{n}-b_{n}>0$, but on the other hand, it is also

$$
a_{n}-b_{n}<\frac{2}{2 \sqrt{n} \cdot 2 n}=\frac{1}{2 n \sqrt{n}}<\frac{1}{2 n}
$$

For $n=k^{2}$, we have $a_{n}=2 k$ and $b_{n}<2 k$, so $\left[a_{n}\right]=2 k$ and $\left[b_{n}\right]=2 k-1$, and thus $f\left(k^{2}\right)=1$. We now show that for all other cases $f(n)=0$:

1. For $n \in\left\{k^{2}+1, k^{2}+2, \ldots, k^{2}+k\right\}$, we have

$$
\left[a_{n}\right]=2 k
$$

Proof: Even for the largest element in the set, namely $k^{2}+k$, we have:

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

For the smallest element, we have:

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

For the smallest element, we have:

$$
2 k \leq 2 \sqrt{k^{2}+1} \leq 2 k+1 \\
k+\sqrt{k^{2}+1+1}>2 k \\
\sqrt{k^{2}+1+1}>k
$$

If the claim holds for the smallest $n$ in the set, it also holds for the larger ones. Therefore, for $n \in\left\{k^{2}+1, k^{2}+2, \ldots, k^{2}+k\right\}$, we have $\left[a_{n}\right]=\left[b_{n}\right]=2 k$, and thus $f(n)=0$.

2. For $n \in\left\{k^{2}+k+1, k^{2}+k+2, \ldots, k^{2}+2 k\right\}$, we have

$$
\left[a_{n}\right]=2 k+1
$$

Proof: (smallest element)

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

For the smallest element, we have:

$$
2 k+1 \leq 2 \sqrt{k^{2}+k+1} \leq 2 k+2 \\
\sqrt{k^{2}+k}+\sqrt{k^{2}+k+2}>2 k+1 \\
k^{2}+k+k^{2}+k+2+2 \sqrt{\left(k^{2}+k\right)\left(k^{2}+2 k+2\right)}>4 k^{2}+4 k+1 \\
2 \sqrt{\left(k^{2}+k\right)\left(k^{2}+2 k+2\right)}>2 k^{2}+2 k-1 \\
4\left(k^{2}+k\right)^{2}+8\left(k^{2}+k\right)>4\left(k^{2}+k\right)^{2}-4\left(k^{2}+k\right)+1 \\
12\left(k^{2}+k\right)>1
$$

Therefore, for this set $n \in\left\{k^{2}+k+1, k^{2}+k+2, \ldots, k^{2}+2 k\right\}$, we have $\left[a_{n}\right]=\left[b_{n}\right]=2 k+1$, and thus $f(n)=0$. The next largest $n$ would be $k^{2}+2 k+1=(k+1)^{2}$, which is again a perfect square. In summary, $f(n)=1$ only when $n$ is a perfect square.