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

PROGRAMMING:Find the value of E

Luz5年前 (2021-05-10)题库360
###Task description
Use the formula e = 1 + 1 / 1+ 1/2! + 1/3! + ... + 1/n! Ask for E.
###Input format:
The input has only one line, which contains an integer n (2 < = n < = 15), indicating that the E is accumulated to 1 / N!.
###Output format:
The output has only one line, which contains the calculated value of e. it is required to print 10 decimal places.
###Input example:
```in
ten
```
###Output example:
```out
two point seven one eight two eight one eight zero one one
```
###Tips
1. E and N! It is represented by double
2. To output floating-point numbers, double precision numbers, 10 digits after the decimal point, you can use the following form:
printf("%.10f", num);
###Title Source
Note: selected from openjudge website, online address: http://sdau.openjudge.cn/c/014/ .
###Problem analysis:
This problem requires that on the basis of the initial value 1.0 of E, the factorial and one-third of n should be accumulated successively. It's easy to do with loops.







answer:If there is no answer, please comment