VB题,输入两个正整数M,N,求阶乘:Cmn=n!/m!(n-m)!,用fac函数

来源:学生作业帮助网 编辑:六六作业网 时间:2024/12/24 21:31:56
VB题,输入两个正整数M,N,求阶乘:Cmn=n!/m!(n-m)!,用fac函数VB题,输入两个正整数M,N,求阶乘:Cmn=n!/m!(n-m)!,用fac函数VB题,输入两个正整数M,N,求阶乘

VB题,输入两个正整数M,N,求阶乘:Cmn=n!/m!(n-m)!,用fac函数
VB题,输入两个正整数M,N,求阶乘:Cmn=n!/m!(n-m)!,用fac函数

VB题,输入两个正整数M,N,求阶乘:Cmn=n!/m!(n-m)!,用fac函数
Private Sub Command1_Click()
Dim m As Integer,n As Integer
Dim c As Double
m = Val(InputBox("m="))
n = Val(InputBox("n="))
If n > 0 And m > 0 And n >= m Then
c = fac(n) / (fac(m) * fac(n - m))
MsgBox "所求结果为:" & c
Else
MsgBox "输入的数不符合要求!"
End If
End Sub
Function fac(n As Integer)
fac = 1
For i = 1 To n
fac = fac * i
Next i
End Function