Combination Class
public class Combination{
public void printCombintion(int n,int r)
{
Factorial fact = new Factorial();
int ncr = fact.fact(n)/(fact.fact(r)*fact.fact(n-r));
System.out.println("NCR : "+ncr);
}
}
Factorial Class
public class Factorial{
public int fact(int n)
{
if(n<=1)
return 1;
return n*fact(n-1);
}
}

0 Comments