Skip to main content
Tuesday (24.11.2026) at 20:00: ALGOR Contest: Round #4 (Special Challenge) starts!

~/algor $ cat problems/for-e-sonini-hisoblash

Computing the number e

Medium 1000 ms 64 MB 46%
Share

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$$

Convergence of the series for Euler's number

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

Sign in to submit a solution

Signing up is free and takes a minute.