ncr means : combination in terms of mathematics.We have to find out the perfect combination of given values.
In the mathematics nCr has defined as nCr = n! /((n-r)! * r!)
#include
int main(){
int n,r,ncr;
printf("Enter any two numbers->");
scanf("%d %d",&n,&r);
ncr=fact(n)/(fact(r)*fact(n-r)); //fact denotes factorial of a number .
printf("The NCR factor of %d and %d is %d",n,r,ncr);
return 0;
}
int fact(int n) // this is a factorial finding function
{
int i=1;
while(n!=0){
i=i*n;
n--;
}
return i;
}
sample output:
6 4
The NCR factor of 6 and 4 is 15
0 Comment(s)