Sum of product of r and rth Binomial Coefficient ( r * nCr ) | Python 3 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 . ; Driver Code
MAX = 100 NEW_LINE def binomialCoeff ( n , C ) : NEW_LINE INDENT for i in range ( 1 , n + 1 ) : NEW_LINE INDENT for j in range ( min ( i , n ) , - 1 , - 1 ) : NEW_LINE INDENT C [ j ] = C [ j ] + C [ j - 1 ] NEW_LINE DEDENT DEDENT DEDENT def summation ( n ) : NEW_LINE INDENT C = [ 0 ] * MAX NEW_LINE binomialCoeff ( n , C ) NEW_LINE sum = 0 NEW_LINE for i in range ( n + 1 ) : NEW_LINE INDENT sum += ( i * C [ i ] ) NEW_LINE DEDENT return sum NEW_LINE DEDENT if __name__ == " _ _ main _ _ " : NEW_LINE INDENT n = 2 NEW_LINE print ( summation ( n ) ) NEW_LINE DEDENT