#t475. 求 e 的近似值
求 e 的近似值
Approximating the Constant e
Problem Description
The natural constant $\,e=\frac{1}{0!}+\frac{1}{1!}+\frac{1}{2!}+\frac{1}{3!}\cdots+\frac{1}{n!}\,(0\le n \le 50, where 0!=1 by convention)$. Given a positive integer , compute the corresponding value of , rounded to decimal places.
Input Format
Input a positive integer .
Output Format
Output the approximate value of .
Sample Input
13
Sample Output
2.71828183
Hint
- The concept of factorial
$5!=5\times (4\times 3\times 2\times 1)=5\times 4!=5\times 24=120$
is called the factorial of .
$n!=n\times(n-1)\times(n-2)\times\cdots\times 3\times 2\times 1=n\times(n-1)!$
In particular, we define .
- About the value ranges
-
:
-
:
-
: ; however, many numbers in this range cannot be represented exactly, and a number that cannot be represented is replaced by the representable number closest to it.
-
$50!=3.0414093201713378043612608166065\times 10^{64}$