泰勒公式求 e的x次方

# _*_ coding:utf-8 _*_

import numpy as np

def jie(i):
    s = 1
    for j in range(1, i+1):
        s = s * j
    return s


x = int(input("请输入x="))
n = int(input("请输入n="))
s = 1
for i in range(1, n+1):
    s = s+np.power(x, i)/jie(i)
print(s)

e^x=1+x+x^2/2!+x^3/3!+.....+x^n/n!

input()默认输入的是字符,需要转化否则出错

你可能感兴趣的:(数学)