def n_choose_k(n: int, k: int) -> int:
    """
    Calulate the number of combinations in N choose K
    When K is 0 or 1, the answer is returned directly. When K > 1, iterate to compute factoral to compute
    nCk formula = n! / (k! (n-k)! by using m as an accumulator

    :return: number of ways to choose k from n
    """
    m = 0
    if k == 0:
        m = 1
    if k == 1:
        m = n
    if k >= 2:
        num, dem, op1, op2 = 1, 1, k, n
        while(op1 >= 1):
            num *= op2
            dem *= op1
            op1 -= 1
            op2 -= 1
        m = num//dem
    return m