vb用近似公式e^x的值,要求计算到展开式中的前500项

如题所述

使用常规的数据类型,只能到100多项,500多项有点困难,超过100多位数的处理有点麻烦。


Private Sub Command1_Click()
Print f(2)
End Sub
Public Function f(x As Single) As Single
Dim i As Integer, s As Double
For i = 1 To 500
s = s + x ^ i / h(i)
Next
End Function
Public Function h(x As Integer) As Double
If x > 1 Then
h = x * h(x - 1)
Else
h = 1
End If
End Function
我的只能算到170多项就开始溢出错误了!

温馨提示:答案为网友推荐,仅供参考
相似回答