Combinations

PHOTO EMBED

Sat Dec 12 2020 22:40:14 GMT+0000 (Coordinated Universal Time)

Saved by @Adorism80 #python


def combinations(n, k):
    '''
    Returns the number of ways you can choose k items out of n if order does not matter

    Parameters:
    ----------
    n: (int)
    k: (int)

    Returns:
    ----------
    Returns the number of combinations of k items out of n.
    '''
    import math
    combs = math.factorial(n)/(math.factorial(k)*math.factorial(n-k))
    return combs
content_copyCOPY

https://learn-2.galvanize.com/cohorts/2302/blocks/315/content_files/06_Importing/02_math.md