-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathFun47.java
More file actions
38 lines (37 loc) · 953 Bytes
/
Fun47.java
File metadata and controls
38 lines (37 loc) · 953 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package fun;
public class Fun47 {
public static void main(String[] args) {
frac1 (630, 198);//630/18=35==>198/18=>11
frac1 (630, 24);//630/6=105==>24/6=>4
frac1 (630, 84);//
}
public static int EKUB(int a,int b){//24 va 18
int max=Integer.MIN_VALUE;//
int t,m=0,e=0;
int tb,mb=0;
for (int i = 1; i <= a; i++) {
t=a%i;//
if (t==0){
m=i;
}
for (int j = 1; j <=b ; j++) {
tb=b%j;//
if ( tb==0 ){
mb=j;
}
if ( m==mb ){
e=m;
}
if (max<e ){
max=e;
}
}
}
return max;//max=>18
}
public static void frac1(int g,int h){
int p=g/EKUB (g,h);
int q=h/EKUB (g,h);
System.out.println (p+"/"+q);
}
}