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

PROGRAMMING:Finding series

Luz5年前 (2021-05-10)题库403
Input a positive integer n, calculate and output the sum of the first n terms of S.
S = 1 - 1/2 + 1/3 - 1/4 + 1/5 - 1/6 + ……
###Input format:
Enter a positive integer n.
###Output format:
The output of the program is shown in the output example.
###Input sample 1:
Here is a set of inputs. For example:
```in
five
```
###Output sample 1:
The corresponding output is given here. For example:
```out
n = 5
S = 0.783333
```
###Input sample 2:
Here is a set of inputs. For example:
```in
one
```
###Output sample 2:
The corresponding output is given here. For example:
```out
n = 1
S = 1.0000003
```
###Input sample 3:
Here is a set of inputs. For example:
```in
nine hundred and ninety-nine
```
###Output sample 3:
The corresponding output is given here. For example:
```out
n = 999
S = 0.693647
```






answer:If there is no answer, please comment