vb编写程序,计算表达式的值 1+x/2!+x^2/4!+x^3/6!+.x^n(2n)!

问题描述:

vb编写程序,计算表达式的值 1+x/2!+x^2/4!+x^3/6!+.x^n(2n)!

Private Sub Command1_Click()
Dim n As Long,x As Single,y As Single,y2 As Single,sum As Single
x = Val(InputBox("请输入一个数值:","输入","0.1"))
n = 1:y = 1:sum = 1
Do
y2 = y :y = y * x / n / (n + 1) :sum = sum + y :n = n + 2
Loop Until Abs(y2 - y) Print sum
End Sub