VB编写程序计算1+2!+3!+4!+……+10!的程序

2024-12-05 07:21:30
推荐回答(2个)
回答1:

Function jc(n As Integer) As Long
Dim i%
jc = 1
For i = 1 To n
jc = jc * i
Next
End Function

Private Sub Command1_Click()
Dim SumAdd As Long, i%
For i = 1 To 10
SumAdd = SumAdd + jc(i)
Next
Print SumAdd
End Sub

回答2:

Private Sub Form_Click()
s = 1
For i = 2 To 10
s = s + JieCheng(i)
Next i
Print s
End Sub

Function JieCheng(a)
t = 1
For i = 2 To a
t = t * i
Next i
JieCheng = t
End Function