
- C++ Basics
- C++ Home
- C++ Overview
- C++ Environment Setup
- C++ Basic Syntax
- C++ Comments
- C++ Data Types
- C++ Variable Types
- C++ Variable Scope
- C++ Constants/Literals
- C++ Modifier Types
- C++ Storage Classes
- C++ Operators
- C++ Loop Types
- C++ Decision Making
- C++ Functions
- C++ Numbers
- C++ Arrays
- C++ Strings
- C++ Pointers
- C++ References
- C++ Date & Time
- C++ Basic Input/Output
- C++ Data Structures
- C++ Object Oriented
- C++ Classes & Objects
- C++ Inheritance
- C++ Overloading
- C++ Polymorphism
- C++ Abstraction
- C++ Encapsulation
- C++ Interfaces
Sum of squares of binomial coefficients in C++
The binomial coefficient is a quotation found in a binary theorem which can be arranged in a form of pascal triangle it is a combination of numbers which is equal to nCr where r is selected from a set of n items which shows the following formula
nCr=n! / r!(n-r)! or nCr=n(n-1)(n-2).....(n-r+1) / r!
The sum of the square of Binomial Coefficient i.e (nC0)2 + (nC1)2 + (nC2)2 + (nC3)2 + ……… + (nCn-2)2 + (nCn-1)2 + (nCn)2
Input :n=5 Output:252
Explanation
In this program first we have to find the binomial coefficient of r which is selected from n set then we have to square each coefficient and sum them we can derive a formula from the above equation or use of factorial function of each digit to get a sum so we will fall or factorial function in which we will pass and r for a given equation and then add it then we get the solution
Example
#include <iostream> using namespace std; int fact(int n){ int fact = 1, i; for (i = 2; i <= n; i++){ fact *= i; } return fact; } int main(){ int n=5; int sum = 0; int temp=0; for (int r = 0; r <= n; r++){ temp = fact(n)/(fact(r)*fact(n-r)); sum +=(temp*temp); } cout<<sum; return 0; }
Output
252
- Related Articles
- Find sum of even index binomial coefficients in C++
- C program for Binomial Coefficients table
- Sum of squares of Fibonacci numbers in C++
- Sum of squares of first n natural numbers in C Program?
- Sum of squares of the first n even numbers in C Program
- Minimize the sum of squares of sum of N/2 paired formed by N numbers in C++
- C++ Program for Sum of squares of first n natural numbers?
- Square pyramidal number (Sum of Squares)
- Memory representation of Binomial Heap in C++
- Prove that the sum of the squares of the diagonals of parallelogram is equal to the sum of the squares of its sides.
- Sum of series with alternate signed squares of AP
- Binomial Heap in C++?
- Binomial Coefficient in C++
- Prove that the sum of the squares of the sides of a rhombus is equal to the sum of the squares of its diagonals.
- Is a number sum of two perfect squares in JavaScript

Advertisements