Sum of product of r and rth Binomial Coefficient ( r * nCr ) | CPP 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
#include <bits/stdc++.h> NEW_LINE using namespace std ; #define MAX  100 NEW_LINE void binomialCoeff ( int n , int C [ ] ) { for ( int i = 1 ; i <= n ; i ++ ) { for ( int j = min ( i , n ) ; j > 0 ; j -- ) C [ j ] = C [ j ] + C [ j - 1 ] ; } } int summation ( int n ) { int C [ MAX ] ; memset ( C , 0 , sizeof ( C ) ) ; binomialCoeff ( n , C ) ; int sum = 0 ; for ( int i = 0 ; i <= n ; i ++ ) sum += ( i * C [ i ] ) ; return sum ; } int main ( ) { int n = 2 ; cout << summation ( n ) << endl ; return 0 ; }