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

来源:学生作业帮助网 编辑:作业帮 时间:2024/10/03 04:14:51
VB语言题目:计算y=2/3!+5/6!+8/9!
xAK0ǿEZn(Sۂn+ M.b6-<͓Z-:xBlសVo<պ|sh@3GP 1kz7DR!y.I] rX)p$ບ"Lh7n㙢809$0~0#YLW-Y[*Y&7)[M,1gв$/!PY0lw$`۶%z_Ɵ6an_>8b

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