利用for循环求1!+3!+5!+ 7!+9!的值(12分)
2个回答
2013-08-03
展开全部
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim Result As Long = 0
For i As Integer = 1 To 9 Step 2
Result += Stair(i)
Next
Debug.WriteLine(Result)
End Sub
Private Function Stair(ByVal Num As Integer) As Long
If Num = 1 Then Return 1
If Num = 0 Then Return 0
Dim Result As Long = 1
For i As Integer = 1 To Num
Result *= i
Next
Return Result
End Function
输出368047
Dim Result As Long = 0
For i As Integer = 1 To 9 Step 2
Result += Stair(i)
Next
Debug.WriteLine(Result)
End Sub
Private Function Stair(ByVal Num As Integer) As Long
If Num = 1 Then Return 1
If Num = 0 Then Return 0
Dim Result As Long = 1
For i As Integer = 1 To Num
Result *= i
Next
Return Result
End Function
输出368047
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2013-08-03
展开全部
t=1 s=0for i=1 to 9 step 2 for j=i to 1 step -1 t=t*j next j s=s+tnext iprint s
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询