作业帮 > 综合 > 作业

vb简单编程:求自然对数e的近似值,当任意项的值小于10^(-4)是结束运算.用公式e=1+1/1!+1/2!+1/n

来源:学生作业帮 编辑:神马作文网作业帮 分类:综合作业 时间:2024/11/11 04:32:57
vb简单编程:求自然对数e的近似值,当任意项的值小于10^(-4)是结束运算.用公式e=1+1/1!+1/2!+1/n
Private Sub Command1_Click()
Dim a#,s#,e%
a = 1
s = 1
Do
s = s * a
t = 1 / s
e = e + t
a = a + 1
Loop While s > 10000
Print "e="; e
End Sub
错在哪?求分析错误程序
vb简单编程:求自然对数e的近似值,当任意项的值小于10^(-4)是结束运算.用公式e=1+1/1!+1/2!+1/n
Dim a As Double
Dim s As Double
Dim e As Single
Dim t As Single
a = 1
s = 1
e = 1
Do While 1 / s >= 10 ^ (-0.4)
s = s * a
t = 1 / s
e = e + t
a = a + 1
Loop
Print "e="; e