VB语言题目:计算y=2/3!+5/6!+8/9!

来源:学生作业帮助网 编辑:作业帮 时间:2024/05/03 17:06:15
VB语言题目:计算y=2/3!+5/6!+8/9!

VB语言题目:计算y=2/3!+5/6!+8/9!
VB语言题目:计算y=2/3!+5/6!+8/9!

VB语言题目:计算y=2/3!+5/6!+8/9!
Private Sub Command1_Click()
  Dim I As Integer, N As Double
  N = 0
  For I = 2 To 8 Step 3
    N = N + I / (Factorial(I + 1))
  Next
  Print N
End Sub
Function Factorial(X As Double) As Double
  If X = 1 Then
    Factorial = 1
  Else
    Factorial = X * Factorial(X - 1)
  End If
End Function