Binomial Coefficient | DP-9
- Difficulty Level : Medium
- Last Updated : 27 Jun, 2022
The following are the common definitions of Binomial Coefficients.
A binomial coefficient C(n, k) can be defined as the coefficient of x^k in the expansion of (1 + x)^n.
![]()
A binomial coefficient C(n, k) also gives the number of ways, disregarding order, that k objects can be chosen from among n objects more formally, the number of k-element subsets (or k-combinations) of a n-element set.
The Problem
Write a function that takes two parameters n and k and returns the value of Binomial Coefficient C(n, k). For example, your function should return 6 for n = 4 and k = 2, and it should return 10 for n = 5 and k = 2.1) Optimal Substructure
The value of C(n, k) can be recursively calculated using the following standard formula for Binomial Coefficients.C(n, k) = C(n-1, k-1) + C(n-1, k) C(n, 0) = C(n, n) = 1Following is a simple recursive implementation that simply follows the recursive structure mentioned above.
C++
// A naive recursive C++ implementation#include <bits/stdc++.h>usingnamespacestd;// Returns value of Binomial Coefficient C(n, k)intbinomialCoeff(intn,intk){// Base Casesif(k > n)return0;if(k == 0 || k == n)return1;// RecurreturnbinomialCoeff(n - 1, k - 1)+ binomialCoeff(n - 1, k);}/* Driver code*/intmain(){intn = 5, k = 2;cout <<"Value of C("<< n <<", "<< k <<") is "<< binomialCoeff(n, k);return0;}// This is code is contributed by rathbhupendraC
// A Naive Recursive Implementation#include <stdio.h>// Returns value of Binomial Coefficient C(n, k)intbinomialCoeff(intn,intk){// Base Casesif(k > n)return0;if(k == 0 || k == n)return1;// RecurreturnbinomialCoeff(n - 1, k - 1)+ binomialCoeff(n - 1, k);}/* Driver program to test above function*/intmain(){intn = 5, k = 2;printf("Value of C(%d, %d) is %d ", n, k,binomialCoeff(n, k));return0;}Java
// JAVA Code for Dynamic Programming |// Set 9 (Binomial Coefficient)importjava.util.*;classGFG {// Returns value of Binomial// Coefficient C(n, k)staticintbinomialCoeff(intn,intk){// Base Casesif(k > n)return0;if(k ==0|| k == n)return1;// RecurreturnbinomialCoeff(n -1, k -1)+ binomialCoeff(n -1, k);}/* Driver program to test above function */publicstaticvoidmain(String[] args){intn =5, k =2;System.out.printf("Value of C(%d, %d) is %d ", n, k,binomialCoeff(n, k));}}// This code is contributed by Arnav Kr. Mandal.Python3
# A naive recursive Python implementationdefbinomialCoeff(n, k):ifk > n:return0ifk==0ork==n:return1# Recursive CallreturnbinomialCoeff(n-1, k-1)+binomialCoeff(n-1, k)# Driver Program to test ht above functionn=5k=2("Value of C(%d,%d) is (%d)"%(n, k,binomialCoeff(n, k)))# This code is contributed by Nikhil Kumar Singh (nickzuck_007)C#
// C# Code for Dynamic Programming |// Set 9 (Binomial Coefficient)usingSystem;classGFG {// Returns value of Binomial// Coefficient C(n, k)staticintbinomialCoeff(intn,intk){// Base Casesif(k > n)return0;if(k == 0 || k == n)return1;// RecurreturnbinomialCoeff(n - 1, k - 1)+ binomialCoeff(n - 1, k);}/* Driver program to test above function */publicstaticvoidMain(){intn = 5, k = 2;Console.Write("Value of C("+ n +","+ k +") is "+ binomialCoeff(n, k));}}// This code is contributed by Sam007.PHP
<?php// PHP Code for Dynamic Programming |// Set 9 (Binomial Coefficient)// Returns value of// Binomial Coefficient C(n, k)functionbinomialCoeff($n,$k){// Base Casesif($k>$n)return0;if($k==0 ||$k==$n)return1;// RecurreturnbinomialCoeff($n- 1,$k- 1) +binomialCoeff($n- 1,$k);}// Driver Code$n= 5;$k= 2;echo"Value of C","(",$n,$k,") is ", binomialCoeff($n,$k);// This code is contributed by aj_36?>Javascript
<script>// javascript Code for Dynamic Programming |// Set 9 (Binomial Coefficient)// Returns value of Binomial// Coefficient C(n, k)functionbinomialCoeff(n , k){// Base Casesif(k > n)return0;if(k == 0 || k == n)return1;// RecurreturnbinomialCoeff(n - 1, k - 1)+ binomialCoeff(n - 1, k);}/* Driver program to test above function */varn = 5, k = 2;document.write("Value of C("+n+", "+k+") is "+binomialCoeff(n, k));// This code is contributed by Amit Katiyar</script>OutputValue of C(5, 2) is 10Time Complexity: O(n*max(k,n-k))
Auxiliary Space: O(n*max(k,n-k))
2) Overlapping Subproblems
It should be noted that the above function computes the same subproblems again and again. See the following recursion tree for n = 5 an k = 2. The function C(3, 1) is called two times. For large values of n, there will be many common subproblems.
Binomial Coefficients Recursion tree for C(5,2)
Since the same subproblems are called again, this problem has the Overlapping Subproblems property. So the Binomial Coefficient problem has both properties (see this and this) of a dynamic programming problem. Like other typical Dynamic Programming(DP) problems, re-computations of the same subproblems can be avoided by constructing a temporary 2D-array C[][] in a bottom-up manner. Following is Dynamic Programming-based implementation.
C++
// A Dynamic Programming based solution that uses// table C[][] to calculate the Binomial Coefficient#include <bits/stdc++.h>usingnamespacestd;// Prototype of a utility function that// returns minimum of two integersintmin(inta,intb);// Returns value of Binomial Coefficient C(n, k)intbinomialCoeff(intn,intk){intC[n + 1][k + 1];inti, j;// Calculate value of Binomial Coefficient// in bottom up mannerfor(i = 0; i <= n; i++) {for(j = 0; j <= min(i, k); j++) {// Base Casesif(j == 0 || j == i)C[i][j] = 1;// Calculate value using previously// stored valueselseC[i][j] = C[i - 1][j - 1] + C[i - 1][j];}}returnC[n][k];}// A utility function to return// minimum of two integersintmin(inta,intb) {return(a < b) ? a : b; }// Driver Codeintmain(){intn = 5, k = 2;cout <<"Value of C["<< n <<"]["<< k <<"] is "<< binomialCoeff(n, k);}// This code is contributed by Shivi_AggarwalC
// A Dynamic Programming based solution// that uses table C[][] to// calculate the Binomial Coefficient#include <stdio.h>// Prototype of a utility function that// returns minimum of two integersintmin(inta,intb);// Returns value of Binomial Coefficient C(n, k)intbinomialCoeff(intn,intk){intC[n + 1][k + 1];inti, j;// Calculate value of Binomial Coefficient// in bottom up mannerfor(i = 0; i <= n; i++) {for(j = 0; j <= min(i, k); j++) {// Base Casesif(j == 0 || j == i)C[i][j] = 1;// Calculate value using// previously stored valueselseC[i][j] = C[i - 1][j - 1] + C[i - 1][j];}}returnC[n][k];}// A utility function to return// minimum of two integersintmin(inta,intb) {return(a < b) ? a : b; }/* Drier program to test above function*/intmain(){intn = 5, k = 2;printf("Value of C(%d, %d) is %d ", n, k,binomialCoeff(n, k));return0;}Java
// A Dynamic Programming based// solution that uses table C[][] to// calculate the Binomial CoefficientclassBinomialCoefficient {// Returns value of Binomial// Coefficient C(n, k)staticintbinomialCoeff(intn,intk){intC[][] =newint[n +1][k +1];inti, j;// Calculate value of Binomial// Coefficient in bottom up mannerfor(i =0; i <= n; i++) {for(j =0; j <= min(i, k); j++) {// Base Casesif(j ==0|| j == i)C[i][j] =1;// Calculate value using// previously stored valueselseC[i][j] = C[i -1][j -1] + C[i -1][j];}}returnC[n][k];}// A utility function to return// minimum of two integersstaticintmin(inta,intb) {return(a < b) ? a : b; }/* Driver program to test above function*/publicstaticvoidmain(String args[]){intn =5, k =2;System.out.println("Value of C("+ n +","+ k+") is "+ binomialCoeff(n, k));}}/*This code is contributed by Rajat Mishra*/Python3
# A Dynamic Programming based Python# Program that uses table C[][]# to calculate the Binomial Coefficient# Returns value of Binomial Coefficient C(n, k)defbinomialCoef(n, k):C=[[0forxinrange(k+1)]forxinrange(n+1)]# Calculate value of Binomial# Coefficient in bottom up mannerforiinrange(n+1):forjinrange(min(i, k)+1):# Base Casesifj==0orj==i:C[i][j]=1# Calculate value using# previously stored valueselse:C[i][j]=C[i-1][j-1]+C[i-1][j]returnC[n][k]# Driver program to test above functionn=5k=2("Value of C["+str(n)+"]["+str(k)+"] is "+str(binomialCoef(n, k)))# This code is contributed by Bhavya JainC#
// A Dynamic Programming based solution that// uses table C[][] to calculate the Binomial// CoefficientusingSystem;classGFG {// Returns value of Binomial Coefficient// C(n, k)staticintbinomialCoeff(intn,intk){int[, ] C =newint[n + 1, k + 1];inti, j;// Calculate value of Binomial// Coefficient in bottom up mannerfor(i = 0; i <= n; i++) {for(j = 0; j <= Math.Min(i, k); j++) {// Base Casesif(j == 0 || j == i)C[i, j] = 1;// Calculate value using previously// stored valueselseC[i, j] = C[i - 1, j - 1] + C[i - 1, j];}}returnC[n, k];}// A utility function to return minimum// of two integersstaticintmin(inta,intb) {return(a < b) ? a : b; }/* Driver program to test above function*/publicstaticvoidMain(){intn = 5, k = 2;Console.WriteLine("Value of C("+ n +","+ k+") is "+ binomialCoeff(n, k));}}// This code is contributed by anuj_67.PHP
<?php// A Dynamic Programming based// solution that uses table C[][] to// calculate the Binomial Coefficient// Returns value of Binomial// Coefficient C(n, k)functionbinomialCoeff($n,$k){$C=array(array());$i;$j;// Calculate value of Binomial// Coefficient in bottom up mannerfor($i= 0;$i<=$n;$i++){for($j= 0;$j<= min($i,$k);$j++){// Base Casesif($j== 0 ||$j==$i)$C[$i][$j] = 1;// Calculate value using// previously stored valueselse$C[$i][$j] =$C[$i- 1][$j- 1] +$C[$i- 1][$j];}}return$C[$n][$k];}// Driver Code$n= 5;$k= 2;echo"Value of C(",$n," ",$k,") is"," ", binomialCoeff($n,$k) ;// This code is contributed by anuj_67.?>Javascript
<script>// A Dynamic Programming based// solution that uses table C to// calculate the Binomial Coefficient// Returns value of Binomial// Coefficient C(n, k)functionbinomialCoeff(n, k){varC = Array(n + 1).fill(0).map(x => Array(k + 1).fill(0));;vari, j;// Calculate value of Binomial// Coefficient in bottom up mannerfor(i = 0; i <= n; i++){for(j = 0; j <= min(i, k); j++){// Base Casesif(j == 0 || j == i)C[i][j] = 1;// Calculate value using// previously stored valueselseC[i][j] = C[i - 1][j - 1] +C[i - 1][j];}}returnC[n][k];}// A utility function to return// minimum of two integersfunctionmin(a, b){return(a < b) ? a : b;}// Driver codevarn = 5, k = 2;document.write("Value of C("+ n +","+ k +") is "+ binomialCoeff(n, k));// This code is contributed by 29AjayKumar</script>OutputValue of C[5][2] is 10Time Complexity: O(n*k)
Auxiliary Space: O(n*k)Following is a space-optimized version of the above code. The following code only uses O(k). Thanks to AK for suggesting this method.
C++
// C++ program for space optimized Dynamic Programming// Solution of Binomial Coefficient#include <bits/stdc++.h>usingnamespacestd;intbinomialCoeff(intn,intk){intC[k + 1];memset(C, 0,sizeof(C));C[0] = 1;// nC0 is 1for(inti = 1; i <= n; i++){// Compute next row of pascal triangle using// the previous rowfor(intj = min(i, k); j > 0; j--)C[j] = C[j] + C[j - 1];}returnC[k];}/* Driver code*/intmain(){intn = 5, k = 2;cout <<"Value of C("<< n <<","<< k <<")"<<"is "<<binomialCoeff(n, k);return0;}// This code is contributed by shivanisinghss2110C
// C++ program for space optimized Dynamic Programming// Solution of Binomial Coefficient#include <stdio.h>intbinomialCoeff(intn,intk){intC[k + 1];memset(C, 0,sizeof(C));C[0] = 1;// nC0 is 1for(inti = 1; i <= n; i++) {// Compute next row of pascal triangle using// the previous rowfor(intj = min(i, k); j > 0; j--)C[j] = C[j] + C[j - 1];}returnC[k];}/* Driver code*/intmain(){intn = 5, k = 2;printf("Value of C(%d, %d) is %d ", n, k,binomialCoeff(n, k));return0;}Java
// JAVA Code for Dynamic Programming |// Set 9 (Binomial Coefficient)importjava.util.*;classGFG {staticintbinomialCoeff(intn,intk){intC[] =newint[k +1];// nC0 is 1C[0] =1;for(inti =1; i <= n; i++) {// Compute next row of pascal// triangle using the previous rowfor(intj = Math.min(i, k); j >0; j--)C[j] = C[j] + C[j -1];}returnC[k];}/* Driver code */publicstaticvoidmain(String[] args){intn =5, k =2;System.out.printf("Value of C(%d, %d) is %d ", n, k,binomialCoeff(n, k));}}Python3
# Python program for Optimized# Dynamic Programming solution to# Binomial Coefficient. This one# uses the concept of pascal# Triangle and less memorydefbinomialCoeff(n, k):# Declaring an empty arrayC=[0foriinrange(k+1)]C[0]=1# since nC0 is 1foriinrange(1, n+1):# Compute next row of pascal triangle using# the previous rowj=min(i, k)while(j >0):C[j]=C[j]+C[j-1]j-=1returnC[k]# Driver Coden=5k=2("Value of C(%d,%d) is %d"%(n, k, binomialCoeff(n, k)))# This code is contributed by Nikhil Kumar Singh(nickzuck_007)C#
// C# Code for Dynamic Programming |// Set 9 (Binomial Coefficient)usingSystem;classGFG {staticintbinomialCoeff(intn,intk){int[] C =newint[k + 1];// nC0 is 1C[0] = 1;for(inti = 1; i <= n; i++) {// Compute next row of pascal// triangle using the previous// rowfor(intj = Math.Min(i, k); j > 0; j--)C[j] = C[j] + C[j - 1];}returnC[k];}/* Driver Code */publicstaticvoidMain(){intn = 5, k = 2;Console.WriteLine("Value of C("+ n +" "+ k+") is "+ binomialCoeff(n, k));}}// This code is contributed by anuj_67.PHP
<?php// PHP program for space optimized// Dynamic Programming Solution of// Binomial CoefficientfunctionbinomialCoeff($n,$k){$C=array_fill(0,$k+ 1, 0);$C[0] = 1;// nC0 is 1for($i= 1;$i<=$n;$i++){// Compute next row of pascal// triangle using the previous rowfor($j= min($i,$k);$j> 0;$j--)$C[$j] =$C[$j] +$C[$j- 1];}return$C[$k];}// Driver Code$n= 5;$k= 2;echo"Value of C[$n, $k] is ".binomialCoeff($n,$k);// This code is contributed by mits.?>Javascript
<script>// Javascript program for space optimized// Dynamic Programming// Solution of Binomial CoefficientfunctionbinomialCoeff(n, k){let C =newArray(k + 1);C.fill(0);// nC0 is 1C[0] = 1;for(let i = 1; i <= n; i++){// Compute next row of pascal// triangle using the previous// rowfor(let j = Math.min(i, k); j > 0; j--)C[j] = C[j] + C[j - 1];}returnC[k];}// Driver codelet n = 5, k = 2;document.write("Value of C("+ n +" "+k +") is "+ binomialCoeff(n, k));// This code is contributed by divyesh072019</script>OutputValue of C(5, 2) is 10Time Complexity: O(n*k)
Auxiliary Space: O(k)Explanation:
1==========>> n = 0, C(0,0) = 1
1–1========>> n = 1, C(1,0) = 1, C(1,1) = 1
1–2–1======>> n = 2, C(2,0) = 1, C(2,1) = 2, C(2,2) = 1
1–3–3–1====>> n = 3, C(3,0) = 1, C(3,1) = 3, C(3,2) = 3, C(3,3)=1
1–4–6–4–1==>> n = 4, C(4,0) = 1, C(4,1) = 4, C(4,2) = 6, C(4,3)=4, C(4,4)=1
So here every loop on i, builds i’th row of pascal triangle, using (i-1)th row
At any time, every element of array C will have some value (ZERO or more) and in the next iteration, the value for those elements comes from the previous iteration.
In statement,
C[j] = C[j] + C[j-1]
The right-hand side represents the value coming from the previous iteration (A row of Pascal’s triangle depends on the previous row). The left-Hand side represents the value of the current iteration which will be obtained by this statement.Let's say we want to calculate C(4, 3), i.e. n=4, k=3: All elements of array C of size 4 (k+1) are initialized to ZERO. i.e. C[0] = C[1] = C[2] = C[3] = C[4] = 0; Then C[0] is set to 1 For i = 1: C[1] = C[1] + C[0] = 0 + 1 = 1 ==>> C(1,1) = 1 For i = 2: C[2] = C[2] + C[1] = 0 + 1 = 1 ==>> C(2,2) = 1 C[1] = C[1] + C[0] = 1 + 1 = 2 ==>> C(2,1) = 2 For i=3: C[3] = C[3] + C[2] = 0 + 1 = 1 ==>> C(3,3) = 1 C[2] = C[2] + C[1] = 1 + 2 = 3 ==>> C(3,2) = 3 C[1] = C[1] + C[0] = 2 + 1 = 3 ==>> C(3,1) = 3 For i=4: C[4] = C[4] + C[3] = 0 + 1 = 1 ==>> C(4,4) = 1 C[3] = C[3] + C[2] = 1 + 3 = 4 ==>> C(4,3) = 4 C[2] = C[2] + C[1] = 3 + 3 = 6 ==>> C(4,2) = 6 C[1] = C[1] + C[0] = 3 + 1 = 4 ==>> C(4,1) = 4 C(4,3) = 4 is would be the answer in our example.Memoization Approach: The idea is to create a lookup table and follow the recursive top-down approach. Before computing any value, we check if it is already in the lookup table. If yes, we return the value. Else we compute the value and store it in the lookup table. Following is the Top-down approach of dynamic programming to finding the value of the Binomial Coefficient.
C++
// A Dynamic Programming based// solution that uses// table dp[][] to calculate// the Binomial Coefficient// A naive recursive approach// with table C++ implementation#include <bits/stdc++.h>usingnamespacestd;// Returns value of Binomial Coefficient C(n, k)intbinomialCoeffUtil(intn,intk,int** dp){// If value in lookup table then returnif(dp[n][k] != -1)//returndp[n][k];// store value in a table before returnif(k == 0) {dp[n][k] = 1;returndp[n][k];}// store value in table before returnif(k == n) {dp[n][k] = 1;returndp[n][k];}// save value in lookup table before returndp[n][k] = binomialCoeffUtil(n - 1, k - 1, dp) +binomialCoeffUtil(n - 1, k, dp);returndp[n][k];}intbinomialCoeff(intn,intk){int** dp;// make a temporary lookup tabledp =newint*[n + 1];// loop to create table dynamicallyfor(inti = 0; i < (n + 1); i++) {dp[i] =newint[k + 1];}// nested loop to initialise the table with -1for(inti = 0; i < (n + 1); i++) {for(intj = 0; j < (k + 1); j++) {dp[i][j] = -1;}}returnbinomialCoeffUtil(n, k, dp);}/* Driver code*/intmain(){intn = 5, k = 2;cout <<"Value of C("<< n <<", "<< k <<") is "<< binomialCoeff(n, k) << endl;return0;}// This is code is contributed by MOHAMMAD MUDASSIRJava
// A Dynamic Programming based// solution that uses// table dp[][] to calculate// the Binomial Coefficient// A naive recursive approach// with table Java implementationimportjava.util.*;classGFG{// Returns value of Binomial// Coefficient C(n, k)staticintbinomialCoeffUtil(intn,intk,Vector<Integer> []dp){// If value in lookup table// then returnif(dp[n].get(k) != -1)returndp[n].get(k);// store value in a table// before returnif(k ==0){dp[n].add(k,1);returndp[n].get(k);}// store value in table// before returnif(k == n){dp[n].add(k,1);returndp[n].get(k);}// save value in lookup table// before returndp[n].add(k, binomialCoeffUtil(n -1,k -1, dp) +binomialCoeffUtil(n -1,k, dp));returndp[n].get(k);}staticintbinomialCoeff(intn,intk){// Make a temporary lookup tableVector<Integer> []dp =newVector[n+1];// Loop to create table dynamicallyfor(inti =0; i < (n +1); i++){dp[i] =newVector<Integer>();for(intj =0; j <= k; j++)dp[i].add(-1);}returnbinomialCoeffUtil(n, k, dp);}// Driver codepublicstaticvoidmain(String[] args){intn =5, k =2;System.out.print("Value of C("+ n +", "+ k +") is "+binomialCoeff(n, k) +"\n");}}// This code is contributed by Rajput-JiPython3
# A Dynamic Programming based solution# that uses table dp[][] to calculate# the Binomial Coefficient. A naive# recursive approach with table# Python3 implementation# Returns value of Binomial# Coefficient C(n, k)defbinomialCoeffUtil(n, k, dp):# If value in lookup table then returnifdp[n][k] !=-1:returndp[n][k]# Store value in a table before returnifk==0:dp[n][k]=1returndp[n][k]# Store value in table before returnifk==n:dp[n][k]=1returndp[n][k]# Save value in lookup table before returndp[n][k]=(binomialCoeffUtil(n-1, k-1, dp)+binomialCoeffUtil(n-1, k, dp))returndp[n][k]defbinomialCoeff(n, k):# Make a temporary lookup tabledp=[ [-1foryinrange(k+1) ]forxinrange(n+1) ]returnbinomialCoeffUtil(n, k, dp)# Driver coden=5k=2("Value of C("+str(n)+", "+str(k)+") is",binomialCoeff(n, k))# This is code is contributed by Prateek GuptaC#
// C# program for the// above approach// A Dynamic Programming based// solution that uses// table [,]dp to calculate// the Binomial Coefficient// A naive recursive approach// with table C# implementationusingSystem;usingSystem.Collections.Generic;classGFG{// Returns value of Binomial// Coefficient C(n, k)staticintbinomialCoeffUtil(intn,intk,List<int> []dp){// If value in lookup table// then returnif(dp[n][k] != -1)returndp[n][k];// store value in a table// before returnif(k == 0){dp[n][k] = 1;returndp[n][k];}// store value in table// before returnif(k == n){dp[n][k] = 1;returndp[n][k];}// save value in lookup table// before returndp[n][k] = binomialCoeffUtil(n - 1,k - 1, dp) +binomialCoeffUtil(n - 1,k, dp);returndp[n][k];}staticintbinomialCoeff(intn,intk){// Make a temporary lookup tableList<int> []dp =newList<int>[n + 1];// Loop to create table dynamicallyfor(inti = 0; i < (n + 1); i++){dp[i] =newList<int>();for(intj = 0; j <= k; j++)dp[i].Add(-1);}returnbinomialCoeffUtil(n, k, dp);}// Driver codepublicstaticvoidMain(String[] args){intn = 5, k = 2;Console.Write("Value of C("+ n +", "+ k +") is "+binomialCoeff(n, k) +"\n");}}// This code is contributed by 29AjayKumarJavascript
<script>// A Dynamic Programming based solution that// uses table dp[][] to calculate the// Binomial Coefficient. A naive recursive// approach with table Javascript implementation// Returns value of Binomial// Coefficient C(n, k)functionbinomialCoeffUtil(n, k, dp){// If value in lookup table// then returnif(dp[n][k] != -1)returndp[n][k];// Store value in a table// before returnif(k == 0){dp[n][k] = 1;returndp[n][k];}// Store value in table// before returnif(k == n){dp[n][k] = 1;returndp[n][k];}// Save value in lookup table// before returndp[n][k] = binomialCoeffUtil(n - 1,k - 1, dp) +binomialCoeffUtil(n - 1,k, dp);returndp[n][k];}functionbinomialCoeff(n, k){// Make a temporary lookup tablelet dp =newArray(n + 1);// Loop to create table dynamicallyfor(let i = 0; i < (n + 1); i++){dp[i] = [];for(let j = 0; j <= k; j++)dp[i].push(-1);}returnbinomialCoeffUtil(n, k, dp);}// Driver codelet n = 5, k = 2;document.write("Value of C("+ n +", "+ k +") is "+binomialCoeff(n, k) +"\n");// This code is contributed by avanitrachhadiya2155</script>Time Complexity: O(n*k)
Auxiliary Space: O(n*k)
OutputValue of C(5, 2) is 10Cancellation of factors between numerator and denominator:
nCr = (n-r+1)*(n-r+2)*….*n / (r!)
Create an array arr of numbers from n-r+1 to n which will be of size r. As nCr is always an integer, all numbers in the denominator should cancel with the product of the numerator (represented by arr).
for i = 1 to i = r,
search arr, if arr[j] and i have gcd>1, divide both by the gcd and when i becomes 1, stop the search
Now, the answer is just the product of arr, whose value mod 10^9+7 can be found using a single pass and the formula use (a*b)%mod = (a%mod * b%mod)%mod
C++
// C++ program to find gcd of// two numbers in O(log(min(a,b)))#include <bits/stdc++.h>usingnamespacestd;intgcd(inta,intb){if(b == 0)returna;returngcd(b, a % b);}intnCr(intn,intr){// base caseif(r > n)return0;// C(n,r) = C(n,n-r)if(r > n - r)r = n - r;intmod = 1000000007;// array of elements from n-r+1 to nintarr[r];for(inti = n - r + 1; i <= n; i++) {arr[i + r - n - 1] = i;}longintans = 1;// for numbers from 1 to r find arr[j],// such that gcd(i,arr[j])>1for(intk = 1; k < r + 1; k++) {intj = 0, i = k;while(j < r) {intx = gcd(i, arr[j]);if(x > 1) {// if gcd>1, divide both by gcdarr[j] /= x;i /= x;}// if i becomes 1, no need to search arrif(i == 1)break;j += 1;}}// single pass to multiply the numeratorfor(inti : arr)ans = (ans * i) % mod;return(int)ans;}intmain(){intn = 5, r = 2;cout <<"Value of C("<< n <<", "<< r <<") is "<< nCr(n, r) <<"\n";return0;}// This code is contributed by rajsanghavi9.Java
importjava.util.*;classGFG{staticintgcd(inta,intb)// function to find gcd of two numbers in O(log(min(a,b))){if(b==0)returna;returngcd(b,a%b);}staticintnCr(intn,intr){if(r>n)// base casereturn0;if(r>n-r)// C(n,r) = C(n,n-r) better time complexity for lesser r valuer = n-r;intmod =1000000007;int[] arr =newint[r];// array of elements from n-r+1 to nfor(inti=n-r+1; i<=n; i++){arr[i+r-n-1] = i;}longans =1;for(intk=1;k<r+1;k++)// for numbers from 1 to r find arr[j] such that gcd(i,arr[j])>1{intj=0, i=k;while(j<arr.length){intx = gcd(i,arr[j]);if(x>1){arr[j] /= x;// if gcd>1, divide both by gcdi /= x;}if(i==1)break;// if i becomes 1, no need to search arrj +=1;}}for(inti : arr)// single pass to multiply the numeratorans = (ans*i)%mod;return(int)ans;}// Driver codepublicstaticvoidmain(String[] args){intn =5, r =2;System.out.print("Value of C("+ n+", "+ r+") is "+nCr(n, r) +"\n");}}// This code is contributed by Gautam WadhwaniPython3
importmathclassGFG:defnCr(self, n, r):defgcd(a,b):# function to find gcd of two numbers in O(log(min(a,b)))ifb==0:# base casereturnareturngcd(b,a%b)ifr>n:return0ifr>n-r:# C(n,r) = C(n,n-r) better time complexity for lesser r valuer=n-rmod=10**9+7arr=list(range(n-r+1,n+1))# array of elements from n-r+1 to nans=1foriinrange(1,r+1):# for numbers from 1 to r find arr[j] such that gcd(i,arr[j])>1j=0whilej<len(arr):x=gcd(i,arr[j])ifx>1:arr[j]//=x# if gcd>1, divide both by gcdi//=xifarr[j]==1:# if element becomes 1, its of no use anymore so delete from arrdelarr[j]j-=1ifi==1:break# if i becomes 1, no need to search arrj+=1foriinarr:# single pass to multiply the numeratorans=(ans*i)%modreturnans# Driver coden=5k=2ob=GFG()("Value of C("+str(n)+", "+str(k)+") is",ob.nCr(n, k))# This is code is contributed by Gautam WadhwaniC#
usingSystem;classGFG{// Function to find gcd of two numbers// in O(log(min(a,b)))staticintgcd(inta,intb){if(b == 0)returna;returngcd(b, a % b);}staticintnCr(intn,intr){// Base caseif(r > n)return0;// C(n,r) = C(n,n-r) better time// complexity for lesser r valueif(r > n - r)r = n - r;intmod = 1000000007;// Array of elements from n-r+1 to nint[] arr =newint[r];for(inti = n - r + 1; i <= n; i++){arr[i + r - n - 1] = i;}longans = 1;// For numbers from 1 to r find arr[j]// such that gcd(i,arr[j])>1for(intk = 1; k < r + 1; k++){intj = 0, i = k;while(j < arr.Length){intx = gcd(i,arr[j]);if(x > 1){// If gcd>1, divide both by gcdarr[j] /= x;i /= x;}if(i == 1)// If i becomes 1, no need// to search arrbreak;j += 1;}}// Single pass to multiply the numeratorforeach(intiinarr)ans = (ans * i) % mod;return(int)ans;}// Driver codestaticpublicvoidMain(){intn = 5, r = 2;Console.WriteLine("Value of C("+ n +", "+ r +") is "+nCr(n, r) +"\n");}}// This code is contributed by rag2127Javascript
<script>// Javascript program to find gcd of// two numbers in O(log(min(a,b)))functiongcd(a, b){if(b == 0)returna;returngcd(b, a % b);}functionnCr(n, r){// Base caseif(r > n)return0;// C(n,r) = C(n,n-r) better time// complexity for lesser r valueif(r > n - r)r = n - r;mod = 1000000007;// Array of elements from n-r+1 to nvararr =newArray(r);for(vari = n - r + 1; i <= n; i++){arr[i + r - n - 1] = i;}varans = 1;// For numbers from 1 to r find arr[j]// such that gcd(i,arr[j])>1for(vark = 1; k < r + 1 ; k++){varj = 0, i = k;while(j < arr.length){varx = gcd(i, arr[j]);if(x > 1){// If gcd>1, divide both by gcdarr[j] /= x;i /= x;}// If i becomes 1, no need to search arrif(i == 1)break;j += 1;}}// Single pass to multiply the numeratorarr.forEach(function(i){ans = (ans * i) % mod;});returnans;}// Driver codevarn = 5, r = 2;document.write("Value of C("+ n +", "+r +") is "+ nCr(n, r) +"\n");// This code is contributed by shivanisinghss2110</script>OutputValue of C(5, 2) is 10Time Complexity: O(( min(r, n-r)^2 ) * log(n)), useful when n >> r or n >> (n-r)
Auxiliary Space: O(min(r, n-r))
See this for GCD in logarithmic time
Prime factorization of every number from 1 to n using Sieve of Eratosthenes :
1. Create an array SPF of size n+1 to the smallest prime factor of each number from 1 to n
Set SPF[i] = i for all i = 1 to i = n2. Use Sieve of Eratosthenes:
for i = 2 to i = n: if i is prime, for all multiples j of i, j<=n: if SPF[j] equals j, set SPF[j] = i3. Once, we know the SPF of each number from 1 to n, we can find the prime factorization of any number from 1 to n in O(log(n)) time using recursive division by SPF until the number becomes 1
Now, nCr = (n-r+1)*(r+2)* ... *(n) / (r)!4. Create a dictionary (or hashmap) to store the frequency of each prime in the prime factorization of the actual value of nCr.
5. So, just calculate the frequency of each prime in nCr and multiply them raised to the power of their frequency.
6. For the numerator, iterate through i = n-r+1 to i = n, and for all prime factors of i, store their frequency in a dictionary.
( prime_pow[prime_factor] += freq_in_i )7. For the denominator, iterate through i = 1 to i = r and now subtract the frequency instead of adding.
8. Now, traverse the dictionary and multiply the answer to (prime ^ prime_pow[prime]) % (10^9 + 7)
ans = (ans * pow(prime, prime_pow[prime], mod) ) % modC++
#include <bits/stdc++.h>usingnamespacestd;// pow(base,exp,mod) is used to find// (base^exp)%mod fast -> O(log(exp))longintpow(longintb,longintexp,longintmod){longintret = 1;while(exp> 0) {if((exp& 1) > 0)ret = (ret * b) % mod;b = (b * b) % mod;exp>>= 1;}returnret;}intnCr(intn,intr){// base caseif(r > n)return0;// C(n,r) = C(n,n-r) Complexity for// this code is lesser for lower n-rif(n - r > r)r = n - r;// list to smallest prime factor// of each number from 1 to nintSPF[n + 1];// set smallest prime factor of each// number as itselffor(inti = 1; i <= n; i++)SPF[i] = i;// set smallest prime factor of all// even numbers as 2for(inti = 4; i <= n; i += 2)SPF[i] = 2;for(inti = 3; i * i < n + 1; i += 2) {// Check if i is primeif(SPF[i] == i) {// All multiples of i are// composite (and divisible by// i) so add i to their prime// factorization getpow(j,i)// timesfor(intj = i * i; j < n + 1; j += i)if(SPF[j] == j) {SPF[j] = i;}}}// Hash Map to store power of// each prime in C(n,r)map<int,int> prime_pow;// For numerator count frequency of each prime factorfor(inti = r + 1; i < n + 1; i++) {intt = i;// Recursive division to find// prime factorization of iwhile(t > 1) {if(!prime_pow[SPF[t]]) {prime_pow[SPF[t]] = 1;}elseprime_pow[SPF[t]]++;// prime_pow.put(SPF[t],// prime_pow.getOrDefault(SPF[t], 0)// + 1);t /= SPF[t];}}// For denominator subtract the power of// each prime factorfor(inti = 1; i < n - r + 1; i++) {intt = i;// Recursive division to find// prime factorization of iwhile(t > 1) {prime_pow[SPF[t]]--;// prime_pow.put(SPF[t],// prime_pow.get(SPF[t]) - 1);t /= SPF[t];}}// long because mod is large and a%mod// * b%mod can overflow intlongintans = 1, mod = 1000000007;// use (a*b)%mod = (a%mod * b%mod)%modfor(autoit : prime_pow)// pow(base,exp,mod) is used to// find (base^exp)%mod fastans = (ans*pow(it.first, prime_pow[it.first], mod))% mod;return(int)ans;}intmain(){intn = 5, r = 2;cout <<"Value of C("<< n <<", "<< r <<") is "<< nCr(n, r) <<"\n";return0;}// This code is contributed by rajsanghavi9.Java
importjava.util.*;classGFG {// pow(base,exp,mod) is used to find// (base^exp)%mod fast -> O(log(exp))staticlongpow(longb,longexp,longmod){longret =1;while(exp >0) {if((exp &1) >0)ret = (ret * b) % mod;b = (b * b) % mod;exp >>=1;}returnret;}staticintnCr(intn,intr){if(r > n)// base casereturn0;// C(n,r) = C(n,n-r) Complexity for// this code is lesser for lower n-rif(n - r > r)r = n - r;// list to smallest prime factor// of each number from 1 to nint[] SPF =newint[n +1];// set smallest prime factor of each// number as itselffor(inti =1; i <= n; i++)SPF[i] = i;// set smallest prime factor of all// even numbers as 2for(inti =4; i <= n; i +=2)SPF[i] =2;for(inti =3; i * i < n +1; i +=2){// Check if i is primeif(SPF[i] == i){// All multiples of i are// composite (and divisible by// i) so add i to their prime// factorization getpow(j,i)// timesfor(intj = i * i; j < n +1; j += i)if(SPF[j] == j) {SPF[j] = i;}}}// Hash Map to store power of// each prime in C(n,r)Map<Integer, Integer> prime_pow=newHashMap<>();// For numerator count frequency of each prime factorfor(inti = r +1; i < n +1; i++){intt = i;// Recursive division to find// prime factorization of iwhile(t >1){prime_pow.put(SPF[t],prime_pow.getOrDefault(SPF[t],0) +1);t /= SPF[t];}}// For denominator subtract the power of// each prime factorfor(inti =1; i < n - r +1; i++){intt = i;// Recursive division to find// prime factorization of iwhile(t >1){prime_pow.put(SPF[t],prime_pow.get(SPF[t]) -1);t /= SPF[t];}}// long because mod is large and a%mod// * b%mod can overflow intlongans =1, mod =1000000007;// use (a*b)%mod = (a%mod * b%mod)%modfor(inti : prime_pow.keySet())// pow(base,exp,mod) is used to// find (base^exp)%mod fastans = (ans * pow(i, prime_pow.get(i), mod))% mod;return(int)ans;}// Driver codepublicstaticvoidmain(String[] args){intn =5, r =2;System.out.print("Value of C("+ n +", "+ r+") is "+ nCr(n, r) +"\n");}}// This code is contributed by Gautam WadhwaniPython3
# Python code for the above approachimportmathclassGFG:defnCr(self, n, r):# Base caseifr > n:return0# C(n,r) = C(n,n-r) Complexity for this# code is lesser for lower n-rifn-r > r:r=n-r# List to store smallest prime factor# of every number from 1 to nSPF=[iforiinrange(n+1)]foriinrange(4, n+1,2):# set smallest prime factor of# all even numbers as 2SPF[i]=2foriinrange(3, n+1,2):ifi*i > n:break# Check if i is primeifSPF[i]==i:# All multiples of i are composite# (and divisible by i) so add i to# their prime factorization getpow(j,i) timesforjinrange(i*i, n+1, i):ifSPF[j]==j:# set smallest prime factor# of j to i only if it is# not previously setSPF[j]=i# dictionary to store power of each prime in C(n,r)prime_pow={}# For numerator count frequency# of each prime factorforiinrange(r+1, n+1):t=i# Recursive division to# find prime factorization of iwhilet >1:ifnotSPF[t]inprime_pow:prime_pow[SPF[t]]=1else:prime_pow[SPF[t]]+=1t//=SPF[t]# For denominator subtract the# power of each prime factorforiinrange(1, n-r+1):t=i# Recursive division to# find prime factorization of iwhilet >1:prime_pow[SPF[t]]-=1t//=SPF[t]ans=1mod=10**9+7# Use (a*b)%mod = (a%mod * b%mod)%modforiinprime_pow:# pow(base,exp,mod) is used to# find (base^exp)%mod fastans=(ans*pow(i, prime_pow[i], mod))%modreturnans# Driver coden=5k=2ob=GFG()("Value of C("+str(n)+", "+str(k)+") is",ob.nCr(n, k))# This is code is contributed by Gautam WadhwaniC#
usingSystem;usingSystem.Collections.Generic;publicclassGFG {// pow(base,exp,mod) is used to find// (base^exp)%mod fast -> O(log(exp))staticlongpow(longb,longexp,longmod){longret = 1;while(exp > 0) {if((exp & 1) > 0)ret = (ret * b) % mod;b = (b * b) % mod;exp >>= 1;}returnret;}staticintnCr(intn,intr){if(r > n)// base casereturn0;// C(n,r) = C(n,n-r) Complexity for// this code is lesser for lower n-rif(n - r > r)r = n - r;// list to smallest prime factor// of each number from 1 to nint[] SPF =newint[n + 1];// set smallest prime factor of each// number as itselffor(inti = 1; i <= n; i++)SPF[i] = i;// set smallest prime factor of all// even numbers as 2for(inti = 4; i <= n; i += 2)SPF[i] = 2;for(inti = 3; i * i < n + 1; i += 2) {// Check if i is primeif(SPF[i] == i) {// All multiples of i are// composite (and divisible by// i) so add i to their prime// factorization getpow(j,i)// timesfor(intj = i * i; j < n + 1; j += i)if(SPF[j] == j) {SPF[j] = i;}}}// Hash Map to store power of// each prime in C(n,r)Dictionary<int,int> prime_pow=newDictionary<int,int>();// For numerator count frequency of each prime// factorfor(inti = r + 1; i < n + 1; i++) {intt = i;// Recursive division to find// prime factorization of iwhile(t > 1) {if(prime_pow.ContainsKey(SPF[t])) {prime_pow[SPF[t]]= prime_pow[SPF[t]] + 1;}else{prime_pow.Add(SPF[t], 1);}t /= SPF[t];}}// For denominator subtract the power of// each prime factorfor(inti = 1; i < n - r + 1; i++) {intt = i;// Recursive division to find// prime factorization of iwhile(t > 1) {if(prime_pow.ContainsKey(SPF[t])) {prime_pow[SPF[t]]= prime_pow[SPF[t]] - 1;}t /= SPF[t];}}// long because mod is large and a%mod// * b%mod can overflow intlongans = 1, mod = 1000000007;// use (a*b)%mod = (a%mod * b%mod)%modforeach(intiinprime_pow.Keys)// pow(base,exp,mod) is used to// find (base^exp)%mod fastans= (ans * pow(i, prime_pow[i], mod)) % mod;return(int)ans;}// Driver codepublicstaticvoidMain(String[] args){intn = 5, r = 2;Console.Write("Value of C("+ n +", "+ r +") is "+ nCr(n, r) +"\n");}}// This code contributed by gauravrajput1Javascript
<script>// Javascript program to find gcd of// two numbers in O(log(min(a,b)))functiongcd(a, b){if(b == 0)returna;returngcd(b, a % b);}functionnCr(n, r){// base caseif(r > n)return0;// C(n,r) = C(n,n-r)if(r > n - r)r = n - r;varmod = 1000000007;// array of elements from n-r+1 to nvararr =newArray(r);for(vari = n - r + 1; i <= n; i++) {arr[i + r - n - 1] = i;}varans = 1;// for numbers from 1 to r find arr[j],// such that gcd(i,arr[j])>1for(vark = 1; k < r + 1; k++) {varj = 0;vari = k;do{varx = gcd(i, arr[j]);if(x > 1) {// if gcd>1, divide both by gcdarr[j] /= x;i /= x;}// if i becomes 1, no need to search arrif(i == 1)break;j += 1;}while(j < r);}// single pass to multiply the numeratorarr.forEach(function(i, index) {ans = (ans * i) % mod;});returnans;}varn = 5;varr = 2;document.write("Value of C("+ n +", "+ r +") is "+ nCr(n, r) +"<br>");// This code is contributed by shivani.</script>OutputValue of C(5, 2) is 10Time Complexity: O(n*log(n)), so useful when r->n/2
Auxiliary Space: O(n)
See this for Prime factorization in O(log(n))
Another Approach: (Modular Inversion technique)
1. The general formula of nCr is ( n*(n-1)*(n-2)* … *(n-r+1) ) / (r!). We can directly use this formula to find nCr. But that will overflow out of bound. We need to find nCr mod m so that it doesn’t overflow. We can easily do it with modular arithmetic formula.
for the n*(n-1)*(n-2)* ... *(n-r+1) part we can use the formula, (a*b) mod m = ((a % m) * (b % m)) % m2. and for the 1/r! part, we need to find the modular inverse of every number from 1 to r. Then use the same formula above with a modular inverse of 1 to r. We can find modular inverse in O(r) time using the formula,
inv[1] = 1 inv[i] = − ⌊m/i⌋ * inv[m mod i] mod m To use this formula, m has to be a prime.In the practice problem, we need to show the answer with modulo 1000000007 which is a prime.
So, this technique will work.
C++
// C++ program for the above approach#include<bits/stdc++.h>usingnamespacestd;// Function to find binomial// coefficientintbinomialCoeff(intn,intr){if(r > n)return0;longlongintm = 1000000007;longlongintinv[r + 1] = { 0 };inv[0] = 1;if(r+1>=2)inv[1] = 1;// Getting the modular inversion// for all the numbers// from 2 to r with respect to m// here m = 1000000007for(inti = 2; i <= r; i++) {inv[i] = m - (m / i) * inv[m % i] % m;}intans = 1;// for 1/(r!) partfor(inti = 2; i <= r; i++) {ans = ((ans % m) * (inv[i] % m)) % m;}// for (n)*(n-1)*(n-2)*...*(n-r+1) partfor(inti = n; i >= (n - r + 1); i--) {ans = ((ans % m) * (i % m)) % m;}returnans;}/* Driver code*/intmain(){intn = 5, r = 2;cout <<"Value of C("<< n <<", "<< r <<") is "<< binomialCoeff(n, r) << endl;return0;}Java
// JAVA program for the above approachimportjava.util.*;classGFG{// Function to find binomial// coefficientstaticintbinomialCoeff(intn,intr){if(r > n)return0;longm =1000000007;longinv[] =newlong[r +1];inv[0] =1;if(r+1>=2)inv[1] =1;// Getting the modular inversion// for all the numbers// from 2 to r with respect to m// here m = 1000000007for(inti =2; i <= r; i++) {inv[i] = m - (m / i) * inv[(int) (m % i)] % m;}intans =1;// for 1/(r!) partfor(inti =2; i <= r; i++) {ans = (int) (((ans % m) * (inv[i] % m)) % m);}// for (n)*(n-1)*(n-2)*...*(n-r+1) partfor(inti = n; i >= (n - r +1); i--) {ans = (int) (((ans % m) * (i % m)) % m);}returnans;}/* Driver code*/publicstaticvoidmain(String[] args){intn =5, r =2;System.out.print("Value of C("+ n+", "+ r+") is "+binomialCoeff(n, r) +"\n");}}// This code contributed by Rajput-JiPython3
# Python3 program for the above approach# Function to find binomial# coefficientdefbinomialCoeff(n, r):if(r > n):return0m=1000000007inv=[0foriinrange(r+1)]inv[0]=1;if(r+1>=2)inv[1]=1;# Getting the modular inversion# for all the numbers# from 2 to r with respect to m# here m = 1000000007foriinrange(2, r+1):inv[i]=m-(m//i)*inv[m%i]%mans=1# for 1/(r!) partforiinrange(2, r+1):ans=((ans%m)*(inv[i]%m))%m# for (n)*(n-1)*(n-2)*...*(n-r+1) partforiinrange(n, n-r,-1):ans=((ans%m)*(i%m))%mreturnans# Driver coden=5r=2("Value of C(",n ,", ", r ,") is ",binomialCoeff(n, r))# This code is contributed by rohan07C#
// C# program for the above approachusingSystem;publicclassGFG{// Function to find binomial// coefficientstaticintbinomialCoeff(intn,intr){if(r > n)return0;longm = 1000000007;long[]inv =newlong[r + 1];inv[0] = 1;if(r+1>=2)inv[1] = 1;// Getting the modular inversion// for all the numbers// from 2 to r with respect to m// here m = 1000000007for(inti = 2; i <= r; i++) {inv[i] = m - (m / i) * inv[(int) (m % i)] % m;}intans = 1;// for 1/(r!) partfor(inti = 2; i <= r; i++) {ans = (int) (((ans % m) * (inv[i] % m)) % m);}// for (n)*(n-1)*(n-2)*...*(n-r+1) partfor(inti = n; i >= (n - r + 1); i--) {ans = (int) (((ans % m) * (i % m)) % m);}returnans;}/* Driver code*/publicstaticvoidMain(String[] args){intn = 5, r = 2;Console.Write("Value of C("+ n+", "+ r+") is "+binomialCoeff(n, r) +"\n");}}// This code is contributed by 29AjayKumarJavascript
<script>// JavaScript Program for the above approach// Function to find binomial// coefficientfunctionbinomialCoeff(n, r) {if(r > n)return0;let m = 1000000007;let inv =newArray(r + 1).fill(0);inv[0] = 1;if(r + 1 >= 2)inv[1] = 1;// Getting the modular inversion// for all the numbers// from 2 to r with respect to m// here m = 1000000007for(let i = 2; i <= r; i++) {inv[i] = m - Math.floor(m / i) * inv[m % i] % m;}let ans = 1;// for 1/(r!) partfor(let i = 2; i <= r; i++) {ans = ((ans % m) * (inv[i] % m)) % m;}// for (n)*(n-1)*(n-2)*...*(n-r+1) partfor(let i = n; i >= (n - r + 1); i--) {ans = ((ans % m) * (i % m)) % m;}returnans;}/* Driver code*/let n = 5, r = 2;document.write("Value of C("+ n +", "+ r +") is "+ binomialCoeff(n, r) +"<br>");// This code is contributed by Potta Lokesh</script>OutputValue of C(5, 2) is 10Time Complexity: O(n+k)
Auxiliary Space: O(k)
See this for Space and time-efficient Binomial Coefficient
https://cp-algorithms.com/algebra/module-inverse.html
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
My Personal Notes arrow_drop_upRecommended ArticlesPage :Article Contributed By :Improved By :
- jit_t
- vt_m
- Mithun Kumar
- Shivi_Aggarwal
- rathbhupendra
- Akanksha_Rai
- MohammadMudassir
- PrateekGupta10
- mr_hitman
- Rajput-Ji
- 29AjayKumar
- mansimar_anand
- divyanshusrivastava1
- 1505086kmr
- gautamsw5
- amit143katiyar
- divyesh072019
- rohan07
- jyoti369
- surindertarika1234
- lokeshpotta20
- avanitrachhadiya2155
- rag2127
- rajsanghavi9
- shivanisinghss2110
- akshaysingh98088
- reenadevi98412200
- simmytarika5
- GauravRajput1
- amartyaghoshgfg
- prophet1999
- surinderdawra388
- kaushallodd62
- jainlovely450
Article Tags :Practice Tags :




