def comb(N, n, combs):
	""" 
	Returns the value of C(N,n). 
	First the function looks it up in a dictionary and only calculates
	if it isn't present, in which case it works recursively.
	"""
	try:
		ans = combs[(N,n)]
	except KeyError:
		if n == 0: ans=1
		elif n == 1: ans=N
		else:
			ans = (comb(N, n-1, combs) * (N-n+1) * 1/n)
			combs[(N,n)] = ans
	return ans
 
	Returns the value of C(N,n). 
	First the function looks it up in a dictionary and only calculates
	if it isn't present, in which case it works recursively.
	
recipes/Python/528913_Pascals_Triangle/recipe-528913.py