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

PROGRAMMING:Finding the sum of formulas [3]

Luz5年前 (2021-05-10)题库391
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{2+3}{2}+\frac{3+4+5}{3}+......+\frac{n+(n+1)+(n+2)+...+(2n-1)}{n}$$
###Input format:
The input gives a positive integer n on a 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:
```in
three
```
###Output example:
```out
sum = 7.500000
```







answer:If there is no answer, please comment