#100Medium
Exponential from a series
Time: 1 s · Memory: 256 MB
- Functions
Statement
Write a function Exp1(x, ε) that approximates with the Taylor series:
Add the terms one by one and stop at the first term whose absolute value is less than — that term itself is not added.
Input format
A single line with and : has one digit after the decimal point (), is an integer (), .
Output format
A single number — the computed sum with exactly 6 digits after the decimal point.
Examples
Input
1.0 6
Output
2.718282
Input
-1.0 3
Output
0.368056
Note
Get each term from the previous one: — there is no need to compute the factorial and the power separately, they grow huge quickly.
