functions to calculate ncr ie how many ways to choose r items from n items this function calculates ncr if n r or r 0 return 1 return combinationn1 r1 combinationn1 r def combinationmemon r this function calculates ncr this function calculates ncr using memoization method
def combination(n, r):
    
    if n == r or r == 0:
        return 1
    return combination(n-1, r-1) + combination(n-1, r)

def combination_memo(n, r):
    
    memo = {}
    def recur(n, r):
        if n == r or r == 0:
            return 1
        if (n, r) not in memo:
            memo[(n, r)] = recur(n - 1, r - 1) + recur(n - 1, r)
        return memo[(n, r)]
    return recur(n, r)