TITLE: Find $x$ such that $\sqrt{x+\sqrt{x+7}}\in \mathbb{N}$
QUESTION [19 upvotes]: Find $x$ such that $$\sqrt{x+\sqrt{x+7}}\in \mathbb{N}$$
I tried many ways: $$\sqrt{x+\sqrt{x+7}}=n$$
$$\sqrt{x+\sqrt{x+7}}^2=n^2$$
$$x+\sqrt{x+7}=n^2$$
then solve for $x$ but didn't do with success.
I think this is the most difficult problem in my lifetime
Also $x$ must be made
 of $2$ digit.

Thanks to everybody for helping me understand this problem and its solution!

REPLY [3 votes]: To see what's going on in this problem, it helps to generalize it slightly.  (This should also help put martini's wonderful answer in context.)  Let's look for integers $x$ that make an expression of the form
$$\sqrt{x+\sqrt{x+A}}\in\mathbb{N}$$
for an arbitrary $A\in\mathbb{N}$.
As other answers have shown, setting the expression in question equal to $k$ leads to the quadratic equation
$$x^2-(2k^2+1)x+(k^4-A)=0$$
for which the discriminant is
$$\Delta = (2k^2+1)^2-4(k^4-A)=4k^2+4A+1$$
For $x$ to be an integer, the discrimant must be a square, say $\Delta = n^2$.  This implies
$$(n+2k)(n-2k)=4A+1$$
Now any factorization of the integer $4A+1$, say $4A+1=ab$, gives integer values for $n$ and $k$ (with non-negative $k$ if we take $a\ge b$): Setting  $(n+2k)=a$ and $(n-2k)=b$ implies
$$n={a+b\over2}\quad\text{and}\quad k={a-b\over4}$$
(The denominators here, especially the $4$, may appear problematic, but note that $4A+1$ is congruent to $1$ mod $4$, hence its factors must be odd numbers that are both congruent to either $1$ or $3$ mod $4$.)  Each factorization gives two values for $x$:
$$x={2k^2+1-n\over2}\quad\text{and}\quad x={2k^2+1+n\over2}$$
However, only the first of these is a solution of $\sqrt{x+\sqrt{x+A}}=k$; the other is a solution of $\sqrt{x-\sqrt{x+A}}=k$.
In particular, we always have the factorization $a=4A+1$, $b=1$, and this gives $n=2A+1$, $k=A$, leading to $x=A^2-A$.  This is the solution in martini's wonderful answer.
For $A=7$, the number $4A+1=29$ is prime, so this is the only factorization.  But for $A=11$, for example, we wind up with three values of $x$ that make $\sqrt{x+\sqrt{x+11}}$ an integer:  $x=110$, $x=5$, and $x=-2$, corresponding to the factorizations $45\cdot1$, $15\cdot3$, and $9\cdot5$.