作业帮 > 综合 > 作业

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

来源:学生作业帮 编辑:大师作文网作业帮 分类:综合作业 时间:2024/11/14 23:21:57
.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 Su