jmu-python-组合数

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):
    m, n = int(m), int(n)
    if m > 0 and n > 0:
        print('result={:.2f}'.format(cal(m, n)))
    else:
        print('不能负数')
else:
原文地址:https://www.cnblogs.com/Deranuid/p/13172891.html