.VB中:对于X值,求e^x=1+x+x^2/2!+x^3/3!+….+x^n/n!+……直到最后一项小于10^-6.界面自己设定.

来源:学生作业帮助网 编辑:六六作业网 时间:2024/11/17 13:36:51
.VB中:对于X值,求e^x=1+x+x^2/2!+x^3/3!+….+x^n/n!+……直到最后一项小于10^-6.界面自己设定..VB中:对于X值,求e^x=1+x+x^2/2!+x^3/3!+…

.VB中:对于X值,求e^x=1+x+x^2/2!+x^3/3!+….+x^n/n!+……直到最后一项小于10^-6.界面自己设定.
.VB中:对于X值,求e^x=1+x+x^2/2!+x^3/3!+….+x^n/n!+……直到最后一项小于10^-6.界面自己设定.

.VB中:对于X值,求e^x=1+x+x^2/2!+x^3/3!+….+x^n/n!+……直到最后一项小于10^-6.界面自己设定.
验证一下,不知道对不
Private Sub Ca()
Dim x As Single
Dim n As Integer
Dim i As Integer
Dim j As Integer
Dim Xn As Single
Dim Nn As Single
Dim Sum As Single
x = InputBox("请输入x的值")
n = 10000
Sum = 1 + x
i = 2
Do
Xn = 1
Nn = 1
For j = 1 To i
Xn = Xn * x
Nn = j * Nn
Next j
Sum = Sum + Xn / Nn
i = i + 1
Loop While (Xn / Nn) < 0.000001
End Sub