~/algor $ cat problems/for-ikkining-ildiziga-yaqinlashish
Approaching the square root of two
Medium
1000 ms
64 MB
45%
A positive integer $n$ is given. Compute the first $n$ terms of a sequence converging to $\sqrt{2}$ by the rule:
$$x_{1} = 1, \qquad x_{k+1} = \frac{x_{k} + 2}{x_{k} + 1}$$
Input
One positive integer $n$.
Output
One line with $n$ numbers separated by spaces: $x_{1}, x_{2}, \dots, x_{n}$, each with exactly 5 digits after the decimal point (for example, 1.00000 1.50000 1.40000 1.41667).
Note
$1 \le n \le 30$
Examples
Input #1
4
Output #1
1.00000 1.50000 1.40000 1.41667
Input #2
6
Output #2
1.00000 1.50000 1.40000 1.41667 1.41379 1.41429