By M.C. Pinto, UNILA Brazil
The method of periodic continued fractions is one of the many ways to calculate the square root of a natural number. This method uses as denominator a repetition for fractions. This repetition can be done by a fixed number of times.
For example, by repeating 2 times the continued fraction to calculate the square root of 2, we have the following equation.
Your task is to calculate the approximate value of square root of 2 given the number N of repetitions.
The input is a natural number N (0 ≤ N ≤ 100) that indicates the quantity of denominator repetitions in the continued fraction.
The output is the approximate value of the square root with 10 decimal places.
Input Samples | Output Samples |
0 |
1.0000000000 |
1 |
1.5000000000 |
5 |
1.4142857143 |