Program to calculate value of nCr | Javascript program To calculate The Value Of nCr ; Returns factorial of n ; Driver code
function nCr ( n , r ) { return fact ( n ) / ( fact ( r ) * fact ( n - r ) ) ; } function fact ( n ) { var res = 1 ; for ( var i = 2 ; i <= n ; i ++ ) res = res * i ; return res ; } var n = 5 , r = 3 ; document . write ( nCr ( n , r ) ) ;