Binomial Coefficient

Binomial coefficient is a positive integer that occur as coefficient in the Binomial Theorem. It can be defined as the coefficient of the monomial Xk in the expansion of (1 + X)n .

This coefficient also occurs in the formula given below

(x+y)^{n}=\sum _{k=0}^{n}{\binom {n}{k}}x^{n-k}y^{k}
#include <stdio.h>

int Coeff(int n, int k)
{

	if (k > n)
		return 0;
	if (k == 0 || k == n)
		return 1;
	return Coeff(n - 1, k - 1)
		+ Coeff(n - 1, k);
}

int main()
{
	int n , k ;
	printf("Enter first number : \n");
	scanf("%i",&n);
	printf("Enter second number : \n");
	scanf("%i",&k);
	printf("Value of K(%d, %d) is %d ", n, k,
		Coeff(n, k));
	return 0;
}

Leave a comment

Create a website or blog at WordPress.com

Up ↑

Design a site like this with WordPress.com
Get started