#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  n \,n\,, compute the corresponding value of  e \,e\,, rounded to  8 \,8\, decimal places.

Input Format

Input a positive integer  n\,n.

Output Format

Output the approximate value of  e \,e\,.

Sample Input

13

Sample Output

2.71828183

Hint

  1. The concept of factorial

4!=4×3×2×1=244!=4\times 3\times 2\times 1=24

$5!=5\times (4\times 3\times 2\times 1)=5\times 4!=5\times 24=120$

n!n! is called the factorial of nn.

$n!=n\times(n-1)\times(n-2)\times\cdots\times 3\times 2\times 1=n\times(n-1)!$

In particular, we define 0!=10!=1.

  1. About the value ranges
  • intint: −2×109∼2×109-2\times 10^9\sim 2\times 10^9

  • long longlong\ long: −2×1018∼2×1018-2\times 10^{18}\sim 2\times 10^{18}

  • doubledouble: −2×10308∼2×10308-2\times 10^{308}\sim 2\times 10^{308}; 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}$