# How to evaluate the limit of a function consists of Range

I would like to evaluate the limit: $$\sqrt{1+\sqrt{2+\sqrt{3+\sqrt{4+\sqrt{5+\cdots}}}}}$$ Therefore, I write the following function of n:

g[p_, n_] := Sqrt[p] + n;
f[n_] := Sqrt[Fold[g, 0, Reverse@Range@n]],


and evaluate the limit:

Limit[f[n], n -> Infinity].


But Mathematica said:

Range::range: "Range specification in Range[n] does not have appropriate bounds."


Is there something wrong with my code? How can i make this work? Thanks in advance.

• (1) Limit operates on continuous parameters only. It sometimes "works" for functions of a discrete parameter (sequences) but only if they accidently have definitions in terms of a continuous parameter that give the same limiting behavior. – Daniel Lichtblau Nov 27 '15 at 16:17
• (2) Limit has absolutely no capability to handle what amounts to a program, e.g. f[n_]:=... where the ... part is computed by an iterative algorithm (e.g. using a function such as Fold or Nest). – Daniel Lichtblau Nov 27 '15 at 16:19
• (3) I would surmise this is a difficult problem to do using Mathematica other than in an approximation approach. So it is an interesting question. – Daniel Lichtblau Nov 27 '15 at 16:28
• @DanielLichtblau Thanks，I finally know why it is difficult to calculate this limit of the sequence in Mathematica. – robit Nov 29 '15 at 9:00

You can see that:

Fold[Sqrt[#1 + #2] &, 0, Reverse@Range] DiscretePlot[Fold[Sqrt[#1 + #2] &, 0, Reverse@Range[i]], {i, 50}] • I understand your idea is to calculation the function for large n instead of evaluate the limit itself. Does that mean there is no way to evaluate this limit directly in Mathematica? – robit Nov 27 '15 at 7:32
• @robit Well, it's the Kasner number. See this. – Dr. belisarius Nov 27 '15 at 7:40
• @robit You can find more info on the convergence of those series here ... those problems were Ramanujan's pets – Dr. belisarius Nov 27 '15 at 7:44
• Thanks, I get it. These are very good references for sequences like this! – robit Nov 27 '15 at 8:08