def choose(n, r):
    """
    Returns the value of nCr
    """
    if r > n//2 + 1:
        r = n - r
    numerator = 1
    denominator = 1
    for i in range(n, n - r, -1):
        numerator *= i
        denominator *= (n - i + 1)
    return(numerator//denominator)