152.C Program to find Binomial Co-Efficient using recursion.
How does this program work?
- In this C programme you will learn about how to find the binomial coefficient using recursion.
Here is the code
#include <stdio.h>
int main(void)
{
int n,r,ncr;
printf("Enter N and R values: \n");
scanf("%d %d",&n,&r);
ncr=fact(n)/(fact(r)*fact(n-r));
printf("The NCR of %d and %d is %d",n,r,ncr);
}
// x is a parameter
// Compute NCR using n!/(n-r)!*r!
int fact(int x)
{
int i=1;
while(x!=0)
{
i=i*x;
x--;
}
return i;
}