vb采用递推法计算s=1+(1+2)+(1+2+3)+…+(1+2+3+…+10)

vb采用递推法计算s=1+(1+2)+(1+2+3)+…+(1+2+3+…+10)
2024-12-28 17:35:07
推荐回答(1个)
回答1:

Function sss(n As Integer) As Long

  Dim i As Long, m As Long

  If n < 1 Then Exit Function

  For i = 1 To n

    m = m + i

  Next

  sss = m + sss(n - 1)

End Function