Ways of selecting men and women from a group to make a team | Returns factorial of the number ; Function to calculate ncr ; Function to calculate the total possible ways ; Driver code
def fact ( n ) : NEW_LINE INDENT fact = 1 NEW_LINE for i in range ( 2 , n + 1 ) : NEW_LINE INDENT fact *= i NEW_LINE DEDENT return fact NEW_LINE DEDENT def ncr ( n , r ) : NEW_LINE INDENT ncr = fact ( n ) // ( fact ( r ) * fact ( n - r ) ) NEW_LINE return ncr NEW_LINE DEDENT def ways ( m , w , n , k ) : NEW_LINE INDENT ans = 0 NEW_LINE while ( m >= k ) : NEW_LINE INDENT ans += ncr ( m , k ) * ncr ( w , n - k ) NEW_LINE k += 1 NEW_LINE DEDENT return ans ; NEW_LINE DEDENT m = 7 NEW_LINE w = 6 NEW_LINE n = 5 NEW_LINE k = 3 NEW_LINE print ( ways ( m , w , n , k ) ) NEW_LINE