We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.

- All Contests
- ProjectEuler+
- Project Euler #57: Square root convergents

# Project Euler #57: Square root convergents

# Project Euler #57: Square root convergents

Contest ends in

_{This problem is a programming version of Problem 57 from projecteuler.net}

It is possible to show that the square root of two can be expressed as an infinite continued fraction.

By expanding this for the first four iterations, we get:

The next three expansions are , , and , but the eighth expansion, , is the first example where the number of digits in the numerator exceeds the number of digits in the denominator.

Given . In the first expansions, print the iteration numbers where the fractions contain a numerator with more digits than denominator.

**Input Format**

Input contains an integer

**Constraints**

**Output Format**

Print the answer corresponding to the test case.

**Sample Input**

```
14
```

**Sample Output**

```
8
13
```