1个回答
展开全部
Private Sub Command1_Click()
Dim n As Integer, s As Double
n = Val(InputBox("请输入n", , 10))
Print "1到" & n & "的和为:" & toSum(n)
End Sub
Private Function toSum(ByVal n As Integer) As Double
toSum = 1
If n > 1 Then toSum = n + toSum(n - 1)
End Function
Dim n As Integer, s As Double
n = Val(InputBox("请输入n", , 10))
Print "1到" & n & "的和为:" & toSum(n)
End Sub
Private Function toSum(ByVal n As Integer) As Double
toSum = 1
If n > 1 Then toSum = n + toSum(n - 1)
End Function
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询