~/algor $ cat problems/for-e-sonini-hisoblash
Computing the number e
Medium
1000 ms
64 MB
46%
A positive integer $n$ is given. Approximate the mathematical constant $e \approx 2.718281828$ with the sum:
$$S = 1 + \frac{1}{1!} + \frac{1}{2!} + \frac{1}{3!} + \dots + \frac{1}{n!}, \qquad k! = 1 * 2 * \dots * k$$
Input
One positive integer $n$.
Output
One number — $S$, with exactly 6 digits after the decimal point (for example, 2.000000).
Note
$1 \le n \le 20$
Examples
Input #1
1
Output #1
2.000000
Input #2
3
Output #2
2.666667