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

PROGRAMMING:Calculate the approximate value of E

Luz5年前 (2021-05-10)题库421
The exact value of E is equal to the sum of the following infinite sequences.
$$ \frac{1}{0!} +\ frac{1}{1!}+\ frac{1}{2!}+\ frac{1}{3!}+\ frac{1}{4!}+\ frac{1}{5!}+...$$
$$e0 = \frac{1}{0!}$$
$$e1 = \frac{1}{0!} +\ frac{1}{1!} $$
$$e2 = \frac{1}{0!} +\ frac{1}{1!}+\ frac{1}{2!}$$
$$e3 = \frac{1}{0!} +\ frac{1}{1!}+\ frac{1}{2!}+\ frac{1}{3!}$$
$$e4 = \frac{1}{0!} +\ frac{1}{1!}+\ frac{1}{2!}+\ frac{1}{3!}+\ frac{1}{4!}$$
Enter a floating-point error to calculate the approximate value of constant e with error in the range of error. By generating a series of approximations E0, E1, E2,..., until the error between the current approximation and the previous approximation is not greater than error.
###Input format:
Enter a floating-point error to indicate the error
###Output format:
Approximate value of output e
###Input sample 1:
Here is a set of inputs. For example:
```in
zero point zero one
```
###Output sample 1:
The corresponding output is given here. For example:
```out
two point seven one six six six six six six six six six six six six six three
```
###Input sample 2:
Here is a set of inputs. For example:
```in
zero point zero zero zero zero zero zero zero zero one
```
###Output sample 2:
The corresponding output is given here. For example:
```out
two point seven one eight two eight one eight two eight four four six seven five nine four
```







answer:If there is no answer, please comment