Deep_Dev
article thumbnail

 


์ตœ๋Œ€๊ณต์•ฝ์ˆ˜์™€ ์ตœ์†Œ๊ณต๋ฐฐ์ˆ˜ ---> ์œ ํด๋ฆฌ๋“œ ํ˜ธ์ œ๋ฒ•

 

๐Ÿ’ก ์ตœ๋Œ€๊ณต์•ฝ์ˆ˜

int gcd(int a, int b){

    if(b==0) return a;

    return gcd(b,a%b);

}

 

๐Ÿ’ก ์ตœ์†Œ๊ณต๋ฐฐ์ˆ˜

a*b / ์ตœ๋Œ€๊ณต์•ฝ์ˆ˜

 


import java.util.*;

class Main {
    public static void main(String args[]) throws Exception {
        Scanner kb = new Scanner(System.in);
        int a = kb.nextInt();
        int b = kb.nextInt();
        int max=gcd(a,b); // ์ตœ๋Œ€๊ณต์•ฝ์ˆ˜
        int min=(a*b)/max;
        System.out.println(max);
        System.out.print(min);
    }

    static int gcd(int a, int b){
        if(b==0) return a;
        return gcd(b,a%b);
    }
}