1/1*2+1/2*3+1/3*4+...+1/n*(n+1) VBA编程
2个回答
展开全部
Private Sub CommandButton1_Click()
Dim n As Integer, i As Integer, s As Single
n = 1000
For i = 1 To n
s = s + 1 / i / (i + 1)
Next i
Debug.Print "n = "; n, "1/1*2+1/2*3+1/3*4+...+1/n*(n+1) = "; s
End Sub
Dim n As Integer, i As Integer, s As Single
n = 1000
For i = 1 To n
s = s + 1 / i / (i + 1)
Next i
Debug.Print "n = "; n, "1/1*2+1/2*3+1/3*4+...+1/n*(n+1) = "; s
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐于2017-10-29
展开全部
Option ExplicitSub test() MsgBox calc(3)End SubFunction calc(ByVal num As Integer) Dim i As Integer For i = 1 To num If i Mod 2 = 0 Then calc = calc - i Else calc = calc + i End If Next iEnd Function
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询