Hide

# Problem EEuler's Number

Euler’s number (you may know it better as just $e$) has a special place in mathematics. You may have encountered $e$ in calculus or economics (for computing compound interest), or perhaps as the base of the natural logarithm, $\ln {x}$, on your calculator.

While $e$ can be calculated as a limit, there is a good approximation that can be made using discrete mathematics. The formula for $e$ is:

\begin{align*} e & = \displaystyle \sum _{i=0}^ n\dfrac {1}{i!}\\ & = \dfrac {1}{0!} +\dfrac {1}{1!} +\dfrac {1}{2!}+\dfrac {1}{3!}+\dfrac {1}{4!} + \cdots \\ \end{align*}

Note that $0! = 1$. Now as $n$ approaches $\infty$, the series converges to $e$. When $n$ is any positive constant, the formula serves as an approximation of the actual value of $e$. (For example, at $n=10$ the approximation is already accurate to $7$ decimals.)

You will be given a single input, a value of $n$, and your job is to compute the approximation of $e$ for that value of $n$.

## Input

A single integer $n$, ranging from $0$ to $10\, 000$.

## Output

A single real number – the approximation of $e$ computed by the formula with the given $n$. All output must be accurate to an absolute or relative error of at most $10^{-12}$.

Sample Input 1 Sample Output 1
3

2.6666666666666665

Sample Input 2 Sample Output 2
15

2.718281828458995

CPU Time limit 1 second
Memory limit 1024 MB
{"ft_lang_label":"__label__en","ft_lang_prob":0.8455051,"math_prob":0.9999037,"size":1339,"snap":"2022-27-2022-33","text_gpt3_token_len":409,"char_repetition_ratio":0.12509364,"word_repetition_ratio":0.0,"special_character_ratio":0.34279314,"punctuation_ratio":0.11940298,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9999263,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2022-07-05T06:35:24Z\",\"WARC-Record-ID\":\"<urn:uuid:f05d516b-6d16-4088-b93e-924ab1eda297>\",\"Content-Length\":\"23539\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:6732fe26-108a-4929-ad5a-a23d550858e0>\",\"WARC-Concurrent-To\":\"<urn:uuid:35429b35-db52-4646-b7cd-d64f304b49a0>\",\"WARC-IP-Address\":\"104.26.11.67\",\"WARC-Target-URI\":\"https://ncna18.kattis.com/contests/ncna18/problems/eulersnumber\",\"WARC-Payload-Digest\":\"sha1:2YT2GUA2BPM5QQV6CW4VL6XLTZWTDLNH\",\"WARC-Block-Digest\":\"sha1:T7XCUDX2MSWVSS223LEQVK6NNQ72IQ67\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2022/CC-MAIN-2022-27/CC-MAIN-2022-27_segments_1656104514861.81_warc_CC-MAIN-20220705053147-20220705083147-00689.warc.gz\"}"}