def nCr(n,r):
    """Calculate ways of selecting *r* members out of a collection of *n*
    members.
    
    :param n: Size of the collection
    :param r: Number of members to be selected from the collection
    :returns: n!/[r!(n-r)!]
    
    .. note::
        
        :sup:`n` C :sub:`r` is typically read as *n combination r*. Order of 
        members *is not* important in the combination. E.g. There are :sup:`4`   
        C :sub:`2` = 6 ways of selecting two members out of a collection 
        (A, B, C, D) => AB, AC, AD, BC, BD, CD.
    """
    result = 0
    if n >= 0 and r >= 0 and r <= n:
        num = 1
        denom = 1
        for i in range(r):
            num *= (n-i)
            denom *= (i+1)
        result = num/denom
    return result