VB计算n个整数的阶乘和
5个回答
展开全部
'计算阶乘的函数
Private Function factorial(ByVal N As Long) As Double
Dim i As Long
Dim sum As Double
sum = 1
For i = 1 To N
sum = sum * i
Next
factorial = sum
End Function
Private Function factorial(ByVal N As Long) As Double
Dim i As Long
Dim sum As Double
sum = 1
For i = 1 To N
sum = sum * i
Next
factorial = sum
End Function
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Private Sub Command1_Click()
Dim AA As Double, BB As Integer, CC As Double
BB = Val(Text1.Text)
CC = 1
For J = 1 To BB
CC = CC * J
AA = AA + CC
Next J
Text1.Text = AA
End Sub
Dim AA As Double, BB As Integer, CC As Double
BB = Val(Text1.Text)
CC = 1
For J = 1 To BB
CC = CC * J
AA = AA + CC
Next J
Text1.Text = AA
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Private Sub Command1_Click()For i = 1 To 10 Sum = Sum + jiecheng(i)NextPrint SumEnd SubFunction jiecheng(num)jiecheng = 1 For i = 1 To num jiecheng = jiecheng * i NextEnd Function
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询