from fractions import Fraction

def choose(n, k):
    if k > n // 2:
        k = n - k
p = Fraction(1)
for i in range(1, k + 1):
    p *= Fraction(n - i + 1, i)
return int(p)
Handling big numbers in Python 3 for calculating combinations