在VB6.0中,求1!+3!+5!+7!+9!+...+n!阶乘的和,n利用InpuBos输入。
发布网友
发布时间:2024-10-04 16:51
我来回答
共2个回答
热心网友
时间:2024-10-04 22:11
Private Sub Command1_Click()
x = InputBox("shu ru shuju", "nihao")
s = Fac(Val(x))
Print s
End Sub
Public Function Fac(Num As Integer) As Double
If Num = 1 Then
Fac = 1
Else
Fac = Fac(Num - 1) * Num
End If
End Function
热心网友
时间:2024-10-04 22:05
已改:
Private Sub Command1_Click()
Dim n, i, k, s, sum
sum = 0
n = CInt(InputBox("Please input a value", ""))
For i = 1 To n Step 2
s = 1
For k = 1 To i Step 1
s = s * k
Next k
MsgBox s
sum = sum + s
Next i
MsgBox sum
End Sub