All problems
Taylor Coefficients of Exponential
Problem
Return the Taylor coefficients of e^x expanded about 0 (Maclaurin coefficients) up to and including degree n.
The coefficient of x^k is 1 / k!, so the result has n + 1 entries starting with 1.0 for k = 0.
Hint
Build the running factorial iteratively instead of importing math.factorial.
Test cases
case 1
in: [3]
expected: [1,1,0.5,0.16666666666666666]
case 2
in: [0]
expected: [1]
case 3
in: [1]
expected: [1,1]
case 4
in: [5]
expected: [1,1,0.5,0.16666666666666666,0.041666666666666664,0.008333333333333333]
Starter codePython
def taylor_coeffs_exp(n):
# Return n + 1 coefficients
# Your code here
pass4 test cases · run your code against them in the editor