Number of ways to arrange 2 * N persons on the two sides of a table with X and Y persons on opposite sides | JavaScript implementation for the above approach Function to returns factorial of n ; Function to find nCr ; Function to find the number of ways to arrange 2 * N persons ; Driver code ; Function call
function factorial ( n ) { if ( n <= 1 ) return 1 ; return n * factorial ( n - 1 ) ; } function nCr ( n , r ) { return factorial ( n ) / ( factorial ( n - r ) * factorial ( r ) ) ; } function NumberOfWays ( n , x , y ) { return nCr ( 2 * n - x - y , n - x ) * factorial ( n ) * factorial ( n ) ; } var n = 5 , x = 4 , y = 2 ; document . write ( NumberOfWays ( n , x , y ) ) ;