0
1.4kviews
Write a program in Java to find "C and "P
1 Answer
0
8views
import java.util.*;
class permutation
{
public static int fact(int num)
{
    int fact=1,i;
    for(i=1;i<=num;i++)
    fact=fact*i;
    return fact;
}
public static void main(String args[])
{
    Scanner sc=new Scanner(System.in);
    System.out.println("Enter n");
    int n=sc.nextInt();
    System.out.println("Enter r");
        int r=sc.nextInt();
    System.out.println("Ncr ="+(fact(n)/(fact(n-r)*fact(r))));
    System.out.println("Npr ="+(fact(n)/(fact(n-r))));
    }
}
Please log in to add an answer.