File tree 1 file changed +52
-0
lines changed
1 file changed +52
-0
lines changed Original file line number Diff line number Diff line change
1
+ import java .util .Scanner ;
2
+
3
+ class Bino {
4
+ int p , m , e , w ;
5
+ int comb ;
6
+ Scanner sc = new Scanner (System .in );
7
+
8
+ Bino () {
9
+ p = 0 ;
10
+ m = 0 ;
11
+ }
12
+
13
+ void input () {
14
+ System .out .println ("Enter the first number (p): " );
15
+ p = sc .nextInt ();
16
+ System .out .println ("Enter the second number (m): " );
17
+ m = sc .nextInt ();
18
+ System .out .println ("Enter the highest power (w): " );
19
+ w = sc .nextInt ();
20
+ System .out .println ("Enter the lowest power (e): " );
21
+ e = sc .nextInt ();
22
+ }
23
+
24
+ int fact (int x ) {
25
+ int s = 1 ;
26
+ for (int i = 1 ; i <= x ; i ++) {
27
+ s = s * i ;
28
+ }
29
+ return s ;
30
+ }
31
+
32
+ int compute () {
33
+ int a = fact (p );
34
+ int b = fact (m );
35
+ int k = fact (p - m );
36
+ comb = a / (b * k );
37
+ return comb ;
38
+ }
39
+
40
+ void bmial () {
41
+ int d = compute ();
42
+ System .out .print (d + " * " + Math .pow (p , w ) + " * " + Math .pow (m , e ));
43
+ w --;
44
+ e ++;
45
+ }
46
+
47
+ public static void main (String [] args ) {
48
+ Bino ob = new Bino ();
49
+ ob .input ();
50
+ ob .bmial ();
51
+ }
52
+ }
You can’t perform that action at this time.
0 commit comments