Code Below:
// Permutation & Combination formula using return function
import java.util.*;
class returnprg2
{
public static double fact(int x)
{
double f=1.0;
for (int i=1;i< x;i++)
{
f=f*i;
}
return (f);
}
public static void main()
{
Scanner s=new Scanner(System.in);
int n,r;
System.out.println("enter the values respectively");
n=s.nextInt();
r=s.nextInt();
System.out.println("Permuation="+(fact(n)/fact(n-r)));
System.out.println("Combination="+(fact(n)/(fact(r)*fact(n-r))));
}
}