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
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter