计算1到10的阶乘和,
来源:百度知道 编辑:UC知道 时间:2024/05/21 14:19:11
Function product(i) As Long
p = 1
For j = 1 To i
p = p * j
Next j
product = p
End Function
Private Sub Command1_Click()
For i = 2 To 10 Step 2
sum = sum + product(i)
Next i
Print sum
End Sub
'添加窗体Form1,按钮Command1,然后添加如下代码:
Private Sub Command1_Click()
Dim i%, temp&, s&
temp = 1
s = 0
For i = 1 To 10
temp = temp * i
s = s + temp
Next
MsgBox s
End Sub