-->
当前位置:首页 > 题库

PROGRAMMING:Finding the sum of formulas [2]

Luz5年前 (2021-05-10)题库367
Define the function main (), input positive integer n, calculate and output the value of the following formula. The function f (n) is required to calculate n + (n + 1) +... + (2n-1), and the return value type of the function is double.
$$sum=1+\frac{1}{2+3}+\frac{1}{3+4+5}+......+\frac{1}{n+(n+1)+(n+2)+...+(2n-1)}$$
###Input format:
The input gives a positive integer n in one line.
###Output format:
In one line, output the value s of partial sum in the format of "sum = s" to six decimal places. Please note that there is a space on the left and right of the equal sign. The calculation results should not exceed the double precision range.
###Input example:
Here is a set of inputs. For example:
```in
three
```
###Output example:
The corresponding output is given here. For example:
```out
sum = 1.283333
```







answer:If there is no answer, please comment