def combination_memo(n, r):
memo = {}<EOL>def recur(n, r):<EOL><INDENT>if n == r or r == <NUM_LIT:0>:<EOL><INDENT>return <NUM_LIT:1><EOL><DEDENT>if (n, r) not in memo:<EOL><INDENT>memo[(n, r)] = recur(n - <NUM_LIT:1>, r - <NUM_LIT:1>) + recur(n - <NUM_LIT:1>, r)<EOL><DEDENT>return memo[(n, r)]<EOL><DEDENT>return recur(n, r)<EOL>
This function calculates nCr using memoization method.