输入X,利用公式e^x=1+x+x^2/2!+x^3/3!+…求e^x的近似值,直到最后一项绝对值小于-10^-6用VB (Microsoft Visual Studio 2005)这个软件

问题描述:

输入X,利用公式e^x=1+x+x^2/2!+x^3/3!+…求e^x的近似值,直到最后一项绝对值小于-10^-6
用VB (Microsoft Visual Studio 2005)这个软件

Dim a As Long, s As Long, D As String, e As Long, b As Long
D = 1: a = 1: s = 1
Do Until e > 6
D = ((2 * a) / (2 * a + 1)) * ((2 * a) / (2 * a - 1))
s = s * D
a = a + 1
b = 2 * s
e = Len(b) - InStr(b, ".")
Debug.Print D
DoEvents
Loop
Print b