Find the number of words of X vowels and Y consonants that can be formed from M vowels and N consonants | Function to returns factorial of n ; Function to find nCr ; Function to find the number of words of X vowels and Y consonants can be formed from M vowels and N consonants ; Driver code ; Function call
function fact ( n ) { var res = 1 ; for ( var i = 2 ; i <= n ; i ++ ) res = res * i ; return res ; } function nCr ( n , r ) { return fact ( n ) / ( fact ( r ) * fact ( n - r ) ) ; } function NumberOfWays ( X , Y , M , N ) { return fact ( X + Y ) * nCr ( M , X ) * nCr ( N , Y ) ; } var X = 2 , Y = 2 , M = 3 , N = 3 ; document . write ( NumberOfWays ( X , Y , M , N ) ) ;