计算机编程求S=1+1/(1+2)+1/(1+2+3)+…
计算机编程求S=1+1/(1+2)+1/(1+2+3)+…
日期:2016-06-12 22:51:01 人气:2
VB?代码如下,VB6测试通过:
Private Sub Command1_Click()
Dim i As Integer, sum As Single, n As Integer
n = Val(Text1.Text)
For i = 1 To n
sum = sum + ds(i)
Next i
Label1.Caption = Str(sum)
End Sub
Function ds(n As Integer) As Single