#B2069. Sum of a Modified Fibonacci Fraction Sequence
Sum of a Modified Fibonacci Fraction Sequence
Sum of a Modified Fibonacci Fraction Sequence
Consider a sequence of fractions defined by the following recurrence relations:
\(q_1 = 2, \; p_1 = 1\), and for \(i \ge 1\):
\(q_{i+1} = q_i + p_i\) and \(p_{i+1} = q_i\).
Thus, the sequence is given by:
\[ \frac{q_1}{p_1}, \; \frac{q_2}{p_2}, \; \frac{q_3}{p_3}, \; \ldots \] \]
For example, the first 6 terms of this sequence are:
\(\frac{2}{1}, \; \frac{3}{2}, \; \frac{5}{3}, \; \frac{8}{5}, \; \frac{13}{8}, \; \frac{21}{13}\)
Given an integer n, your task is to compute the sum of the first n terms of this sequence and print the result rounded to 4 decimal places.
inputFormat
The input consists of a single integer n (\(n \ge 1\)) representing the number of terms in the sequence.
outputFormat
Output the sum of the first n terms of the sequence, rounded to 4 decimal places.
sample
1
2.0000