如何用python 3.5用连分数计算欧拉数e的值

0
我需要输入一个n来确定迭代次数,下面是我写的代码,但是明显是错误的
n=int(input('Enter the number of iteration:'))
a=1
b=a+1
term=0 #remainder part of value e
approx=2 #integer part of value e
while b<=n:
term=1/(1+(1/b))
a=a+1
b=a+(a/(a+1))

approx=approx+term
print('The approximation of e is:'+str(approx))
已邀请:

要回复问题请先登录注册