1个回答
展开全部
Option Explicit
Private Sub Form_Load()
'窗体自动刷新,以便Print语句显示结果
Me.AutoRedraw = True
Dim e As Double
Dim n As Integer
e = 2#
n = 2
Do While n <= 100
e = e + 1# / Factorial(n)
n = n + 1
Loop
Print e
End Sub
Private Function Factorial(ByVal n As Integer) As Double
Dim f As Double
Dim k As Integer
f = 1
For k = 1 To n
f = f * k
Next
Factorial = f
End Function
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询