[백준] 2609 최소공배수와 최대공약수 풀이
import java.util.*;
public class Main {
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
int b = sc.nextInt();
int a1 = Math.max(a,b);
int b1 = Math.min(a,b);
while(b1 != 0){
int r = a1%b1;
a1 = b1;
b1 = r;
}
System.out.println(a1);
System.out.println((a*b)/a1);
}
}
Comments