Find all possible integers $n$ such that $\sqrt{n + 2} + \sqrt{n + \sqrt{n + 2}}$ is an integer.

We have that $$m = \sqrt{n + 2} + \sqrt{n + \sqrt{n + 2}} \ (m \in \mathbb N)$$

$$\iff m - \sqrt{n + 2} = \sqrt{n + \sqrt{n + 2}} \iff (m - \sqrt{n + 2})^2 = n + \sqrt{n + 2}$$

$$\iff m^2 - (2m - \sqrt{n + 2})\sqrt{n + 2} = (\sqrt{n + 2} + 1)\sqrt{n + 2} - 2$$

$$\iff m^2 + 2 = (2m + 1)\sqrt{n + 2} \iff \sqrt{n + 2} = \frac{m^2 + 2}{2m + 1}$$

As an addition, $\dfrac{m^2 + 2}{2m + 1} \in \mathbb Q^+, \forall m \in \mathbb N \implies \sqrt{n + 2} \in \mathbb Q^+$

$\implies \sqrt{n + 2} \in \mathbb N \implies \dfrac{m^2 + 2}{2m + 1} \in \mathbb N \iff \dfrac{4(m^2 + 2) - (2m + 1)(2m - 1)}{2m + 1} \in \mathbb N$

$\iff \dfrac{9}{2m + 1} \in \mathbb N \iff 2m + 1\mid 9 \iff 2m + 1 \in \{1, 3, 9\} \iff m \in \{0, 1, 4\}$

We can set up a table for different value of $m$ and $\sqrt{n + 2}$.

$$\begin{matrix} m&& 0&& 1&& 4\\ \sqrt{n + 2} = \dfrac{m^2 + 2}{2m + 1}&& 2&& 1&& 2 \end{matrix}$$

$\iff n \in \{-1, 2\}$.

Plugging $n \in \{-1, 2\}$ in $m = \sqrt{n + 2} + \sqrt{n + \sqrt{n + 2}}$, we have that $(m,n) = (1, -1)$ and $(m, n) = (4, 2)$ is the correct answer.


We have that $n+2 = a^2, n + a = b^2$, where $a$ and $b$ are non-negative integers.

If $a > 2$, then $$a^2 = n+2 < n+a = a^2 + a - 2 < a^2 + 2a + 1.$$

This means that $n+a$ cannot be a perfect square as it's bounded between 2 consecutive perfect squares, which is a contradiction. Hence $ 0 \leq a \leq 2$.

If $ a= 0$, then $n = -2$ but $n+a = -2$ is not a perfect square. No solution.
If $a = 1$, then $n = - 1$ and $n+a = 0$ is a pefect square. This gives $m=1$.
If $a=2$, then $n=2$ and $n+a = 4$ is a perfect square. This gives $m=4$.