Please help me in doing this program
Attachments:
Answers
Answered by
1
Answer:
Explanation:
In this Question, You Have to Calculate factorial three times. So, It's easy to make a function for factorial and call this function in the formula.
I hope You Understand :-)
Attachments:
Answered by
1
Answer:
import java.util.*;
public class Main
{
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
int r=sc.nextInt();
int nfact=afact(n);
int rfact=afact(r);
int nmr=afact(n-r);
int fact= nfact/(rfact*nmr);
System.out.println(fact);
}
public static int afact(int a)
{ int fact=1;
for( int i=1;i<=a;i++)
{
fact=fact*i;
}
return fact;
}
}
Explanation:
it is a java program
Attachments:
Similar questions