求高手vb解决此题
今天自己练习vb,遇到这题,1+7+13+···,求前n项之和的程序代码 VB
[解决办法]
本帖最后由 bcrun 于 2013-05-31 10:22:23 编辑
Public Function CalcX(n As Long) As Long
Dim K As Long, K1 As Long
K = 2 * n - 1
If n = 1 Then
CalcX = 1
ElseIf n = 2 Then
CalcX = 1 + 3
Else
CalcX = K + CalcX(n - 1)
End If
End Function