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
< ? php function factorial ( $ n ) { $ result = 1 ; for ( $ i = 1 ; $ i <= $ n ; $ i ++ ) $ result = $ result * $ i ; return $ result ; } function nCr ( $ n , $ r ) { return factorial ( $ n ) / ( factorial ( $ r ) * factorial ( $ n - $ r ) ) ; } function calculate_result ( $ n ) { $ result = 2 * nCr ( ( $ n - 2 ) , ( $ n / 2 - 1 ) ) ; return $ result ; } $ a = 2 ; $ b = 4 ; echo calculate_result ( 2 * $ a ) . " STRNEWLINE " ; echo calculate_result ( 2 * $ b ) . " STRNEWLINE " ; ? >