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
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
TableDI
2024-07-18 广告
2024-07-18 广告
Excel一键自动匹配,在线免费vlookup工具,3步完成!Excel在线免费vlookup工具,点击63步自动完成vlookup匹配,无需手写公式,免费使用!...
点击进入详情页
本回答由TableDI提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询