Ways of dividing a group into two halves such that two elements are in different groups | This function will return the factorial of a given number ; This function will calculate nCr of given n and r ; This function will Calculate number of ways ; Driver code
def factorial ( n ) : NEW_LINE INDENT result = 1 NEW_LINE for i in range ( 1 , n + 1 ) : NEW_LINE INDENT result *= i NEW_LINE DEDENT return result NEW_LINE DEDENT def nCr ( n , r ) : NEW_LINE INDENT return ( factorial ( n ) // ( factorial ( r ) * factorial ( n - r ) ) ) NEW_LINE DEDENT def calculate_result ( n ) : NEW_LINE INDENT result = 2 * nCr ( ( n - 2 ) , ( n // 2 - 1 ) ) NEW_LINE return result NEW_LINE DEDENT if __name__ == " _ _ main _ _ " : NEW_LINE INDENT a , b = 2 , 4 NEW_LINE print ( calculate_result ( 2 * a ) ) NEW_LINE print ( calculate_result ( 2 * b ) ) NEW_LINE DEDENT