Private Sub Command1_Click()
'n自己填,我这里填的6
MsgBox test1(6) & " = " & test(6)
End Sub
'你要的算法主要是这个。。。
Private Function test(ByVal n As Long) As Double
If n > 0 Then
test = test(n - 1) + 1 / (n + n + 1)
Else
test = 1
End If
End Function
'显示拼接的公式,可以忽略
Private Function test1(ByVal n As Long) As String
If n > 0 Then
test1 = test1(n - 1) & " + 1 / (" & n & " + " & n + 1 & ")"
Else
test1 = "1"
End If
End Function