Approximation of e P11916


Statement
 

pdf   zip

The Taylor series of the function exe^{x} is ex=i0xii!.e^{x} = \sum_{i \ge 0} \frac{x^{i}}{i!} \enspace .

Note that this series has an infinite number of terms. However, for any xx we can get an approximation of exe^{x} by adding some of the first terms of the series (of course, the more terms, the better the result). In particular, chosing x=1x = 1 gives us a method to compute e271828182845904523536e \simeq 2'71828182845904523536: e=i01i!.e = \sum_{i \ge 0} \frac{1}{i!} \enspace .

Write a program that, for every given natural number nn, prints the approximation of ee that we get by adding the nn first terms of the series above.

Input

Input consists of several natural numbers nn between 0 and 20.

Output

For every given nn, print with 10 digits after the decimal point the approximation of ee that we get by adding the nn first terms of the series above.

Observation

Because of overflow reasons, do all the computations for this exercise using real numbers.

Public test cases
  • Input

    0
    1
    3
    20
    

    Output

    With 0 term(s) we get 0.0000000000.
    With 1 term(s) we get 1.0000000000.
    With 3 term(s) we get 2.5000000000.
    With 20 term(s) we get 2.7182818285.
    
  • Information
    Author
    Salvador Roura
    Language
    English
    Translator
    Carlos Molina
    Original language
    Catalan
    Other languages
    Catalan
    Official solutions
    C++ Java Python
    User solutions
    C C++ Java JavaScript Python