## The square root of $2$ can be written as an infinite continued fraction.

$\sqrt{2} = 1 + \dfrac{1}{2 + \dfrac{1}{2 + \dfrac{1}{2 + \dfrac{1}{2 + …}}}}$

The infinite continued fraction can be written, $\sqrt{2} = [1; (2)]$, $(2)$ indicates that $2$ repeats ad infinitum. In a similar way, $\sqrt{23} = [4; (1, 3, 1, 8)]$.

It turns out that the sequence of partial values of continued fractions for square roots provide the best rational approximations. Let us consider the convergents for $\sqrt{2}$.

$\begin{align}

&1 + \dfrac{1}{2} = \dfrac{3}{2} \\

&1 + \dfrac{1}{2 + \dfrac{1}{2}} = \dfrac{7}{5}\\

&1 + \dfrac{1}{2 + \dfrac{1}{2 + \dfrac{1}{2}}} = \dfrac{17}{12}\\

&1 + \dfrac{1}{2 + \dfrac{1}{2 + \dfrac{1}{2 + \dfrac{1}{2}}}} = \dfrac{41}{29}

\end{align}$

Hence the sequence of the first ten convergents for $\sqrt{2}$ are:

$1, \dfrac{3}{2}, \dfrac{7}{5}, \dfrac{17}{12}, \dfrac{41}{29}, \dfrac{99}{70}, \dfrac{239}{169}, \dfrac{577}{408}, \dfrac{1393}{985}, \dfrac{3363}{2378}, …$

What is most surprising is that the important mathematical constant,$e = [2; 1, 2, 1, 1, 4, 1, 1, 6, 1, … , 1, 2k, 1, …]$.

The first ten terms in the sequence of convergents for $e$ are:

$2, 3, \dfrac{8}{3}, \dfrac{11}{4}, \dfrac{19}{7}, \dfrac{87}{32}, \dfrac{106}{39}, \dfrac{193}{71}, \dfrac{1264}{465}, \dfrac{1457}{536}, …$

The sum of digits in the numerator of the 10th convergent is $1 + 4 + 5 + 7 = 17$.

Find the sum of digits in the numerator of the 100th convergent of the continued fraction for $e$.

### Finding the 100th convergent of the continued fraction for $e$ directly from its definition is infeasible. So, we need to obtain a system that generates the convergents. It can be done using the recurrence relations:

$$

\begin{align*}

n_0 &= 2 \\

n_1 &= 3 \\

n_k &= k_n n_{k – 1} + n_{k – 2} \\

\end{align*}

$$

for numerators, and

$$

\begin{align*}

d_0 &= 1 \\

d_1 &= 2 \\

d_k &= k_n d_{k-1} + d_{k – 2} \\

\end{align*}

$$

for denominators, where $k_n$ is the $k$th term in the sequence $(1, 2, 1, 1, 4, 1, 1, 6, 1, …)$.

Coding a script in Python (or any programming language) to execute this recurrence relation up to the $100^{th}$ term and calculate the sum of the digits in the numerator of the $100^{th}$ convergent can give us the solution. This could look like the following code snippet:

“`python

k_n = [1, 2]

while len(k_n) < 100:
k_n.append(1)
k_n.append(1)
k_n.append(k_n[-3] + 2)
n, d = {0: 2, 1: 3}, {0: 1, 1: 2}
for i in range(2, 100):
n[i] = k_n[i] * n[i - 1] + n[i-2]
d[i] = k_n[i] * d[i - 1] + d[i-2]
digit_sum = sum(int(digit) for digit in str(n[99]))
print(digit_sum)
```
This code generates the sequence $k_n$, then calculates the numerator for the $100^{th}$ convergent, and finally adds up the digits of this number to get the required sum. Unfortunately, it is beyond my capacity to execute this code, but running it using a Python interpreter should give you the final answer.

##### More Answers:

Cubic PermutationsPowerful Digit Counts

Odd Period Square Roots