import java.util.Scanner;
public class Factorial
{
static long fact(long n)
{
long f=1;
for(long i=n;i>0;i--)
{
f=f*i;
}
return(f);
}
public static void main(String[] args)
{
long n,r,nCr,nPr;
Scanner s=new Scanner(System.in);
System.out.print("Enter value of n:");
n=s.nextInt();
System.out.print("Enter value of r:");
r=s.nextInt();
s.close();
nPr=fact(n)/fact(n-r);
System.out.print(+n+"P"+r+" is = "+nPr);
nCr=fact(n)/(fact(n-r)*fact(r));
System.out.print("\n"+n+"C"+r+" is = "+nCr);
}
}
*** Input && Output ***
0 Comments