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

PROGRAMMING:Finding the sum of formulas [4]

Luz5年前 (2021-05-10)题库409
Define the function main (), input positive integer n, calculate and output the value of the following formula. Call function fact (n) to calculate n, The return value type of the function is double.
$$sum=\frac{1}{2!}+\ frac{2}{3!}+......+\ frac{n}{(n+1)!}$$
###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 = 0.958333
```







answer:If there is no answer, please comment