Given a positive integer **n**. The task is to find the sum of the product of r and r^{th} Binomial Coefficient. In other words find: **Σ (r * ^{n}C_{r})**, where 0 <= r <= n.

Examples:

Input : n = 2 Output : 4 0.^{2}C_{0}+ 1.^{2}C_{1}+ 2.^{2}C_{2}= 0*2 + 1*2 + 2*1 = 4 Input : n = 5 Output : 80

**Method 1 (Brute Force) : ** The idea is to iterate a loop i from 0 to n and evaluate i * ^{n}C_{i} and add to sum variable.

Below is the C++ implementation of this approach:

// CPP Program to find sum of product of r and // rth Binomial Coefficient i.e summation r * nCr #include <bits/stdc++.h> using namespace std; #define MAX 100 // Return the first n term of binomial coefficient. void binomialCoeff(int n, int C[]) { C[0] = 1; // nC0 is 1 for (int i = 1; i <= n; i++) { // Compute next row of pascal triangle // using the previous row for (int j = min(i, n); j > 0; j--) C[j] = C[j] + C[j - 1]; } } // Return summation of r * nCr int summation(int n) { int C[MAX]; memset(C, 0, sizeof(C)); // finding the first n term of binomial // coefficient binomialCoeff(n, C); // Iterate a loop to find the sum. int sum = 0; for (int i = 0; i <= n; i++) sum += (i * C[i]); return sum; } // Driven Program int main() { int n = 2; cout << summation(n) << endl; return 0; }

**Output:**

4

**Method 2 (Using formula) : **

Mathematically we need to find,

Σ (i * ^{n}C_{i}), where 0 <= i <= n

= Σ (^{i}C_{1} * ^{n}C_{i}), (Since ^{n}C_{1} = n, we can write i as ^{i}C_{1})

= Σ ( (i! / (i – 1)! * 1!) * (n! / (n – i)! * i!)

On cancelling i! from numerator and denominator

= Σ (n! / (i – 1)! * (n – i)!)

= Σ n * ((n – 1)!/ (i – 1)! * (n – i)!)

(Using reverse of ^{n}C_{r} = (n)!/ (r)! * (n – r)!)

= n * Σ ^{n – 1}C_{r – 1}

= n * 2^{n – 1} (Since Σ ^{n}C_{r} = 2^{n})

Below is the implementation of this approach:

## C++

// CPP Program to find sum of product of r and // rth Binomial Coefficient i.e summation r * nCr #include <bits/stdc++.h> using namespace std; #define MAX 100 // Return summation of r * nCr int summation(int n) { return n << (n - 1); } // Driven Program int main() { int n = 2; cout << summation(n) << endl; return 0; }

## Java

// Java Program to find sum of product of // r and rth Binomial Coefficient i.e // summation r * nCr import java.io.*; class GFG { static int MAX = 100; // Return summation of r * nCr static int summation(int n) { return n << (n - 1); } // Driven Program public static void main (String[] args) { int n = 2; System.out.println( summation(n)); } } // This code is contributed by anuj_67.

## C#

// C# Program to find sum of product of // r and rth Binomial Coefficient i.e // summation r * nCr using System; class GFG { //static int MAX = 100; // Return summation of r * nCr static int summation(int n) { return n << (n - 1); } // Driver Code public static void Main () { int n = 2; Console.WriteLine( summation(n)); } } // This code is contributed by anuj_67.

**Output:**

4

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.