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!

  • $\begingroup$ There should be some other assumption in the problem, otherwise it's trivial that for any sufficiently large $n\in\mathbb{N}$ there is a solution to $\sqrt{x+\sqrt{x+7}}=n$ (and by sufficiently large, I mean $n>2$), and it is found just by isolating $x$ and resolving a quadratic polynomial. $\endgroup$
    – rewritten
    Commented Dec 4, 2013 at 10:53
  • $\begingroup$ An additional information must be needed.with above information we can find infinite values of x.we can understand that by plotting graph of $y$ vs $x$ where $y=x+\sqrt {x+7}$ and find corresponding value of x when y become perfect squares,by looking graph we can see that infinite values for $x$ is possible $\endgroup$ Commented Dec 4, 2013 at 11:44
  • 2
    $\begingroup$ Is 42 the answer?! $\endgroup$ Commented Dec 5, 2013 at 5:56
  • 2
    $\begingroup$ @zeta, that's the ultimate answer! $\endgroup$
    – tenpercent
    Commented Dec 5, 2013 at 6:36

8 Answers 8


If you just want to find some $x$, not all, you can try to find $x$ such that $\sqrt{x+7} = 7$, as then $$ \sqrt{x + \sqrt{x+7}} = \sqrt{x+7} = 7 \in \mathbb N.$$ Can you see such an $x$?

  • $\begingroup$ MARVELLOUS!!! THANK YOU SO MUCH!!! $\endgroup$ Commented Dec 4, 2013 at 13:08
  • $\begingroup$ But i have problem how you derived ths equationn $\sqrt{x + \sqrt{x+7}} = \sqrt{x+7}$ $\endgroup$ Commented Dec 4, 2013 at 13:13
  • $\begingroup$ @9abab You need $\sqrt{x+7} = 7$. When you do that, you can use $\sqrt{x + \sqrt{x+7}} = \sqrt{x+7}$. Can you find an $x$ so $\sqrt{x+7} = 7$? $\endgroup$
    – kba
    Commented Dec 4, 2013 at 13:31
  • 4
    $\begingroup$ You deserve a money price :) $\endgroup$ Commented Dec 4, 2013 at 19:11
  • 3
    $\begingroup$ Coincides with the answer to the Ultimate Question of Life, the Universe, and Everything $\endgroup$
    – Alex
    Commented Dec 7, 2013 at 17:44

$$x + 7 = ((n^2)-x)^2 = n^4 - 2n^2x + x^2$$ $$x^2-(2n^2+1)x+n^4-7=0$$ $$x_{1,2}=\frac{2n^2+1 \pm \sqrt{(2n^2+1)^2-4(n^4+7)}}{2}\\ =\frac{2n^2+1 \pm \sqrt{4n^4+4n^2+1-4n^4+28}}{2}\\ =\frac{2n^2+1 \pm \sqrt{4n^2+29}}{2}\\$$

This is an integer if and only if $ \sqrt{4n^2+29}$ is an integer (the converse follows immediately from the observation that if $\sqrt{4n^2+29}$ is an integer, it must be odd.

Claim 1: If $\sqrt{4n^2+29}$ is an integer, then $n \leq 7$.

Proof: $$\sqrt{4n^2+29} > \sqrt{4n^2}=2n \,.$$ Thus $$\sqrt{4n^2+29} \geq 2n+1 \,.$$ Hence $$4n^2+29 \geq 4n^2+4n+1 \,.$$

This implies that $n \leq 7$, with equality if and only if $n=7$.

Claim 2: If $\sqrt{4n^2+29}$ is an integer, and $n \neq 7$ then $n \leq 1$.

Proof: Exactly like in Claim $1$ $$\sqrt{4n^2+29} \geq 2n+1 \,.$$

But we proved that we only have equality for $n=7$. Thus $$\sqrt{4n^2+29} > 2n+1 \,.$$

As $\sqrt{4n^2+29}$ is odd, we get $$\sqrt{4n^2+29} \geq 2n+3 \,.$$ $$4n^2+29 \geq 4n^2+12n+9 \,.$$ $$29 \geq 12n+9 \,.$$

Thus $n \leq 1$.

Thus we showed that the only $n$ which can work are $n = 0, n = 1$ and $n = 7$.

If $$n=0 \Rightarrow x_{1,2} =\frac{1 \pm \sqrt{29}}{2} \notin \mathbb Z$$ $$n=1 \Rightarrow x_{1,2} =\frac{2+1 \pm \sqrt{4+29}}{2}\notin \mathbb Z$$ $$n=7 \Rightarrow x_{1,2} =\frac{99 \pm 15}{2}$$

P.S. Don't forget that we squared couple times, which means that the solutions we got are solutions to $$x + 7 = ((n^2)-x)^2 = n^4 - 2n^2x + x^2$$ but not necessarily to the original question.

One needs to check them in the original equation, and only one works.

The reason why the other solution doesn't work is because it appears as an extra solution when we square: $$\sqrt{x + 7 }= (n^2)-x$$

If we observe in the original equation that $n^2 \geq x$, this eliminates the wrong extra solution .

  • $\begingroup$ last value is for n=7, btw (gives the solution given by martini, too) $\endgroup$
    – njzk2
    Commented Dec 4, 2013 at 23:24
  • $\begingroup$ It is easy to show that if $x\in\mathbb{R}$ such that $\sqrt{x+\sqrt{x+7}}=n\in\mathbb{N}$ then $\displaystyle \frac{1-\sqrt{29}}{2}\le x\le n^2$ must hold. Therefore we cannot have solutions of the form $\displaystyle\frac{2n^2+1+\sqrt{4n^2+29}}{2}$. The only valid ones that yield $n\in\mathbb{N}$ are of the form $\displaystyle\frac{2n^2+1-\sqrt{4n^2+29}}{2}$. $\endgroup$
    – tcmtan
    Commented Dec 5, 2013 at 2:15
  • $\begingroup$ you see, $\frac{99+15}{2} = 57$, and $\sqrt{57 + \sqrt{57 + 7}} = \sqrt{57 + 8} = \sqrt{65}$. It happens. $\endgroup$
    – tenpercent
    Commented Dec 5, 2013 at 5:09
  • $\begingroup$ @tenpercent Of course it happens, we squared couple times on the way, which means that the solutions of the two equations are not necessarily the same. $\endgroup$
    – N. S.
    Commented Dec 5, 2013 at 5:22
  • 1
    $\begingroup$ @N.S. If I wasn't clear then I meant the same thing you wrote. You should then clarify that only solutions of the form $\displaystyle\frac{2n^2+1-\sqrt{4n^2+29}}{2}$ satisfy the original equation. $\endgroup$
    – tcmtan
    Commented Dec 5, 2013 at 5:38

Trial and Error

I assume you want $x$ to be an integer. You might want $x+7$ to be a square so that $\sqrt{x+7}\in\mathbb{N}$... $x+7\in\{1,4,9,16,25,36,49,64\dots\}$ and hence $$\begin{align}x&\in\{-6,-3,2,18,29,42,57,\dots\} \end{align}$$

But you want $x+\sqrt{x+7}$ to be a square so look at the corresponding values of it:


One of these is squares, corresponding to $x=42$.

  • 1
    $\begingroup$ thanks this is also very helpful!!! $\endgroup$ Commented Dec 4, 2013 at 19:48
  • 4
    $\begingroup$ 42 is the solution. Why I am not surprised? $\endgroup$ Commented Dec 4, 2013 at 20:20
  • 1
    $\begingroup$ $x = -3$ gives $x + \sqrt{x + 7} = -1$, not 1. $\endgroup$
    – hunse
    Commented Dec 5, 2013 at 16:14
  • $\begingroup$ @hunse Thank you. Edited. $\endgroup$ Commented Dec 5, 2013 at 16:51

$x + 7 = ((n^2)-x)^2 = n^4 - 2n^2x + x^2$ which is quadratic equation considering x. Can you go further?

  • $\begingroup$ This leads to $(x-n^2)^2=x+7$. Where does one go now? $\endgroup$ Commented Dec 4, 2013 at 13:39
  • $\begingroup$ @JpMcCarthy, wrong way! $x = \frac{(2n^2 + 1)\pm \sqrt{4n^4+4n^2+1+28-4n^4 }}{2}$, but it seems that my guess was also wrong, as I can't imagine what to do with the thing under the root. I only know that it should be a square of some odd integer. Sorry, guys. Besides, you have a nice solution up there. $\endgroup$
    – tenpercent
    Commented Dec 4, 2013 at 13:52
  • $\begingroup$ @JpMcCarthy To be more accurate, $(2n)^2 + 29 = k^2$ implies that $2n \leq 29 $ and $n \leq 14$. There are only 14 such positive integers that $n \leq 14$, so we can check if any of them is the solution to the problem. Or we could try to solve $4n^2 + 1 = k^2 \mod 14 $, which leaves us less variants to consider. $\endgroup$
    – tenpercent
    Commented Dec 4, 2013 at 14:17
  • $\begingroup$ Begs the question why did this get devoted? $\endgroup$ Commented Dec 4, 2013 at 15:33
  • 1
    $\begingroup$ @JpMcCarthy, because the upvoted hint is awesome. $\endgroup$
    – tenpercent
    Commented Dec 4, 2013 at 16:06

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


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


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


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$.


We want to find $a \in \mathbb{N}$ such that $$a = \sqrt{x + \sqrt{x + 7}}.$$ Also implicit in the question was that $x \in \mathbb{N}$, but that wasn't stated, only implied by the statement that $x$ is two-digit.

Let $n = \sqrt{x + 7}$. Then $x = n^2 - 7$. Substituting into the original equation: $$\begin{align} a = & \sqrt{n^2 + n - 7}\\ 0 = & n^2 + n - 7 - a^2 \end{align}$$ Solving for $n$: $$n = -\frac{1}{2} \pm \frac{1}{2}\sqrt{4 a^2 + 29}$$ Plugging any $a > 1$ into this equation will yield a valid value for $n$ and therefore $x$, but they will generally be non-integer.

For $n$ and therefore $x$ to be integer, $4 a^2 + 29$ must be a perfect square, and furthermore an odd perfect square. We can rewrite this as $(2a)^2 + 29 = b^2$, where $a, b \in \mathbb{N}$, which means two perfect squares must have a difference of 29, and this only occurs for $(2a)^2 = 14^2$ and $b^2 = 15^2$. Therefore, solving backwards, $a = 7$, $n = 7$, and $x = 42$.

  • $\begingroup$ Well, $x=42$ would be more true. ;-) $\endgroup$
    – egreg
    Commented Dec 4, 2013 at 21:48
  • $\begingroup$ @egreg: Thanks! $\endgroup$
    – hunse
    Commented Dec 4, 2013 at 23:19
  • $\begingroup$ @RossMillikan: $x = -3$ results in $n = 2$ and $a = \sqrt{-1}$, which does satisfy $0 = n^2 + n - 7 - a^2$, but breaks the restriction that $a$ is a natural number (positive integer). Thanks for pointing it out, though. $\endgroup$
    – hunse
    Commented Dec 4, 2013 at 23:23

just to it by guesswork , x=42

  • 5
    $\begingroup$ guesswork isn't good in mathematics $\endgroup$ Commented Dec 4, 2013 at 13:11
  • 8
    $\begingroup$ @9abab Au contraire. Guesswork is very good in mathematics... you just have to be careful. If the question was to find all $x$ guesswork is not OK... how would you know there are not more solutions. Here we are only looking for one and 42 is fine. Perhaps Sahil can explain how $x=42$ was guessed... by a trial and error. $\endgroup$ Commented Dec 4, 2013 at 13:22
  • 3
    $\begingroup$ Quite some mathematical problems came to a solution when someone started guessing. $\endgroup$
    – drhab
    Commented Dec 4, 2013 at 13:42
  • $\begingroup$ The difference here is between random guesses and educated guesses. Random guesses are rarely good. But educated guesses can help a lot, but require a thorough understanding, experience and intuition. $\endgroup$
    – Turion
    Commented Dec 4, 2013 at 14:07
  • $\begingroup$ Wrong again. Random guesses is precisely the basis of a revolution that has happened in mathematics that has solved many problems already. Educated guesses are just an accident, getting lucky of having a problem so simple that it allows some simplification, a rarity in the sea of all mathematical problems. $\endgroup$
    – OR.
    Commented Dec 4, 2013 at 15:56

You're mentioning that $x$ should have two digits. Write a small program that runs through all integers from 10 to 99, computes your expression and finds that 42 is the only solution.

Example in Python:

>>> import math
>>> for x in range(10,100):
...     n = math.sqrt(x + math.sqrt(x + 7))
...     if float(int(n)) == n:
...             print("The solution is {0}".format(x))
The solution is 42
  • $\begingroup$ Pragmatic, but probably not what Geirg's teacher is looking for... $\endgroup$
    – fluffy
    Commented Dec 5, 2013 at 6:59
  • $\begingroup$ @fluffy, what makes you think so? I think I'm the only one who used the fact that $x$ should have two digits, and it's a legitimate information to use. $\endgroup$
    – Turion
    Commented Dec 5, 2013 at 12:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .