vb简单编程:求自然对数e的近似值,当任意项的值小于10^(-4)是结束运算.用公式e=1+1/1!+1/2!+1/n
问题描述:
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
错在哪?求分析错误程序
答
Dim a As DoubleDim s As DoubleDim e As SingleDim t As Singlea = 1s = 1e = 1Do While 1 / s >= 10 ^ (-0.4) s = s * a t = 1 / s e = e + t a = a + 1LoopPrint "e="; e