一切盡在代碼中
1 /**
2 *
3 */
4 package com.lgc.interview;
5
6 /**
7 * @author lgcpeter
8 * 求三個數(shù)的最小公倍數(shù)
9 */
10 public class ThreeMulti {
11
12 /**
13 * @param a,b
14 * @return
15 * 求兩個數(shù)的最大公約數(shù)
16 */
17 public int gongYue(int a,int b){
18 int m = 1;
19 //如果a小于b則交換位置
20 if(a<b){
21 m = a;
22 a = b;
23 b = m;
24 }
25 while(m != 0){
26 m = a%b;
27 a = b;
28 b = m;
29 }
30 return a;
31 }
32
33 /**
34 * @param a,b
35 * @return
36 * 求兩個數(shù)的最小公倍數(shù)
37 */
38 public int gongBei(int a,int b){
39 int gb = 0;
40 gb = a*b/gongYue(a,b);
41 return gb;
42 }
43
44 /**
45 * @param a,b,c
46 * @return
47 * 三個數(shù)的最小公倍數(shù)
48 */
49 public int threeGB(int a,int b,int c){
50 int t = 0;
51 int mid = 0;
52 mid = this.gongBei(a,b);
53 t = this.gongBei(mid,c);
54 return t;
55 }
56 }
2 *
3 */
4 package com.lgc.interview;
5
6 /**
7 * @author lgcpeter
8 * 求三個數(shù)的最小公倍數(shù)
9 */
10 public class ThreeMulti {
11
12 /**
13 * @param a,b
14 * @return
15 * 求兩個數(shù)的最大公約數(shù)
16 */
17 public int gongYue(int a,int b){
18 int m = 1;
19 //如果a小于b則交換位置
20 if(a<b){
21 m = a;
22 a = b;
23 b = m;
24 }
25 while(m != 0){
26 m = a%b;
27 a = b;
28 b = m;
29 }
30 return a;
31 }
32
33 /**
34 * @param a,b
35 * @return
36 * 求兩個數(shù)的最小公倍數(shù)
37 */
38 public int gongBei(int a,int b){
39 int gb = 0;
40 gb = a*b/gongYue(a,b);
41 return gb;
42 }
43
44 /**
45 * @param a,b,c
46 * @return
47 * 三個數(shù)的最小公倍數(shù)
48 */
49 public int threeGB(int a,int b,int c){
50 int t = 0;
51 int mid = 0;
52 mid = this.gongBei(a,b);
53 t = this.gongBei(mid,c);
54 return t;
55 }
56 }