The Taylor series of the function is
Note that this series has an infinite number of terms. However, for any we can get an approximation of by adding some of the first terms of the series (of course, the more terms, the better the result). In particular, chosing gives us a method to compute :
Write a program that, for every given natural number , prints the approximation of that we get by adding the first terms of the series above.
Input consists of several natural numbers between 0 and 20.
For every given , print with 10 digits after the decimal point the approximation of that we get by adding the first terms of the series above.
Because of overflow reasons, do all the computations for this exercise using real numbers.
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.