求'Vb代码,急,1-1/2+1/3-1/4+1/5-1/6+.1/(n-1)-1/n求n=100的时候的和,

来源:学生作业帮助网 编辑:作业帮 时间:2024/11/05 17:25:28

求'Vb代码,急,1-1/2+1/3-1/4+1/5-1/6+.1/(n-1)-1/n求n=100的时候的和,
求'Vb代码,急,1-1/2+1/3-1/4+1/5-1/6+.1/(n-1)-1/n求n=100的时候的和,

求'Vb代码,急,1-1/2+1/3-1/4+1/5-1/6+.1/(n-1)-1/n求n=100的时候的和,
Private Sub Command1_Click()
Dim d As Double, s As Double
d = 1
For i = 1 To 100
If i Mod 2 0 Then
s = s + d / i
Else
s = s - d / i
End If
Next

End Sub