Sum of product of r and rth Binomial Coefficient ( r * nCr ) | Javascript Program to find sum of product of r and rth Binomial Coefficient i . e summation r * nCr ; Return the first n term of binomial coefficient . ; C [ 0 ] = 1 ; nC0 is 1 ; Compute next row of pascal triangle using the previous row ; Return summation of r * nCr ; finding the first n term of binomial coefficient ; Iterate a loop to find the sum . ; Driven Program
MAX = 100 function binomialCoeff ( n , C ) { for ( var i = 1 ; i <= n ; i ++ ) { for ( var j = Math . min ( i , n ) ; j > 0 ; j -- ) C [ j ] = C [ j ] + C [ j - 1 ] ; } } function summation ( n ) { C = Array ( MAX ) . fill ( 0 ) ; binomialCoeff ( n , C ) ; var sum = 0 ; for ( var i = 0 ; i <= n ; i ++ ) sum += ( i * C [ i ] ) ; return sum ; } var n = 2 ; document . write ( summation ( n ) ) ;