# Continued fraction of $\gamma+1$ using recursion

Number $\gamma,$ the Euler-Mascheroni constant, is defined as the value of $$\gamma = \lim_{n\to\infty} \sum_{k=1}^n \frac{1}{k} - \ln(n).$$

We know that $$\lim_{n\to\infty} \frac{n}{\pi(n)}-\ln(n)=-1,$$ as seen here. Here $\pi(n)$ is the number of primes smaller or equal to $n.$

Thus $$\lim_{n\to\infty} \sum_{k=1}^n \frac{1}{k} - \frac{n}{\pi(n)} = \gamma + 1.$$

Now $$\lim_{n\to\infty} \sum_{k=1}^n \frac{1}{k} - \frac{n}{\pi(n)} =\lim_{n\to\infty} -\frac{n-H_n \pi(n)}{\pi(n)}$$ and $\lfloor \gamma + 1 \rfloor = 1$.

Thus the second coefficient in the continued fraction of $\gamma+1$ is $$\lfloor \lim_{n\to\infty} 1/\left(\frac{n-H_n \pi(n)}{\pi(n)}-1\right) \rfloor = \lfloor \lim_{n\to\infty} -\frac{\pi(n)}{n+\pi(n)-H_n \pi(n)} \rfloor = \lfloor \lim_{n\to\infty} \frac{1}{-n/\pi(n)-1+H_n} \rfloor = \lfloor \frac{1}{\gamma} \rfloor = 1.$$

After a few more iterations it becomes clear that the functions of $\pi(n), H_n$ and so on are of the form $$-\frac{a n + c \pi(n) - a H_n \pi(n)}{b n + d \pi(n) - b H_n \pi(n)}.$$

If the corresponding floor of the limit of this is $v_m,$ (if this is mth iteration) the following value is calculated using the function $$1/(-\frac{a n + c \pi(n) - a H_n \pi(n)}{b n + d \pi(n) - b H_n \pi(n)}-v_m).$$ From this we get the following update rules for the coefficients of the previous limit:

\begin{array}{l} a\rightarrow b \\ b \rightarrow a+b v_m \\ c \rightarrow d \\ d \rightarrow c+d v_m\\ v_{m} \rightarrow v_{m+1} = \lfloor -\frac{d-b(1+\gamma)}{a-c+a \gamma + (b-d+ b\gamma) v_m} \rfloor \end{array}

Usage example: The $0$th iteration has the coefficients $(a,b,c,d,v_0) = (1, 0, 0, 1, 1)$ Thus the $1$st iteration would be $(0, 1, 1, 1, 1)$ and the $2$nd $(1, 1, 1, 2, 1)$ and the $3$rd: $(1, 2, 2, 3, 2)$. So the continued fraction of $\gamma+1$ starts as $(1;1,1,2...).$

Question: How do we know if we have reached the end of the fraction? Would it require that $$\frac{d-b(1+\gamma)}{a-c+a \gamma + (b-d+ b\gamma) v_m} < 1 ?$$ Can this happen?

Edit: I noticed this (can you tell I am not that well versed with continued fractions?) If $\gamma+1$ has continued fraction $[v_1;v_2,v_3\ldots v_m \ldots]$, the fraction $\frac{c+d(1+v_m)}{a+b(1+v_m)}$ has continued fraction $[v_1;v_2\ldots v_m+1]$

• Why is the prime counting function relevant here? – quid Aug 9 '13 at 21:42
• @quid I don't know? I just saw that it fitted and gave this rather simple looking recursion. – Valtteri Aug 12 '13 at 11:44
• You are no doubt aware that it is generally believed that $\gamma$ is irrational, which implies that the continued fraction doesn't have an end to reach. – Gerry Myerson Aug 12 '13 at 12:42
• @GerryMyerson Yes, I am. So...can it be proven from this? – Valtteri Aug 12 '13 at 13:17
• I doubt it, but I guess it's worth a try. – Gerry Myerson Aug 13 '13 at 0:05