def binomial(n: int, k: int) ->int:
    """
    Calculate n choose k.

    Calculation is using the multiplicative formula, and is performed
    from the side that will minimise the number of calculations.
    """
    output = 1
    k = min(k, n - k)
    for t in range(k):
        output = (n - t) * output // (t + 1)
    return output
