class Solution {
public int solution(int a, int b) {
int gcd = gcd(a, b);
a /= gcd;
b /= gcd;
while(b%2 == 0){
b /= 2;
}
while(b % 5 == 0){
b /= 5;
}
return b == 1 ? 1 : 2;
}
public static int gcd(int a, int b) {
if ( b == 0){
return a;
}
return gcd(b, a % b);
}
}
최대공약수를 구하는 코드를 알고있으면 쉽게 풀 수 있는 문제였다.