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
function factorial ( n ) { let result = 1 ; for ( let 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 ) { let result = 2 * nCr ( ( n - 2 ) , ( n / 2 - 1 ) ) ; return result ; } let a = 2 ; let b = 4 ; document . write ( calculate_result ( 2 * a ) + " " ) ; document . write ( calculate_result ( 2 * b ) + " " ) ;