用VB写设计程序代码,求:s=1+(1+2)+(1+2+3)+……+(1+2+3+……+n)的值。
用VB写设计程序代码,求:s=1+(1+2)+(1+2+3)+……+(1+2+3+……+n)的值。
日期:2019-06-26 09:39:46 人气:2
Function sumD(n As Integer) As Single
s = 1
i = 1
Do
i = i + 1
s = s + 1 / i
Loop Until i >= n
sumD = s
End Function
Function sumF(n As Integer) As Single
s = 0
For i = 1 To n
s = s + 1 / i
Next i
sumF = s
End Function
Private Sub Form_Click()