7-2 jmu-python-组合数 (20分)
def Factorial(x):
s = 1
for i in range(1,x+1):
s *= i
return s
try:
m, n = map(int,input().split())
except:
print('请输入数值')
exit(0)
if m < 0:
print('不能负数')
exit(0)
else:
n_1 = Factorial(n)
m_1 = Factorial(m)
n_m = Factorial(n-m)
s = n_1 / (m_1*n_m)
print("result={:.2f}".format(s))
or
def Factorial(n):
s = 1
for i in range(1,n+1):
s = s * i
return s
def cal(m,n):
n_1 = Factorial(n)
m_1 = Factorial(m)
n_m = Factorial(n-m)
return n_1 / (m_1 * n_m)
def judge(m,n):
try:
m, n = int(m), int(n)
return True
except:
return False
m,n = input().split()
if judge(m,n):