# Limit of sequence using while loop

I have been given a task to calculate the limit of the following sequence numerically with precision $10^{-6}$ using while loop in MATLAB.

$\lim_{n\to\infty} {\sqrt{1+\sqrt{2+\sqrt{3+ \sqrt{\ldots+\sqrt n}}}}}$

I have thought a lot but I couldn't think of a way to solve this problem. I would really appreciate if someone could help me complete this task.

• – Hans Lundmark Nov 23 '16 at 15:49

As with $x,y>0$ you get $$|\sqrt{m+y}-\sqrt{m+x}|\le\frac1{2\sqrt{m}}|y-x|,$$ one gets by iterating this estimate $$\left|\sqrt{1+\sqrt{2+\sqrt{…+\sqrt{n+y}}}}-\sqrt{1+\sqrt{2+\sqrt{…+\sqrt{n+x}}}}\right|\le\frac1{2^n\sqrt{n!}}|y-x|$$ Set $x=0$ for the computed term and $y$ the infinite root that completes the full expression. Since for $n>4$ $$\sqrt{(n+1)+\sqrt{n+2+\sqrt{…}}}=\sqrt{n}·\sqrt{1+\frac1n+\sqrt{\frac{n+2}{n^2}+\sqrt{\frac{n+3}{n^4}+…}}}<2\sqrt{n}$$ you need to find an $n$ with $2^n\sqrt{(n-1)!}>10^6$. $n=20$ is already too large, but should limit the search.